From f5940bfb5f7c1f1027434cb04c26d2840ebe5ab8 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Mon, 28 Oct 2013 17:43:29 +0800 Subject: [PATCH] MDL-41030 behat: Dock blocks compatible with both selenium and phantomjs --- admin/tool/behat/tests/behat/basic_actions.feature | 4 ++-- blocks/tests/behat/behat_blocks.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/admin/tool/behat/tests/behat/basic_actions.feature b/admin/tool/behat/tests/behat/basic_actions.feature index 5b1bd502260..83f03207a50 100644 --- a/admin/tool/behat/tests/behat/basic_actions.feature +++ b/admin/tool/behat/tests/behat/basic_actions.feature @@ -39,7 +39,7 @@ Feature: Page contents assertions | Course 1 | C1 | 0 | And I log in as "admin" And I follow "Course 1" - When I click on "Move this to the dock" "button" in the "Administration" "block" + When I dock "Administration" block Then I should not see "Question bank" in the "region-pre" "region" And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element" @@ -49,5 +49,5 @@ Feature: Page contents assertions | fullname | shortname | category | | Course 1 | C1 | 0 | And I log in as "admin" - When I click on "Move this to the dock" "button" in the "Administration" "block" + When I dock "Administration" block Then I should not see "Turn editing on" in the "region-pre" "region" diff --git a/blocks/tests/behat/behat_blocks.php b/blocks/tests/behat/behat_blocks.php index 36d8be2468d..28d59caffb0 100644 --- a/blocks/tests/behat/behat_blocks.php +++ b/blocks/tests/behat/behat_blocks.php @@ -58,6 +58,20 @@ class behat_blocks extends behat_base { return $steps; } + /** + * Docks a block. Editing mode should be previously enabled. + * + * @Given /^I dock "(?P(?:[^"]|\\")*)" block$/ + * @param string $blockname + * @return Given + */ + public function i_dock_block($blockname) { + + // Looking for both title and alt. + $xpath = "//input[@type='image'][@title='" . get_string('dockblock', 'block', $blockname) . "' or @alt='" . get_string('addtodock', 'block') . "']"; + return new Given('I click on " ' . $xpath . '" "xpath_element" in the "' . $this->escape($blockname) . '" "block"'); + } + /** * Opens a block's actions menu if it is not already opened. *