From bbd802f7b7d8dad68bb9df916aa4f9fc3c256677 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Wed, 1 May 2013 15:58:55 +0800 Subject: [PATCH] MDL-38041 behat: Also fail tests if there is any other backtrace --- lib/tests/behat/behat_hooks.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index c8e60c50ad3..4fb968e5e93 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -224,6 +224,17 @@ class behat_hooks extends behat_base { $msg = "PHP debug message/s found:\n" . implode("\n", $msgs); throw new \Exception(html_entity_decode($msg)); } + + // Any other backtrace. + $backtracespattern = '/(line [0-9]* of [^:]*: call to [\->&;:a-zA-Z_\x7f-\xff][\->&;:a-zA-Z0-9_\x7f-\xff]*)/'; + if (preg_match_all($backtracespattern, $this->getSession()->getPage()->getContent(), $backtraces)) { + $msgs = array(); + foreach ($backtraces[0] as $backtrace) { + $msgs[] = $backtrace . '()'; + } + $msg = "Other backtraces found:\n" . implode("\n", $msgs); + throw new \Exception(htmlentities($msg)); + } } /**