function AjaxCallbacksTest::testDateAjaxCallback

Same name in other branches
  1. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxCallbacksTest::testDateAjaxCallback()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxCallbacksTest::testDateAjaxCallback()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxCallbacksTest::testDateAjaxCallback()

Tests if Ajax callback works on date element.

File

core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php, line 27

Class

AjaxCallbacksTest
Tests Ajax callbacks on FAPI elements.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

public function testDateAjaxCallback() {
    // Test Ajax callback when date changes.
    $this->drupalGet('ajax_forms_test_ajax_element_form');
    $this->assertNotEmpty($this->getSession()
        ->getPage()
        ->find('xpath', '//div[@id="ajax_date_value"][text()="No date yet selected"]'));
    $this->getSession()
        ->executeScript('jQuery("[data-drupal-selector=edit-date]").val("2016-01-01").trigger("change");');
    $this->assertNotEmpty($this->assertSession()
        ->waitForElement('xpath', '//div[@id="ajax_date_value"]/div[text()="2016-01-01"]'));
}

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