From 43391de3e26d346fd0417adb472d38ec0409d1eb Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 5 May 2017 12:02:24 +0100 Subject: [PATCH] MDL-58826 theme_boost: Prevent fatal errors in action menu behat steps --- .../tests/behat/behat_theme_boost_behat_course.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/theme/boost/tests/behat/behat_theme_boost_behat_course.php b/theme/boost/tests/behat/behat_theme_boost_behat_course.php index 64a7c597549..6906b669ea4 100644 --- a/theme/boost/tests/behat/behat_theme_boost_behat_course.php +++ b/theme/boost/tests/behat/behat_theme_boost_behat_course.php @@ -49,6 +49,10 @@ class behat_theme_boost_behat_course extends behat_course { // Find the menu. $menunode = $activitynode->find('css', 'a[data-toggle=dropdown]'); + if (!$menunode) { + throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname), + $this->getSession()); + } $expanded = $menunode->getAttribute('aria-expanded'); if ($expanded == 'true') { return; @@ -71,6 +75,10 @@ class behat_theme_boost_behat_course extends behat_course { $activitynode = $this->get_activity_node($activityname); // Find the menu. $menunode = $activitynode->find('css', 'a[data-toggle=dropdown]'); + if (!$menunode) { + throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname), + $this->getSession()); + } $expanded = $menunode->getAttribute('aria-expanded'); if ($expanded != 'true') { return; @@ -90,6 +98,10 @@ class behat_theme_boost_behat_course extends behat_course { $activitynode = $this->get_activity_node($activityname); // Find the menu. $menunode = $activitynode->find('css', 'a[data-toggle=dropdown]'); + if (!$menunode) { + throw new ExpectationException(sprintf('Could not find actions menu for the activity "%s"', $activityname), + $this->getSession()); + } $expanded = $menunode->getAttribute('aria-expanded'); if ($expanded != 'true') { throw new ExpectationException(sprintf("The action menu for '%s' is not open", $activityname), $this->getSession());