class AjaxTest
Same name in this branch
- main core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest
- 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest
- 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest
- 11.x core/themes/olivero/tests/src/FunctionalJavascript/AjaxTest.php \Drupal\Tests\olivero\FunctionalJavascript\AjaxTest
Tests AJAX responses.
Attributes
#[Group('Ajax')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\ExtensionListTestTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\olivero\FunctionalJavascript\AjaxTest extends \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\ExtensionListTestTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of AjaxTest
File
-
core/
themes/ olivero/ tests/ src/ FunctionalJavascript/ AjaxTest.php, line 14
Namespace
Drupal\Tests\olivero\FunctionalJavascriptView source
class AjaxTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'ajax_test',
'ajax_forms_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'olivero';
/**
* Tests that Ajax errors are visible in the UI.
*/
public function testUiAjaxException() : void {
$this->drupalGet('ajax-test/exception-link');
$page = $this->getSession()
->getPage();
// We don't want the test to error out because of an expected Javascript
// console error.
$this->failOnJavascriptConsoleErrors = FALSE;
// Click on the AJAX link.
$this->clickLink('Ajax Exception');
$this->assertSession()
->statusMessageContainsAfterWait("Oops, something went wrong. Check your browser's developer console for more details.", 'error');
// Check that the message can be closed.
$this->click('.messages__close');
$this->assertTrue($page->find('css', '.messages--error')
->hasClass('hidden'));
// This is needed to avoid an unfinished AJAX request error from tearDown()
// because this test intentionally does not complete all AJAX requests.
$this->getSession()
->executeScript("delete window.drupalActiveXhrCount");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.