From aa5da27065dd553026f7b4b0effb618b5a164509 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 30 Nov 2016 14:15:30 +0000 Subject: [PATCH] Issue #2817115 by tstoeckler, dawehner, cilefen: JavascriptTestBase::tearDown() fails if $this->mink is not set --- .../JavascriptTestBase.php | 22 ++++++++++--------- core/tests/Drupal/Tests/BrowserTestBase.php | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index 6a8f1f58bf31..eecafb08aced 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -47,16 +47,18 @@ protected function initMink() { * {@inheritdoc} */ protected function tearDown() { - // Wait for all requests to finish. It is possible that an AJAX request is - // still on-going. - $result = $this->getSession()->wait(5000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))'); - if (!$result) { - // If the wait is unsuccessful, there may still be an AJAX request in - // progress. If we tear down now, then this AJAX request may fail with - // missing database tables, because tear down will have removed them. Rather - // than allow it to fail, throw an explicit exception now explaining what - // the problem is. - throw new \RuntimeException('Unfinished AJAX requests whilst tearing down a test'); + if ($this->mink) { + // Wait for all requests to finish. It is possible that an AJAX request is + // still on-going. + $result = $this->getSession()->wait(5000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))'); + if (!$result) { + // If the wait is unsuccessful, there may still be an AJAX request in + // progress. If we tear down now, then this AJAX request may fail with + // missing database tables, because tear down will have removed them. + // Rather than allow it to fail, throw an explicit exception now + // explaining what the problem is. + throw new \RuntimeException('Unfinished AJAX requests while tearing down a test'); + } } parent::tearDown(); } diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index d4b31d79be21..1ab59b6cf5f3 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -263,7 +263,9 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase { /** * Mink session manager. * - * @var \Behat\Mink\Mink + * This will not be initialized if there was an error during the test setup. + * + * @var \Behat\Mink\Mink|null */ protected $mink; -- GitLab