Merge branch 'MDL-39638_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-05-21 00:59:42 +02:00
commit 388b7d7d98
6 changed files with 41 additions and 9 deletions

View file

@ -14,7 +14,7 @@ Feature: Upload users
| Section 1 | math102 | S1 | | Section 1 | math102 | S1 |
| Section 3 | math102 | S3 | | Section 3 | math102 | S3 |
And I log in as "admin" And I log in as "admin"
And I expand "Front page settings" node And I collapse "Front page settings" node
And I expand "Site administration" node And I expand "Site administration" node
And I expand "Users" node And I expand "Users" node
And I expand "Accounts" node And I expand "Accounts" node

View file

@ -12,7 +12,7 @@ Feature: Add cohorts of users
| user3 | Third | User | third@user.com | | user3 | Third | User | third@user.com |
| user4 | Forth | User | forth@user.com | | user4 | Forth | User | forth@user.com |
And I log in as "admin" And I log in as "admin"
And I expand "Front page settings" node And I collapse "Front page settings" node
And I expand "Site administration" node And I expand "Site administration" node
And I expand "Users" node And I expand "Users" node
And I expand "Accounts" node And I expand "Accounts" node

View file

@ -65,7 +65,7 @@ class behat_cohort extends behat_base {
$steps = array_merge( $steps = array_merge(
array( array(
new Given('I am on homepage'), new Given('I am on homepage'),
new Given('I expand "Front page settings" node'), new Given('I collapse "Front page settings" node'),
new Given('I expand "Site administration" node'), new Given('I expand "Site administration" node'),
new Given('I expand "Users" node'), new Given('I expand "Users" node'),
new Given('I expand "Accounts" node'), new Given('I expand "Accounts" node'),

View file

@ -22,7 +22,7 @@ Feature: Upload users to a cohort
And I follow "Course 2" And I follow "Course 2"
And I add "Cohort sync" enrolment method with: And I add "Cohort sync" enrolment method with:
| Cohort | Cohort 2 | | Cohort | Cohort 2 |
And I expand "Course administration" node And I collapse "Course administration" node
And I expand "Site administration" node And I expand "Site administration" node
And I expand "Users" node And I expand "Users" node
And I expand "Accounts" node And I expand "Accounts" node

View file

@ -27,6 +27,9 @@
require_once(__DIR__ . '/../../behat/behat_base.php'); require_once(__DIR__ . '/../../behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given,
Behat\Mink\Exception\ExpectationException as ExpectationException;
/** /**
* Steps definitions to navigate through the navigation tree nodes. * Steps definitions to navigate through the navigation tree nodes.
* *
@ -41,7 +44,7 @@ class behat_navigation extends behat_base {
* Expands the selected node of the navigation tree that matches the text. * Expands the selected node of the navigation tree that matches the text.
* @Given /^I expand "(?P<nodetext_string>(?:[^"]|\\")*)" node$/ * @Given /^I expand "(?P<nodetext_string>(?:[^"]|\\")*)" node$/
* *
* @throws ElementNotFoundException Thrown by behat_base::find * @throws ExpectationException
* @param string $nodetext * @param string $nodetext
*/ */
public function i_expand_node($nodetext) { public function i_expand_node($nodetext) {
@ -54,18 +57,47 @@ class behat_navigation extends behat_base {
} }
$xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" . $xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" .
"/child::li" . "/child::li[contains(concat(' ', normalize-space(@class), ' '), ' collapsed ')]" .
"/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" . "/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" .
"/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]" . "/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]" .
"|" . "|" .
"//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" . "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" .
"/descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed'))]" . "/descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed'))]" .
"/descendant::li" . "/descendant::li[contains(concat(' ', normalize-space(@class), ' '), ' collapsed')]" .
"/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" . "/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" .
"/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]"; "/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]";
$node = $this->find('xpath', $xpath); $exception = new ExpectationException('The "' . $nodetext . '" node can not be expanded', $this->getSession());
$node = $this->find('xpath', $xpath, $exception);
$node->click(); $node->click();
} }
/**
* Collapses the selected node of the navigation tree that matches the text.
*
* @Given /^I collapse "(?P<nodetext_string>(?:[^"]|\\")*)" node$/
* @throws ExpectationException
* @param string $nodetext
*/
public function i_collapse_node($nodetext) {
// No collapsible nodes with non-JS browsers.
if (!$this->running_javascript()) {
return false;
}
$xpath = "//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" .
"/child::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed '))]" .
"/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" .
"/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]" .
"|" .
"//ul[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]" .
"/descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed'))]" .
"/child::p[contains(concat(' ', normalize-space(@class), ' '), ' branch')]" .
"/child::span[contains(concat(' ', normalize-space(.), ' '), '" . $nodetext . "')]";
$exception = new ExpectationException('The "' . $nodetext . '" node can not be collapsed', $this->getSession());
$node = $this->find('xpath', $xpath, $exception);
$node->click();
}
} }

View file

@ -52,7 +52,7 @@ class behat_permissions extends behat_base {
return array( return array(
new Given('I am on homepage'), new Given('I am on homepage'),
new Given('I expand "Front page settings" node'), new Given('I collapse "Front page settings" node'),
new Given('I expand "Site administration" node'), new Given('I expand "Site administration" node'),
new Given('I expand "Users" node'), new Given('I expand "Users" node'),
new Given('I expand "Permissions" node'), new Given('I expand "Permissions" node'),