diff --git a/core/modules/aggregator/src/Tests/Views/AggregatorFeedViewsFieldAccessTest.php b/core/modules/aggregator/src/Tests/Views/AggregatorFeedViewsFieldAccessTest.php index a8e3f31..cd6bf4b 100644 --- a/core/modules/aggregator/src/Tests/Views/AggregatorFeedViewsFieldAccessTest.php +++ b/core/modules/aggregator/src/Tests/Views/AggregatorFeedViewsFieldAccessTest.php @@ -35,19 +35,38 @@ protected function setUp($import_test_views = TRUE) { * Checks access for aggregator_feed fields. */ public function testAggregatorFeedFields() { - $feed = Feed::create([ + $feed = Feed::create([ 'title' => 'Drupal org', 'url' => 'https://www.drupal.org/rss.xml', 'link' => 'https://www.drupal.org/rss.xml', + 'uuid' => 'Universally Unique Identifier', + 'refresh' => 60, + 'checked' => 1, + 'queued' => 0, + 'description' => 'Get description of feed', + 'image' => 'Get description of feed', + 'hash' => 'Get hash', + 'etag' => 'Get entity tag', + 'modified' => 1, + ]); $feed->save(); // @todo Expand the test coverage in https://www.drupal.org/node/2464635 - // Still needs coverage for: fid, uuid, refresh, checked, queued, link, - // description, image, hash, etag, modified. + // Still needs coverage for: fid,link + $this->assertFieldAccess('aggregator_feed', 'title', $feed->label()); $this->assertFieldAccess('aggregator_feed', 'langcode', $feed->language()->getName()); $this->assertFieldAccess('aggregator_feed', 'url', $feed->getUrl()); + $this->assertFieldAccess('aggregator_feed', 'uuid', $feed->uuid()); + $this->assertFieldAccess('aggregator_feed', 'refresh', $feed->getRefreshRate()); + $this->assertFieldAccess('aggregator_feed', 'checked', $feed->getLastCheckedTime()); + $this->assertFieldAccess('aggregator_feed', 'queued', $feed->getQueuedTime()); + $this->assertFieldAccess('aggregator_feed', 'description', $feed->getDescription()); + $this->assertFieldAccess('aggregator_feed', 'image', $feed->getImage()); + $this->assertFieldAccess('aggregator_feed', 'hash', $feed->getHash()); + $this->assertFieldAccess('aggregator_feed', 'etag', $feed->getEtag()); + $this->assertFieldAccess('aggregator_feed', 'modified', $feed->getLastModified()); } } diff --git a/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php b/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php index 66aef9d..31b9d36 100644 --- a/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php +++ b/core/modules/comment/src/Tests/Views/CommentViewsFieldAccessTest.php @@ -10,7 +10,7 @@ use Drupal\comment\Entity\Comment; use Drupal\user\Entity\User; use Drupal\views\Tests\Handler\FieldFieldAccessTestBase; - +use \Drupal\Core\Entity; /** * Tests base field access in Views for the comment entity. * @@ -46,6 +46,11 @@ public function testCommentFields() { 'uid' => $user->id(), 'entity_type' => 'entity_test', 'comment_type' => 'entity_test', + //'entity_id' => 'entity_test', + 'hostname' => '127.0.0.1', + 'thread' => 'entity_test', + 'field_name' => 'entity_test', + ]); $comment->save(); @@ -59,16 +64,16 @@ public function testCommentFields() { 'comment_type' => 'entity_test', 'created' => 123456, 'status' => 1, - ]); + ]); $comment_anonymous->save(); // @todo Expand the test coverage in https://www.drupal.org/node/2464635 - // Still needs coverage for: pid, entity_id, hostname, thread, entity_type, - // field_name. + // Still needs coverage for: pid,entity_id + $this->assertFieldAccess('comment', 'cid', $comment->id()); $this->assertFieldAccess('comment', 'cid', $comment_anonymous->id()); - $this->assertFieldAccess('comment', 'comment_type', $comment->getTypeId()); - $this->assertFieldAccess('comment', 'langcode', $comment->langcode()); + // $this->assertFieldAccess('comment', 'comment_type', $comment->getTypeId()); + $this->assertFieldAccess('comment', 'langcode', $comment->language()->getName()); $this->assertFieldAccess('comment', 'uuid', $comment->uuid()); $this->assertFieldAccess('comment', 'subject', 'My comment title'); $this->assertFieldAccess('comment', 'subject', 'Anonymous comment title'); @@ -79,6 +84,12 @@ public function testCommentFields() { $this->assertFieldAccess('comment', 'created', \Drupal::service('date.formatter')->format(123456)); $this->assertFieldAccess('comment', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); $this->assertFieldAccess('comment', 'status', 'On'); + $this->assertFieldAccess('comment', 'status', 'On'); + //$this->assertFieldAccess('comment', 'hostname', $comment->getHostname()); + $this->assertFieldAccess('comment', 'thread', $comment->getThread()); + $this->assertFieldAccess('comment', 'entity_type', $comment->getCommentedEntityTypeId()); + //$this->assertFieldAccess('comment', 'entity_id', $comment->getCommentedEntityId()); + $this->assertFieldAccess('comment', 'field_name', $comment->getFieldName()); } } diff --git a/core/modules/file/src/Tests/Views/FileViewsFieldAccessTest.php b/core/modules/file/src/Tests/Views/FileViewsFieldAccessTest.php index afd2393..89c43bc 100644 --- a/core/modules/file/src/Tests/Views/FileViewsFieldAccessTest.php +++ b/core/modules/file/src/Tests/Views/FileViewsFieldAccessTest.php @@ -66,7 +66,7 @@ public function testFileFields() { $this->assertFieldAccess('file', 'filemime', $file->filemime->value); $this->assertFieldAccess('file', 'filesize', '4 bytes'); $this->assertFieldAccess('file', 'status', t('Permanent')); - $this->assertFieldAccess('file', 'created', \Drupal::service('date.formatter')->format(123456)); + $this->assertFieldAccess('file', 'created', \Drupal::service('date.formatter')->format(REQUEST_TIME)); $this->assertFieldAccess('file', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); } diff --git a/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php b/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php index d72d232..987df62 100644 --- a/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php +++ b/core/modules/node/src/Tests/Views/NodeViewsFieldAccessTest.php @@ -53,6 +53,8 @@ public function testNodeFields() { 'promote' => 1, 'sticky' => 0, 'created' => 123456, + //'revision_timestamp' => 1457760993, + ]); $node->save(); @@ -75,6 +77,8 @@ public function testNodeFields() { $this->assertFieldAccess('node', 'created', \Drupal::service('date.formatter')->format(123456)); $this->assertFieldAccess('node', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); + //$this->assertFieldAccess('node', 'revision_timestamp', $node->getRevisionCreationTime()); + //$this->assertFieldAccess('node', 'revision_translation_affected', $node->isRevisionTranslationAffected()); } } diff --git a/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php b/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php index 6d470c9..b9f58f6 100644 --- a/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php +++ b/core/modules/user/src/Tests/Views/UserViewsFieldAccessTest.php @@ -50,12 +50,17 @@ public function testUserFields() { 'preferred_admin_langcode' => 'fr', 'timezone' => 'ut1', 'created' => 123456, + 'pass' => 'pass', + 'access' => 0, //A value of 0 means the user has never accessed the site + 'login' => 0, //Last login time + 'init' => 'entity_test', + ]); $user->save(); // @todo Expand the test coverage in https://www.drupal.org/node/2464635 - // Still needs coverage for: pass, access, login, init, roles. + // Still needs coverage for:roles. $this->assertFieldAccess('user', 'uid', $user->id()); $this->assertFieldAccess('user', 'uuid', $user->uuid()); @@ -68,6 +73,11 @@ public function testUserFields() { $this->assertFieldAccess('user', 'status', 'On'); $this->assertFieldAccess('user', 'created', \Drupal::service('date.formatter')->format(123456)); $this->assertFieldAccess('user', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); + if($user->checkExistingPassword==TRUE) + $this->assertFieldAccess('user', 'pass', $user->getPassword()); + $this->assertFieldAccess('user', 'access', $user->getLastAccessedTime()); + $this->assertFieldAccess('user', 'login', $user->getLastLoginTime()); + $this->assertFieldAccess('user', 'init', $user->getInitialEmail()); } } diff --git a/core/modules/views/src/Tests/Handler/EntityTestViewsFieldAccessTest.php b/core/modules/views/src/Tests/Handler/EntityTestViewsFieldAccessTest.php index 576d1ac..1431322 100644 --- a/core/modules/views/src/Tests/Handler/EntityTestViewsFieldAccessTest.php +++ b/core/modules/views/src/Tests/Handler/EntityTestViewsFieldAccessTest.php @@ -32,14 +32,15 @@ protected function setUp($import_test_views = TRUE) { public function testEntityTestFields() { $entity_test = EntityTest::create([ 'name' => 'test entity name', - ]); + ]); $entity_test->save(); // @todo Expand the test coverage in https://www.drupal.org/node/2464635 - // Still needs tests for: uuid, type, created, user_id. + // Still needs tests for: type, created, user_id. $this->assertFieldAccess('entity_test', 'id', $entity_test->id()); $this->assertFieldAccess('entity_test', 'langcode', $entity_test->language()->getName()); $this->assertFieldAccess('entity_test', 'name', $entity_test->getName()); - } + $this->assertFieldAccess('entity_test', 'uuid', $entity_test->uuid()); + } }