Merge branch '44711-28-r2' of git://github.com/samhemelryk/moodle

This commit is contained in:
Dan Poltawski 2014-05-20 20:32:14 +08:00
commit be38640dfa
2 changed files with 9 additions and 6 deletions

View File

@ -89,8 +89,7 @@ Feature: View my courses in navigation block
And I expand "cat1" node
And I should see "c1" in the "Navigation" "block"
And I expand "c1" node
Then I should not see "
And I should see "cat1" in the "Navigation" "block"
Then I should see "cat1" in the "Navigation" "block"
And I should see "cat2" in the "Navigation" "block"
And I should see "cat3" in the "Navigation" "block"
And I should see "cat31" in the "Navigation" "block"
@ -99,4 +98,4 @@ Feature: View my courses in navigation block
And I should see "c1" in the "Navigation" "block"
And I should not see "c2" in the "Navigation" "block"
And I should see "c31" in the "Navigation" "block"
And I should not see "c32" in the "Navigation" "block"
And I should not see "c32" in the "Navigation" "block"

View File

@ -64,7 +64,7 @@ class behat_navigation extends behat_base {
$hasblocktree = "[contains(concat(' ', normalize-space(@class), ' '), ' block_tree ')]";
$hasbranch = "[contains(concat(' ', normalize-space(@class), ' '), ' branch ')]";
$hascollapsed = "li[contains(concat(' ', normalize-space(@class), ' '), ' collapsed ') or @data-exandable='1']";
$notcollapsed = "[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed '))]";
$notcollapsed = "li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed '))]";
$match = "[normalize-space(.)={$nodetextliteral}]";
// Avoid problems with quotes.
@ -77,8 +77,12 @@ class behat_navigation extends behat_base {
$iscollapsed = 'li';
}
$xpath = "//ul{$hasblocktree}//li{$notcollapsed}/ul/{$iscollapsed}/p{$isbranch}/a{$match}|";
$xpath .= "//ul{$hasblocktree}//li{$notcollapsed}/ul/{$iscollapsed}/p{$isbranch}/span{$match}";
// First check root nodes.
$xpath = "//ul{$hasblocktree}/$hascollapsed/p{$isbranch}/span{$match}|";
// Next search for the node containing the text within a link.
$xpath .= "//ul{$hasblocktree}//{$notcollapsed}/ul/{$iscollapsed}/p{$isbranch}/a{$match}|";
// Finally search for the node containing the text within a span.
$xpath .= "//ul{$hasblocktree}//{$notcollapsed}/ul/{$iscollapsed}/p{$isbranch}/span{$match}";
$node = $this->find('xpath', $xpath, $exception);
$this->ensure_node_is_visible($node);