function AjaxCallbacksTest::testDateTimeAjaxCallback

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

Tests if Ajax callback works on datetime element.

File

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

Class

AjaxCallbacksTest
Tests Ajax callbacks on FAPI elements.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

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

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