function BackwardCompatibilityTest::testAjaxBackwardCompatibility

Same name in other branches
  1. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php \Drupal\FunctionalJavascriptTests\Ajax\BackwardCompatibilityTest::testAjaxBackwardCompatibility()

Ensures Drupal.Ajax.element_settings BC layer.

File

core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php, line 29

Class

BackwardCompatibilityTest
Tests the compatibility of the ajax.es6.js file.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

public function testAjaxBackwardCompatibility() {
    $this->drupalGet('/js_ajax_test');
    $this->click('#edit-test-button');
    $this->assertSession()
        ->waitForElement('css', '#js_ajax_test_form_element');
    $elements = $this->cssSelect('#js_ajax_test_form_element');
    $this->assertCount(1, $elements);
    $json = $elements[0]->getText();
    $data = json_decode($json, TRUE);
    $this->assertEquals([
        'element_settings' => 'catbro',
        'elementSettings' => 'catbro',
    ], $data);
}

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