BackwardCompatibilityTest.php 991 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Drupal\FunctionalJavascriptTests\Ajax;
  3. use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
  4. /**
  5. * Tests the compatibility of the ajax.es6.js file.
  6. *
  7. * @group Ajax
  8. */
  9. class BackwardCompatibilityTest extends WebDriverTestBase {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public static $modules = [
  14. 'js_ajax_test',
  15. ];
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected $defaultTheme = 'stark';
  20. /**
  21. * Ensures Drupal.Ajax.element_settings BC layer.
  22. */
  23. public function testAjaxBackwardCompatibility() {
  24. $this->drupalGet('/js_ajax_test');
  25. $this->click('#edit-test-button');
  26. $this->assertSession()
  27. ->waitForElement('css', '#js_ajax_test_form_element');
  28. $elements = $this->cssSelect('#js_ajax_test_form_element');
  29. $this->assertCount(1, $elements);
  30. $json = $elements[0]->getText();
  31. $data = json_decode($json, TRUE);
  32. $this->assertEquals([
  33. 'element_settings' => 'catbro',
  34. 'elementSettings' => 'catbro',
  35. ], $data);
  36. }
  37. }