From 137c0261ee7b55ae8382c15951409fdf55eda68d Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Tue, 20 May 2014 22:07:29 +1200 Subject: [PATCH] MDL-44711 block_navigation: fixed typo in behat tests --- blocks/navigation/tests/behat/view_my_courses.feature | 5 ++--- lib/tests/behat/behat_navigation.php | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/blocks/navigation/tests/behat/view_my_courses.feature b/blocks/navigation/tests/behat/view_my_courses.feature index ce073ccb406..4c8ad1b027f 100644 --- a/blocks/navigation/tests/behat/view_my_courses.feature +++ b/blocks/navigation/tests/behat/view_my_courses.feature @@ -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" \ No newline at end of file + And I should not see "c32" in the "Navigation" "block" diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index 887743d2f82..30e86b9d90a 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -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);