diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php index 5e38c1d888e8fc4d925ec28162a6eb197a387d33..106dae43e11547a47a186824cd3d03356af5f34c 100644 --- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php +++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php @@ -40,14 +40,25 @@ protected function setUp() { /** * Tests opening off-canvas dialog by click blocks and elements in the blocks. - * - * @dataProvider providerTestBlocks */ - public function testBlocks($theme, $block_plugin, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item, $permissions) { + public function testBlocks() { + foreach ($this->getBlockTests() as $test) { + call_user_func_array([$this, 'doTestBlocks'], $test); + } + } + + /** + * Tests opening off-canvas dialog by click blocks and elements in the blocks. + */ + protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_selector, $label_selector, $button_text, $toolbar_item, $permissions) { if ($permissions) { $this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), $permissions); } - + if ($new_page_text) { + // Some asserts can be based on this value, so it should not be the same + // for different blocks, because it can be saved in the site config. + $new_page_text = $new_page_text . ' ' . $theme . ' ' . $block_plugin; + } $web_assert = $this->assertSession(); $page = $this->getSession()->getPage(); $this->enableTheme($theme); @@ -131,12 +142,18 @@ public function testBlocks($theme, $block_plugin, $new_page_text, $element_selec $web_assert->elementTextContains('css', '#drupal-live-announce', 'Exited edit mode.'); $web_assert->elementTextNotContains('css', '.contextual-toolbar-tab button', 'Editing'); $web_assert->elementAttributeNotContains('css', '.dialog-off-canvas-main-canvas', 'class', 'js-settings-tray-edit-mode'); + + // Clean up test data so each test does not impact the next. + $block->delete(); + if ($permissions) { + user_role_revoke_permissions(Role::AUTHENTICATED_ID, $permissions); + } } /** - * Dataprovider for testBlocks(). + * Creates tests for ::testBlocks(). */ - public function providerTestBlocks() { + public function getBlockTests() { $blocks = []; foreach ($this->getTestThemes() as $theme) { $blocks += [