From 1a1d5bdeadb3675164edd53054c2c4a1b64d83dc Mon Sep 17 00:00:00 2001 From: madmatt Date: Tue, 15 Apr 2014 23:56:03 +1200 Subject: [PATCH] FIX: Invalid Exception throw results in CI failures --- .../BehatExtension/Context/BasicContext.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index fbe8d26..aee797c 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -605,13 +605,25 @@ JS; if(trim($negate)) { if (preg_match($regex, $actual)) { - $message = sprintf('The text "%s" was found in the text of the "%s" region.', $text, $region); - throw new \Exception($message, $this->getSession()); + $message = sprintf( + 'The text "%s" was found in the text of the "%s" region on the page %s.', + $text, + $region, + $this->getSession()->getCurrentUrl() + ); + + throw new \Exception($message); } } else { if (!preg_match($regex, $actual)) { - $message = sprintf('The text "%s" was not found anywhere in the text of the "%s" region.', $text, $region); - throw new \Exception($message, $this->getSession()); + $message = sprintf( + 'The text "%s" was not found anywhere in the text of the "%s" region on the page %s.', + $text, + $region, + $this->getSession()->getCurrentUrl() + ); + + throw new \Exception($message); } }