You are here

function FilterDateTest::testUiValidation in Views (for Drupal 7) 8.3

Make sure the validation callbacks works.

File

lib/Drupal/views/Tests/Handler/FilterDateTest.php, line 137
Definition of Drupal\views\Tests\Handler\FilterDateTest.

Class

FilterDateTest
Tests the core Drupal\views\Plugin\views\filter\Date handler.

Namespace

Drupal\views\Tests\Handler

Code

function testUiValidation() {
  $view = $this
    ->createViewFromConfig('test_filter_date_between');
  $view
    ->save();
  $this
    ->drupalLogin($this
    ->drupalCreateUser(array(
    'administer views',
    'administer site configuration',
  )));
  menu_router_rebuild();
  $this
    ->drupalGet('admin/structure/views/view/test_filter_date_between/edit');
  $this
    ->drupalGet('admin/structure/views/nojs/config-item/test_filter_date_between/default/filter/created');
  $edit = array();

  // Generate a definitive wrong value, which should be checked by validation.
  $edit['options[value][value]'] = $this
    ->randomString() . '-------';
  $this
    ->drupalPost(NULL, $edit, t('Apply'));
  $this
    ->assertText(t('Invalid date format.'), 'Make sure that validation is runned and the invalidate date format is identified.');
}