diff --git a/tests/behat/behat_app.php b/tests/behat/behat_app.php index b5abee45e..3d52a63c5 100644 --- a/tests/behat/behat_app.php +++ b/tests/behat/behat_app.php @@ -653,6 +653,31 @@ class behat_app extends behat_base { }); } + /** + * Check that the app opened a new browser tab. + * + * @Given /^the app should(?P not)? have opened a browser tab$/ + * @param string $not + */ + public function the_app_should_have_opened_a_browser_tab($not = '') { + $not = !empty($not); + + $this->spin(function() use ($not) { + $openedbrowsertab = count($this->getSession()->getWindowNames()) === 2; + + if ($not === $openedbrowsertab) { + throw new ExpectationException( + $not + ? 'Did not expect the app to have opened a browser tab' + : 'Expected the app to have opened a browser tab', + $this->getSession()->getDriver() + ); + } + + return true; + }); + } + /** * Switches to a newly-opened browser tab. *