From f2805a1cc15ea378b90c07770f0dad4101c3f19f Mon Sep 17 00:00:00 2001 From: Chi Date: Fri, 23 Sep 2022 21:20:44 +0500 Subject: [PATCH] Fix tests --- tests/src/Functional/TwigTweakTest.php | 17 ++++++++--------- tests/src/Kernel/RegionViewBuilderTest.php | 14 +++++++------- ...> block.block.claro_powered_by_drupal.yml} | 10 +++++----- .../install/block.block.classy_content.yml | 19 ------------------- .../install/block.block.classy_page_title.yml | 17 ----------------- .../block.block.classy_status_messages.yml | 19 ------------------- .../templates/twig-tweak-test.html.twig | 2 +- 7 files changed, 21 insertions(+), 77 deletions(-) rename tests/twig_tweak_test/config/install/{block.block.classy_powered_by_drupal.yml => block.block.claro_powered_by_drupal.yml} (73%) delete mode 100644 tests/twig_tweak_test/config/install/block.block.classy_content.yml delete mode 100644 tests/twig_tweak_test/config/install/block.block.classy_page_title.yml delete mode 100644 tests/twig_tweak_test/config/install/block.block.classy_status_messages.yml diff --git a/tests/src/Functional/TwigTweakTest.php b/tests/src/Functional/TwigTweakTest.php index 122ae99..2f70966 100644 --- a/tests/src/Functional/TwigTweakTest.php +++ b/tests/src/Functional/TwigTweakTest.php @@ -26,7 +26,7 @@ final class TwigTweakTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected $defaultTheme = 'classy'; + protected $defaultTheme = 'claro'; /** * {@inheritdoc} @@ -134,21 +134,20 @@ final class TwigTweakTest extends BrowserTestBase { // -- Block. $xpath = '//div[@class = "tt-block"]'; - $xpath .= '/img[contains(@src, "/core/themes/classy/logo.svg") and @alt="Home"]'; + $xpath .= '/img[contains(@src, "/core/themes/claro/logo.svg") and @alt="Home"]'; $this->assertXpath($xpath); // -- Block with wrapper. $xpath = '//div[@class = "tt-block-with-wrapper"]'; $xpath .= '/div[@class = "block block-system block-system-branding-block"]'; $xpath .= '/h2[text() = "Branding"]'; - $xpath .= '/following-sibling::a[img[contains(@src, "/core/themes/classy/logo.svg") and @alt="Home"]]'; + $xpath .= '/following-sibling::a[img[contains(@src, "/core/themes/claro/logo.svg") and @alt="Home"]]'; $xpath .= '/following-sibling::div[@class = "site-name"]/a'; $this->assertXpath($xpath); // -- Region. - $xpath = '//div[@class = "tt-region"]/div[@class = "region region-sidebar-first"]'; - $xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Twig Tweak Test"]]'; - $xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]'; + $xpath = '//div[@class = "tt-region"]/div[@class = "region region-highlighted"]'; + $xpath .= '/div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]'; $this->assertXpath($xpath); // -- Entity (default view mode). @@ -191,13 +190,13 @@ final class TwigTweakTest extends BrowserTestBase { // -- Entity add form. $xpath = '//div[@class = "tt-entity-add-form"]/form'; $xpath .= '//input[@name = "title[0][value]" and @value = ""]'; - $xpath .= '/../../../div/input[@type = "submit" and @value = "Save"]'; + $xpath .= '/../../../../..//div/input[@type = "submit" and @value = "Save"]'; $this->assertXpath($xpath); // -- Entity edit form. $xpath = '//div[@class = "tt-entity-edit-form"]/form'; $xpath .= '//input[@name = "title[0][value]" and @value = "Alpha"]'; - $xpath .= '/../../../div/input[@type = "submit" and @value = "Save"]'; + $xpath .= '/../../../../..//div/input[@type = "submit" and @value = "Save"]'; $this->assertXpath($xpath); // -- Field. @@ -434,7 +433,7 @@ final class TwigTweakTest extends BrowserTestBase { } /** - * Checks that an element specified by a the xpath exists on the current page. + * Checks that an element specified by the xpath exists on the current page. */ private function assertXpath(string $xpath): void { $this->assertSession()->elementExists('xpath', $xpath); diff --git a/tests/src/Kernel/RegionViewBuilderTest.php b/tests/src/Kernel/RegionViewBuilderTest.php index fef7e5c..40a1eb8 100644 --- a/tests/src/Kernel/RegionViewBuilderTest.php +++ b/tests/src/Kernel/RegionViewBuilderTest.php @@ -33,12 +33,12 @@ final class RegionViewBuilderTest extends AbstractTestCase { public function setUp(): void { parent::setUp(); $this->installEntitySchema('block'); - $this->container->get('theme_installer')->install(['stable']); + $this->container->get('theme_installer')->install(['stark']); $values = [ 'id' => 'public_block', 'plugin' => 'system_powered_by_block', - 'theme' => 'stable', + 'theme' => 'stark', 'region' => 'sidebar_first', ]; Block::create($values)->save(); @@ -46,7 +46,7 @@ final class RegionViewBuilderTest extends AbstractTestCase { $values = [ 'id' => 'private_block', 'plugin' => 'system_powered_by_block', - 'theme' => 'stable', + 'theme' => 'stark', 'region' => 'sidebar_first', ]; Block::create($values)->save(); @@ -61,7 +61,7 @@ final class RegionViewBuilderTest extends AbstractTestCase { $renderer = $this->container->get('renderer'); $build = $view_builder->build('sidebar_first'); - // The build should be empty because 'stable' is not a default theme. + // The build should be empty because 'stark' is not a default theme. $expected_build = [ '#cache' => [ 'contexts' => [], @@ -72,7 +72,7 @@ final class RegionViewBuilderTest extends AbstractTestCase { self::assertSame($expected_build, $build); // Specify the theme name explicitly. - $build = $view_builder->build('sidebar_first', 'stable'); + $build = $view_builder->build('sidebar_first', 'stark'); $expected_build = [ // Only public_block should be rendered. // @see twig_tweak_test_block_access() @@ -129,11 +129,11 @@ final class RegionViewBuilderTest extends AbstractTestCase { $actual_html = $renderer->renderPlain($build); self::assertSame(self::normalizeHtml($expected_html), self::normalizeHtml($actual_html)); - // Set 'stable' as default site theme and check if the view builder without + // Set 'stark' as default site theme and check if the view builder without // 'theme' argument returns the same result. $this->container->get('config.factory') ->getEditable('system.theme') - ->set('default', 'stable') + ->set('default', 'stark') ->save(); $build = $view_builder->build('sidebar_first'); diff --git a/tests/twig_tweak_test/config/install/block.block.classy_powered_by_drupal.yml b/tests/twig_tweak_test/config/install/block.block.claro_powered_by_drupal.yml similarity index 73% rename from tests/twig_tweak_test/config/install/block.block.classy_powered_by_drupal.yml rename to tests/twig_tweak_test/config/install/block.block.claro_powered_by_drupal.yml index ad953f9..3f0ff7a 100644 --- a/tests/twig_tweak_test/config/install/block.block.classy_powered_by_drupal.yml +++ b/tests/twig_tweak_test/config/install/block.block.claro_powered_by_drupal.yml @@ -4,11 +4,11 @@ dependencies: module: - system theme: - - classy -id: classy_powered_by_drupal -theme: classy -region: sidebar_first -weight: 20 + - claro +id: claro_powered_by_drupal +theme: claro +region: highlighted +weight: 0 provider: null plugin: system_powered_by_block settings: diff --git a/tests/twig_tweak_test/config/install/block.block.classy_content.yml b/tests/twig_tweak_test/config/install/block.block.classy_content.yml deleted file mode 100644 index 38293c0..0000000 --- a/tests/twig_tweak_test/config/install/block.block.classy_content.yml +++ /dev/null @@ -1,19 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - system - theme: - - classy -id: classy_content -theme: classy -region: content -weight: 0 -provider: null -plugin: system_main_block -settings: - id: system_main_block - label: 'Main page content' - provider: system - label_display: '0' -visibility: { } diff --git a/tests/twig_tweak_test/config/install/block.block.classy_page_title.yml b/tests/twig_tweak_test/config/install/block.block.classy_page_title.yml deleted file mode 100644 index 3dd4f0c..0000000 --- a/tests/twig_tweak_test/config/install/block.block.classy_page_title.yml +++ /dev/null @@ -1,17 +0,0 @@ -langcode: en -status: true -dependencies: - theme: - - classy -id: classy_page_title -theme: classy -region: sidebar_first -weight: 0 -provider: null -plugin: page_title_block -settings: - id: page_title_block - label: 'Page title' - provider: core - label_display: '0' -visibility: { } diff --git a/tests/twig_tweak_test/config/install/block.block.classy_status_messages.yml b/tests/twig_tweak_test/config/install/block.block.classy_status_messages.yml deleted file mode 100644 index 19bd131..0000000 --- a/tests/twig_tweak_test/config/install/block.block.classy_status_messages.yml +++ /dev/null @@ -1,19 +0,0 @@ -langcode: en -status: true -dependencies: - module: - - system - theme: - - classy -id: classy_status_messages -theme: classy -region: sidebar_first -weight: 10 -provider: null -plugin: system_messages_block -settings: - id: system_messages_block - label: 'Status messages' - provider: system - label_display: '0' -visibility: { } diff --git a/tests/twig_tweak_test/templates/twig-tweak-test.html.twig b/tests/twig_tweak_test/templates/twig-tweak-test.html.twig index e6dd6c3..28b978e 100644 --- a/tests/twig_tweak_test/templates/twig-tweak-test.html.twig +++ b/tests/twig_tweak_test/templates/twig-tweak-test.html.twig @@ -30,7 +30,7 @@
{{ drupal_view_result('twig_tweak_test', 'page_1')|length }}
{{ drupal_block('system_branding_block', {use_site_name: false}, false) }}
{{ drupal_block('system_branding_block', {label: 'Branding'}) }}
-
{{ drupal_region('sidebar_first') }}
+
{{ drupal_region('highlighted') }}
{{ drupal_entity('node', 1) }}
{{ drupal_entity('node', 1, 'teaser') }}
{{ drupal_entity('node', 'ad1b902a-344f-41d1-8c61-a69f0366dbfa') }}