From 89cf999a8ddacb4d173a877340242c3dc0bbf3ec Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 11 Oct 2013 11:41:41 +0800 Subject: [PATCH] MDL-39489 behat: Updating to 2.6 moodlehq/behat-extension tag Also solving new problem after Behat 2.5 upgrade. --- composer.json | 2 +- lib/tests/behat/behat_hooks.php | 9 ++++++--- lib/tests/behat/behat_transformations.php | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 472d05e94b5..45ff5a85817 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,6 @@ "require-dev": { "phpunit/phpunit": "3.7.*", "phpunit/dbUnit": "1.2.*", - "moodlehq/behat-extension": "1.25.6" + "moodlehq/behat-extension": "1.26.*" } } diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 7d2d912d766..57891341d28 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -32,6 +32,7 @@ require_once(__DIR__ . '/../../behat/behat_base.php'); use Behat\Behat\Event\SuiteEvent as SuiteEvent, Behat\Behat\Event\ScenarioEvent as ScenarioEvent, Behat\Behat\Event\StepEvent as StepEvent, + Behat\Mink\Exception\DriverException as DriverException, WebDriver\Exception\NoSuchWindow as NoSuchWindow, WebDriver\Exception\UnexpectedAlertOpen as UnexpectedAlertOpen, WebDriver\Exception\UnknownError as UnknownError, @@ -143,14 +144,16 @@ class behat_hooks extends behat_base { throw new coding_exception('Behat only can modify the test database and the test dataroot!'); } + $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests'; + $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo; try { $session = $this->getSession(); } catch (CurlExec $e) { // Exception thrown by WebDriver, so only @javascript tests will be caugth; in // behat_util::is_server_running() we already checked that the server is running. - $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests'; - $msg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo; - throw new Exception($msg); + throw new Exception($driverexceptionmsg); + } catch (DriverException $e) { + throw new Exception($driverexceptionmsg); } catch (UnknownError $e) { // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions. $this->throw_unknown_exception($e); diff --git a/lib/tests/behat/behat_transformations.php b/lib/tests/behat/behat_transformations.php index a5591c8af33..738b8298d81 100644 --- a/lib/tests/behat/behat_transformations.php +++ b/lib/tests/behat/behat_transformations.php @@ -56,6 +56,9 @@ class behat_transformations extends behat_base { * @return string The string with the arguments fixed. */ public function arg_replace_slashes($string) { + if (!is_scalar($string)) { + return $string; + } return str_replace('\"', '"', $string); } @@ -67,6 +70,9 @@ class behat_transformations extends behat_base { * @return string */ public function arg_replace_nasty_strings($argument) { + if (!is_scalar($argument)) { + return $argument; + } return $this->replace_nasty_strings($argument); }