From 0944b1641ae1c76ce966ea717010e9e64c71cced Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Thu, 4 Aug 2016 08:21:28 +0800 Subject: [PATCH] MDL-54656 behat: Skip test if db family is not mysql or postgres --- lib/tests/behat/behat_general.php | 23 +++++++++++++++++++ mod/forum/tests/behat/advanced_search.feature | 5 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index 6fe44f64c65..4b68b1d5215 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -1539,4 +1539,27 @@ class behat_general extends behat_base { $node->keyPress($char, $modifier); $node->keyUp($char, $modifier); } + + /** + * Checks if database family used is using one of the specified, else skip. (mysql, postgres, mssql, oracle, etc.) + * + * @Given /^database family used is one of the following:$/ + * @param TableNode $databasefamilies list of database. + * @return void. + * @throws \Moodle\BehatExtension\Exception\SkippedException + */ + public function database_family_used_is_one_of_the_following(TableNode $databasefamilies) { + global $DB; + + $dbfamily = $DB->get_dbfamily(); + + // Check if used db family is one of the specified ones. If yes then return. + foreach ($databasefamilies->getRows() as $dbfamilytocheck) { + if ($dbfamilytocheck[0] == $dbfamily) { + return; + } + } + + throw new \Moodle\BehatExtension\Exception\SkippedException(); + } } diff --git a/mod/forum/tests/behat/advanced_search.feature b/mod/forum/tests/behat/advanced_search.feature index 81e62dc7e5d..6aa043b69c8 100644 --- a/mod/forum/tests/behat/advanced_search.feature +++ b/mod/forum/tests/behat/advanced_search.feature @@ -56,7 +56,10 @@ Feature: The forum search allows users to perform advanced searches for forum po And I should not see "My subjective" Scenario: Perform an advanced search using whole words - Given I log in as "student1" + Given database family used is one of the following: + | mysql | + | postgres | + And I log in as "student1" And I follow "Course 1" And I follow "News forum" And I press "Search forums"