Update to Drupal 8.1.5. For more information, see https://www.drupal.org/project/drupal/releases/8.1.5

This commit is contained in:
Pantheon Automation 2016-07-07 09:44:38 -07:00 committed by Greg Anderson
parent 13b6ca7cc2
commit 38ba7c357d
342 changed files with 7814 additions and 1534 deletions

View file

@ -0,0 +1,31 @@
<?php
namespace Drupal\FunctionalJavascriptTests;
use Drupal\Tests\WebAssert;
/**
* Defines a class with methods for asserting presence of elements during tests.
*/
class JSWebAssert extends WebAssert {
/**
* Waits for AJAX request to be completed.
*
* @param int $timeout
* (Optional) Timeout in milliseconds, defaults to 10000.
* @param string $message
* (optional) A message for exception.
*
* @throws \RuntimeException
* When the request is not completed. If left blank, a default message will
* be displayed.
*/
public function assertWaitOnAjaxRequest($timeout = 10000, $message = 'Unable to complete AJAX request.') {
$result = $this->session->wait($timeout, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
if (!$result) {
throw new \RuntimeException($message);
}
}
}

View file

@ -33,6 +33,24 @@ abstract class JavascriptTestBase extends BrowserTestBase {
return parent::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');
}
parent::tearDown();
}
/**
* Asserts that the element with the given CSS selector is visible.
*
@ -84,4 +102,11 @@ abstract class JavascriptTestBase extends BrowserTestBase {
$this->assertTrue($result, $message);
}
/**
* {@inheritdoc}
*/
public function assertSession($name = NULL) {
return new JSWebAssert($this->getSession($name), $this->baseUrl);
}
}