Loading core/modules/block/tests/src/Functional/BlockTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -403,7 +403,7 @@ public function testBlockCacheTags() { ]; sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $expected_cache_tags = [ 'block_view', Loading @@ -411,7 +411,7 @@ public function testBlockCacheTags() { 'rendered', ]; sort($expected_cache_tags); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); // The "Powered by Drupal" block is modified; verify a cache miss. $block->setRegion('content'); Loading Loading @@ -453,7 +453,7 @@ public function testBlockCacheTags() { sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); $expected_cache_tags = [ 'block_view', 'config:block.block.powered-2', Loading @@ -462,7 +462,7 @@ public function testBlockCacheTags() { sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:' . implode(':', $keys)); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); // Now we should have a cache hit again. $this->drupalGet('<front>'); Loading core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -395,8 +395,8 @@ public function testBlockContextualLinks() { $this->getSession()->getDriver()->getClient()->request('POST', $url, $post); $this->assertSession()->statusCodeEquals(200); $json = Json::decode($this->getSession()->getPage()->getContent()); $this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>'); $this->assertIdentical($json[$cached_id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>'); $this->assertIdentical('<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>', $json[$id]); $this->assertIdentical('<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>', $json[$cached_id]); } } core/modules/block/tests/src/Kernel/BlockInterfaceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -44,12 +44,12 @@ public function testBlockInterface() { // Initial configuration of the block at construction time. /** @var $display_block \Drupal\Core\Block\BlockPluginInterface */ $display_block = $manager->createInstance('test_block_instantiation', $configuration); $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block was configured correctly.'); $this->assertIdentical($expected_configuration, $display_block->getConfiguration(), 'The block was configured correctly.'); // Updating an element of the configuration. $display_block->setConfigurationValue('display_message', 'My custom display message.'); $expected_configuration['display_message'] = 'My custom display message.'; $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.'); $this->assertIdentical($expected_configuration, $display_block->getConfiguration(), 'The block configuration was updated correctly.'); $definition = $display_block->getPluginDefinition(); $expected_form = [ Loading Loading @@ -93,11 +93,11 @@ public function testBlockInterface() { '#children' => 'My custom display message.', ]; // Ensure the build array is proper. $this->assertIdentical($display_block->build(), $expected_build, 'The plugin returned the appropriate build array.'); $this->assertIdentical($expected_build, $display_block->build(), 'The plugin returned the appropriate build array.'); // Ensure the machine name suggestion is correct. In truth, this is actually // testing BlockBase's implementation, not the interface itself. $this->assertIdentical($display_block->getMachineNameSuggestion(), 'displaymessage', 'The plugin returned the expected machine name suggestion.'); $this->assertIdentical('displaymessage', $display_block->getMachineNameSuggestion(), 'The plugin returned the expected machine name suggestion.'); } } core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ protected function createTests() { 'visibility' => [], ]; $this->assertIdentical($actual_properties, $expected_properties); $this->assertIdentical($expected_properties, $actual_properties); $this->assertInstanceOf(TestHtmlBlock::class, $entity->getPlugin()); } Loading core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php +3 −3 Original line number Diff line number Diff line Loading @@ -188,14 +188,14 @@ public function testBlockViewBuilderViewAlter() { // Establish baseline. $build = $this->getBlockRenderArray(); $this->setRawContent((string) $this->renderer->renderRoot($build)); $this->assertIdentical(trim((string) $this->cssSelect('div')[0]), 'Llamas > unicorns!'); $this->assertIdentical('Llamas > unicorns!', trim((string) $this->cssSelect('div')[0])); // Enable the block view alter hook that adds a foo=bar attribute. \Drupal::state()->set('block_test_view_alter_suffix', TRUE); Cache::invalidateTags($this->block->getCacheTagsToInvalidate()); $build = $this->getBlockRenderArray(); $this->setRawContent((string) $this->renderer->renderRoot($build)); $this->assertIdentical(trim((string) $this->cssSelect('[foo=bar]')[0]), 'Llamas > unicorns!'); $this->assertIdentical('Llamas > unicorns!', trim((string) $this->cssSelect('[foo=bar]')[0])); \Drupal::state()->set('block_test_view_alter_suffix', FALSE); \Drupal::state()->set('block_test.content', NULL); Loading @@ -206,7 +206,7 @@ public function testBlockViewBuilderViewAlter() { \Drupal::state()->set('block_test_view_alter_append_pre_render_prefix', TRUE); $build = $this->getBlockRenderArray(); $this->assertFalse(isset($build['#prefix']), 'The appended #pre_render callback has not yet run before rendering.'); $this->assertIdentical((string) $this->renderer->renderRoot($build), 'Hiya!<br>'); $this->assertIdentical('Hiya!<br>', (string) $this->renderer->renderRoot($build)); // Check that a cached block without content is altered. $this->assertArrayHasKey('#prefix', $build); $this->assertSame('Hiya!<br>', $build['#prefix']); Loading Loading
core/modules/block/tests/src/Functional/BlockTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -403,7 +403,7 @@ public function testBlockCacheTags() { ]; sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $expected_cache_tags = [ 'block_view', Loading @@ -411,7 +411,7 @@ public function testBlockCacheTags() { 'rendered', ]; sort($expected_cache_tags); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); // The "Powered by Drupal" block is modified; verify a cache miss. $block->setRegion('content'); Loading Loading @@ -453,7 +453,7 @@ public function testBlockCacheTags() { sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); $expected_cache_tags = [ 'block_view', 'config:block.block.powered-2', Loading @@ -462,7 +462,7 @@ public function testBlockCacheTags() { sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:' . implode(':', $keys)); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $this->assertIdentical($expected_cache_tags, $cache_entry->tags); // Now we should have a cache hit again. $this->drupalGet('<front>'); Loading
core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -395,8 +395,8 @@ public function testBlockContextualLinks() { $this->getSession()->getDriver()->getClient()->request('POST', $url, $post); $this->assertSession()->statusCodeEquals(200); $json = Json::decode($this->getSession()->getPage()->getContent()); $this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>'); $this->assertIdentical($json[$cached_id], '<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>'); $this->assertIdentical('<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>', $json[$id]); $this->assertIdentical('<ul class="contextual-links"><li class="block-configure"><a href="' . base_path() . 'admin/structure/block/manage/' . $cached_block->id() . '">Configure block</a></li><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_view_block/edit/block_1">Edit view</a></li></ul>', $json[$cached_id]); } }
core/modules/block/tests/src/Kernel/BlockInterfaceTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -44,12 +44,12 @@ public function testBlockInterface() { // Initial configuration of the block at construction time. /** @var $display_block \Drupal\Core\Block\BlockPluginInterface */ $display_block = $manager->createInstance('test_block_instantiation', $configuration); $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block was configured correctly.'); $this->assertIdentical($expected_configuration, $display_block->getConfiguration(), 'The block was configured correctly.'); // Updating an element of the configuration. $display_block->setConfigurationValue('display_message', 'My custom display message.'); $expected_configuration['display_message'] = 'My custom display message.'; $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.'); $this->assertIdentical($expected_configuration, $display_block->getConfiguration(), 'The block configuration was updated correctly.'); $definition = $display_block->getPluginDefinition(); $expected_form = [ Loading Loading @@ -93,11 +93,11 @@ public function testBlockInterface() { '#children' => 'My custom display message.', ]; // Ensure the build array is proper. $this->assertIdentical($display_block->build(), $expected_build, 'The plugin returned the appropriate build array.'); $this->assertIdentical($expected_build, $display_block->build(), 'The plugin returned the appropriate build array.'); // Ensure the machine name suggestion is correct. In truth, this is actually // testing BlockBase's implementation, not the interface itself. $this->assertIdentical($display_block->getMachineNameSuggestion(), 'displaymessage', 'The plugin returned the expected machine name suggestion.'); $this->assertIdentical('displaymessage', $display_block->getMachineNameSuggestion(), 'The plugin returned the expected machine name suggestion.'); } }
core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ protected function createTests() { 'visibility' => [], ]; $this->assertIdentical($actual_properties, $expected_properties); $this->assertIdentical($expected_properties, $actual_properties); $this->assertInstanceOf(TestHtmlBlock::class, $entity->getPlugin()); } Loading
core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php +3 −3 Original line number Diff line number Diff line Loading @@ -188,14 +188,14 @@ public function testBlockViewBuilderViewAlter() { // Establish baseline. $build = $this->getBlockRenderArray(); $this->setRawContent((string) $this->renderer->renderRoot($build)); $this->assertIdentical(trim((string) $this->cssSelect('div')[0]), 'Llamas > unicorns!'); $this->assertIdentical('Llamas > unicorns!', trim((string) $this->cssSelect('div')[0])); // Enable the block view alter hook that adds a foo=bar attribute. \Drupal::state()->set('block_test_view_alter_suffix', TRUE); Cache::invalidateTags($this->block->getCacheTagsToInvalidate()); $build = $this->getBlockRenderArray(); $this->setRawContent((string) $this->renderer->renderRoot($build)); $this->assertIdentical(trim((string) $this->cssSelect('[foo=bar]')[0]), 'Llamas > unicorns!'); $this->assertIdentical('Llamas > unicorns!', trim((string) $this->cssSelect('[foo=bar]')[0])); \Drupal::state()->set('block_test_view_alter_suffix', FALSE); \Drupal::state()->set('block_test.content', NULL); Loading @@ -206,7 +206,7 @@ public function testBlockViewBuilderViewAlter() { \Drupal::state()->set('block_test_view_alter_append_pre_render_prefix', TRUE); $build = $this->getBlockRenderArray(); $this->assertFalse(isset($build['#prefix']), 'The appended #pre_render callback has not yet run before rendering.'); $this->assertIdentical((string) $this->renderer->renderRoot($build), 'Hiya!<br>'); $this->assertIdentical('Hiya!<br>', (string) $this->renderer->renderRoot($build)); // Check that a cached block without content is altered. $this->assertArrayHasKey('#prefix', $build); $this->assertSame('Hiya!<br>', $build['#prefix']); Loading