function AjaxTest::assertInsert

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertInsert()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertInsert()
  3. 11.x 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 213

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>');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.