function WebDriverTestBase::tearDown
Same name in other branches
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::tearDown()
- 10 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::tearDown()
- 11.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::tearDown()
Overrides BrowserTestBase::tearDown
1 call to WebDriverTestBase::tearDown()
- MaximumFileSizeExceededUploadTest::tearDown in core/
modules/ file/ tests/ src/ FunctionalJavascript/ MaximumFileSizeExceededUploadTest.php
1 method overrides WebDriverTestBase::tearDown()
- MaximumFileSizeExceededUploadTest::tearDown in core/
modules/ file/ tests/ src/ FunctionalJavascript/ MaximumFileSizeExceededUploadTest.php
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 93
Class
- WebDriverTestBase
- Runs a browser test using a driver that supports JavaScript.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function tearDown() {
if ($this->mink) {
$status = $this->getStatus();
if ($status === BaseTestRunner::STATUS_ERROR || $status === BaseTestRunner::STATUS_WARNING || $status === BaseTestRunner::STATUS_FAILURE) {
// Ensure we capture the output at point of failure.
@$this->htmlOutput();
}
// 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');
}
$warnings = $this->getSession()
->evaluateScript("JSON.parse(sessionStorage.getItem('js_testing_log_test.warnings') || JSON.stringify([]))");
foreach ($warnings as $warning) {
if (strpos($warning, '[Deprecation]') === 0) {
@trigger_error('Javascript Deprecation:' . substr($warning, 13), E_USER_DEPRECATED);
}
}
if ($this->failOnJavascriptConsoleErrors) {
$errors = $this->getSession()
->evaluateScript("JSON.parse(sessionStorage.getItem('js_testing_log_test.errors') || JSON.stringify([]))");
if (!empty($errors)) {
$all_errors = implode("\n", $errors);
@trigger_error("Not failing JavaScript test for JavaScript errors is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. This test had the following JavaScript errors: {$all_errors}. See https://www.drupal.org/node/3221100", E_USER_DEPRECATED);
}
}
}
parent::tearDown();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.