AjaxCallbacksTest.php 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
<?php

namespace Drupal\FunctionalJavascriptTests\Ajax;

use Drupal\FunctionalJavascriptTests\JavascriptTestBase;

/**
 * Tests Ajax callbacks on FAPI elements.
 *
 * @group Ajax
 */
class AjaxCallbacksTest extends JavascriptTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = ['ajax_forms_test'];

  /**
   * Tests if Ajax callback works on date element.
   */
  public function testDateTimeAjaxCallback() {

    // Test Ajax callback when date changes.
    $this->drupalGet('ajax_forms_test_ajax_element_form');
    $this->assertSession()->responseContains('No date selected.');
    $this->getSession()->getPage()->fillField('edit-datetime-date', '2016-01-01');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->responseNotContains('No date selected.');
    $this->assertSession()->responseContains('2016-01-01');
    $this->getSession()->getPage()->fillField('edit-datetime-time', '12:00:00');
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertSession()->responseContains('2016-01-01 12:00:00');
  }

}