From e2c512768984ecb202209727a540dc7389029276 Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Tue, 30 May 2017 15:43:00 +0200 Subject: [PATCH] interdiff --- .../CommentDefaultFormatterCacheTagsTest.php | 42 +++++++++++++--------- .../src/Kernel/Views/UserViewsFieldAccessTest.php | 1 - core/profiles/standard/standard.install | 1 - 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php index 3dc02e8..bed4521 100644 --- a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php @@ -34,8 +34,10 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase { protected function setUp() { parent::setUp(); - $session = new Session(); + $this->container->get('module_handler')->loadInclude('comment', 'install'); + comment_install(); + $session = new Session(); $request = Request::create('/'); $request->setSession($session); @@ -48,7 +50,7 @@ protected function setUp() { // user does not have access to the 'administer comments' permission, to // ensure only published comments are visible to the end user. $current_user = $this->container->get('current_user'); - $current_user->setAccount($this->createUser([], ['access comments'])); + $current_user->setAccount($this->createUser([], ['access comments', 'post comments'])); // Install tables and config needed to render comments. $this->installSchema('comment', ['comment_entity_statistics']); @@ -66,6 +68,14 @@ protected function setUp() { * Tests the bubbling of cache tags. */ public function testCacheTags() { + $entity_type_manager = $this->container->get('entity_type.manager'); + + /** @var \Drupal\Core\Entity\EntityViewBuilderInterface $view_builder */ + $view_builder = $entity_type_manager->getViewBuilder('entity_test'); + + /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */ + $storage = $entity_type_manager->getStorage('entity_test'); + /** @var \Drupal\Core\Render\RendererInterface $renderer */ $renderer = $this->container->get('renderer'); @@ -74,11 +84,14 @@ public function testCacheTags() { $commented_entity->save(); // Verify cache tags on the rendered entity before it has comments. - $build = \Drupal::entityManager() - ->getViewBuilder('entity_test') - ->view($commented_entity); + $build = $view_builder->view($commented_entity); $renderer->renderRoot($build); $expected_cache_tags = [ + 'config:core.entity_form_display.comment.comment.default', + 'config:field.field.comment.comment.comment_body', + 'config:field.field.entity_test.entity_test.comment', + 'config:field.storage.comment.comment_body', + 'config:user.settings', 'entity_test_view', 'entity_test:' . $commented_entity->id(), ]; @@ -104,17 +117,11 @@ public function testCacheTags() { ]); $comment->save(); - // Load commented entity so comment_count gets computed. - // @todo Remove the $reset = TRUE parameter after - // https://www.drupal.org/node/597236 lands. It's a temporary work-around. - $storage = $this->container->get('entity_type.manager')->getStorage('entity_test'); - $storage->resetCache([$commented_entity->id()]); + // Load commented entity again so we get the updated comment_count. $commented_entity = $storage->load($commented_entity->id()); // Verify cache tags on the rendered entity when it has comments. - $build = \Drupal::entityManager() - ->getViewBuilder('entity_test') - ->view($commented_entity); + $build = $view_builder->view($commented_entity); $renderer->renderRoot($build); $expected_cache_tags = [ 'entity_test_view', @@ -124,6 +131,11 @@ public function testCacheTags() { 'config:filter.format.plain_text', 'user_view', 'user:2', + 'config:core.entity_form_display.comment.comment.default', + 'config:field.field.comment.comment.comment_body', + 'config:field.field.entity_test.entity_test.comment', + 'config:field.storage.comment.comment_body', + 'config:user.settings', ]; sort($expected_cache_tags); $this->assertEqual($build['#cache']['tags'], $expected_cache_tags); @@ -132,9 +144,7 @@ public function testCacheTags() { // builder elements bubble up outside of the entity and we can check that // it got the correct cache max age. $build = ['#type' => 'container']; - $build['entity'] = \Drupal::entityManager() - ->getViewBuilder('entity_test') - ->view($commented_entity); + $build['entity'] = $view_builder->view($commented_entity); $renderer->renderRoot($build); // The entity itself was cached but the top-level element is max-age 0 due diff --git a/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php b/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php index a443ae9..c17c3dc 100644 --- a/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php +++ b/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\user\Kernel\Views; -use Drupal\language\Entity\ConfigurableLanguage; use Drupal\user\Entity\User; use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase; diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index a4f298b..f0be314 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -5,7 +5,6 @@ * Install, update and uninstall functions for the standard installation profile. */ -use Drupal\user\Entity\User; use Drupal\user\RoleInterface; use Drupal\shortcut\Entity\Shortcut; -- 2.8.1