function AjaxFormCacheTest::testQueryString
Same name in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormCacheTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxFormCacheTest::testQueryString()
- 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormCacheTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxFormCacheTest::testQueryString()
- 11.x 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 87
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',
FormBuilderInterface::AJAX_FORM_REQUEST => 1,
MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax',
]);
$this->assertUrl($url);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.