From fe856690cbc219cf1287ebacf8be41d92be06edf Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 25 Jan 2013 15:48:35 +0800 Subject: [PATCH] MDL-37662 behat: Add blocks definition --- blocks/tests/behat/add_blocks.feature | 24 +++++++++++++ blocks/tests/behat/behat_blocks.php | 52 +++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 blocks/tests/behat/add_blocks.feature create mode 100644 blocks/tests/behat/behat_blocks.php diff --git a/blocks/tests/behat/add_blocks.feature b/blocks/tests/behat/add_blocks.feature new file mode 100644 index 00000000000..7ee5644c176 --- /dev/null +++ b/blocks/tests/behat/add_blocks.feature @@ -0,0 +1,24 @@ +@blocks +Feature: Add blocks + In order to add more functionality to pages + As a teacher + I need to add blocks to pages + + @javascript + Scenario: Add a block to a course + Given the following "users" exists: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@asd.com | + | student2 | Student | 2 | student2@asd.com | + And the following "courses" exists: + | fullname | shortname | format | + | Course 1 | C1 | topics | + And the following "course enrolments" exists: + | user | course | role | + | student1 | C1 | student | + | student2 | C1 | student | + And I log in as "admin" + And I follow "Course 1" + And I turn editing mode on + When I add the "Blog menu" block + Then I should see "View all of my entries" diff --git a/blocks/tests/behat/behat_blocks.php b/blocks/tests/behat/behat_blocks.php new file mode 100644 index 00000000000..c90f1df87b3 --- /dev/null +++ b/blocks/tests/behat/behat_blocks.php @@ -0,0 +1,52 @@ +. + +/** + * Steps definitions related with blocks. + * + * @package core + * @category test + * @copyright 2012 David Monllaó + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. + +require_once(__DIR__ . '/../../../lib/behat/behat_base.php'); + +use Behat\Behat\Context\Step\Given as Given; + +/** + * Blocks management steps definitions. + * + * @package core + * @category test + * @copyright 2012 David Monllaó + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class behat_blocks extends behat_base { + + /** + * Adds the selected block. Editing mode must be previously enabled. + * + * @Given /^I add the "(?P(?:[^"]|\\")*)" block$/ + * @param string $blockname + */ + public function i_add_the_block($blockname) { + return new Given('I select "' . $blockname . '" from "bui_addblock"'); + } + +}