Skip to content

Commit

Permalink
MDL-44711 block_navigation: fixed typo in behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed May 20, 2014
1 parent d4a84d8 commit 5d946b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions blocks/navigation/tests/behat/view_my_courses.feature
Expand Up @@ -92,8 +92,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"
Expand Down
11 changes: 7 additions & 4 deletions lib/tests/behat/behat_navigation.php
Expand Up @@ -64,7 +64,7 @@ protected function get_node_text_node($text, $branch = false, $collapsed = null,
$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.
Expand All @@ -77,11 +77,14 @@ protected function get_node_text_node($text, $branch = false, $collapsed = null,
$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);
return $node;
}

Expand Down

0 comments on commit 5d946b7

Please sign in to comment.