You are here

public function DateValidationTest::wrongGranularity in Date 8

Same name in this branch
  1. 8 lib/Drupal/date/Tests/DateValidationTest.php \Drupal\date\Tests\DateValidationTest::wrongGranularity()
  2. 8 date_field/lib/Drupal/date_field/Tests/DateValidationTest.php \Drupal\date\Tests\DateValidationTest::wrongGranularity()

@todo.

2 calls to DateValidationTest::wrongGranularity()
DateValidationTest::testValidation in lib/Drupal/date/Tests/DateValidationTest.php
@todo.
DateValidationTest::testValidation in date_field/lib/Drupal/date_field/Tests/DateValidationTest.php
@todo.

File

lib/Drupal/date/Tests/DateValidationTest.php, line 120
Date validation tests.

Class

DateValidationTest

Namespace

Drupal\date\Tests

Code

public function wrongGranularity($field_name, $field_type, $widget_type) {

  // Create a node with incorrect granularity -- missing time.
  $edit = array();
  $edit['title'] = $this
    ->randomName(8);
  $edit['body[und][0][value]'] = $this
    ->randomName(16);
  if ($widget_type == 'date_select') {
    $edit[$field_name . '[und][0][value][year]'] = '2011';
    $edit[$field_name . '[und][0][value][month]'] = '12';
    $edit[$field_name . '[und][0][value][day]'] = '10';
    $edit[$field_name . '[und][0][value][hour]'] = '';
    $edit[$field_name . '[und][0][value][minute]'] = '';
  }
  elseif ($widget_type == 'date_popup') {
    $edit[$field_name . '[und][0][value][date]'] = '12/10/2011';
    $edit[$field_name . '[und][0][value][time]'] = '';
  }
  $this
    ->drupalPost('node/add/story', $edit, t('Save'));
  $should_not_be = $edit['title'] . " has been created";
  $this
    ->assertNoText($should_not_be, "Correctly blocked creation of node with missing time for a {$field_type} field using the {$widget_type} widget.");
  $this
    ->assertText('invalid', "Marked form with missing time as invalid for a {$field_type} field using the {$widget_type} widget.");
}