You are here

public function AjaxFormCacheTest::testQueryString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Ajax/AjaxFormCacheTest.php \Drupal\system\Tests\Ajax\AjaxFormCacheTest::testQueryString()

Tests AJAX forms on pages with a query string.

File

core/modules/system/src/Tests/Ajax/AjaxFormCacheTest.php, line 65
Contains \Drupal\system\Tests\Ajax\AjaxFormCacheTest.

Class

AjaxFormCacheTest
Tests the usage of form caching for AJAX forms.

Namespace

Drupal\system\Tests\Ajax

Code

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);
  $this
    ->drupalPostAjaxForm(NULL, [
    'test1' => 'option1',
  ], 'test1');
  $url
    ->setOption('query', [
    'foo' => 'bar',
    FormBuilderInterface::AJAX_FORM_REQUEST => 1,
    MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax',
  ]);
  $this
    ->assertUrl($url);
}