public function AjaxFormCacheTest::testQueryString in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormCacheTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxFormCacheTest::testQueryString()
- 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormCacheTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxFormCacheTest::testQueryString()
Tests AJAX forms on pages with a query string.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ Ajax/ AjaxFormCacheTest.php, line 84
Class
- AjaxFormCacheTest
- Tests the usage of form caching for AJAX forms.
Namespace
Drupal\FunctionalJavascriptTests\AjaxCode
public function testQueryString() {
$this->container
->get('module_installer')
->install([
'block',
]);
$this
->drupalLogin($this->rootUser);
$this
->drupalPlaceBlock('ajax_forms_test_block');
$url = Url::fromRoute('entity.user.canonical', [
'user' => $this->rootUser
->id(),
], [
'query' => [
'foo' => 'bar',
],
]);
$this
->drupalGet($url);
$session = $this
->getSession();
// Select first option and trigger ajax update.
$session
->getPage()
->selectFieldOption('edit-test1', 'option1');
// DOM update: The InsertCommand in the AJAX response changes the text
// in the option element to 'Option1!!!'.
$opt1_selector = $this
->assertSession()
->waitForElement('css', "option:contains('Option 1!!!')");
$this
->assertNotEmpty($opt1_selector);
$url
->setOption('query', [
'foo' => 'bar',
]);
$this
->assertSession()
->addressEquals($url);
}