You are here

public function AjaxTest::assertInsert in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertInsert()
  2. 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertInsert()

Assert insert.

@internal

Parameters

string $render_type: Render type.

string $expected: Expected result.

string $script: Script for additional theming.

1 call to AjaxTest::assertInsert()
AjaxTest::testInsertAjaxResponse in core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
Tests that various AJAX responses with DOM elements are correctly inserted.

File

core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php, line 168

Class

AjaxTest
Tests AJAX responses.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

public function assertInsert(string $render_type, string $expected, string $script = '') : void {

  // Check insert to block element.
  $this
    ->drupalGet('ajax-test/insert-block-wrapper');
  $this
    ->getSession()
    ->executeScript($script);
  $this
    ->clickLink("Link html {$render_type}");
  $this
    ->assertWaitPageContains('<div class="ajax-target-wrapper"><div id="ajax-target">' . $expected . '</div></div>');
  $this
    ->drupalGet('ajax-test/insert-block-wrapper');
  $this
    ->getSession()
    ->executeScript($script);
  $this
    ->clickLink("Link replaceWith {$render_type}");
  $this
    ->assertWaitPageContains('<div class="ajax-target-wrapper">' . $expected . '</div>');

  // Check insert to inline element.
  $this
    ->drupalGet('ajax-test/insert-inline-wrapper');
  $this
    ->getSession()
    ->executeScript($script);
  $this
    ->clickLink("Link html {$render_type}");
  $this
    ->assertWaitPageContains('<div class="ajax-target-wrapper"><span id="ajax-target-inline">' . $expected . '</span></div>');
  $this
    ->drupalGet('ajax-test/insert-inline-wrapper');
  $this
    ->getSession()
    ->executeScript($script);
  $this
    ->clickLink("Link replaceWith {$render_type}");
  $this
    ->assertWaitPageContains('<div class="ajax-target-wrapper">' . $expected . '</div>');
}