You are here

public function DateRepeatFormTest::testDateRepeatForm in Date 8

File

date_repeat/lib/Drupal/date_repeat/Tests/DateRepeatFormTest.php, line 45
Test Date Repeat form.

Class

DateRepeatFormTest

Namespace

Drupal\date_repeat\Tests

Code

public function testDateRepeatForm() {
  $edit = array();
  $edit['name'] = 'Date';
  $edit['type'] = 'date';
  $this
    ->drupalPost('admin/structure/types/add', $edit, t('Save content type'));
  $this
    ->assertText('The content type Date has been added.', 'Content type added.');
  $display_all_day = FALSE;

  // Testing options.
  $widget_options = array(
    'date_select' => 'select',
    'date_popup' => 'popup',
  );
  foreach ($widget_options as $widget => $options) {

    // Daily tests
    // Creates date field stored as a datetime.
    $this
      ->createDateField($type = 'datetime', $widget, $display_all_day);
    $form_edit = $this
      ->dateForm($options, 'daily_1');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_2');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_3');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_4');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_1', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_2', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_3', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_4', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_1', FALSE, 'exclude');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_1', FALSE, 'include');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'daily_1', FALSE, 'exclude_include');
    $this
      ->verifyDateForm($form_edit);

    // Weekly tests
    $form_edit = $this
      ->dateForm($options, 'weekly_1');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_2');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_3');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_4');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_1', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_2', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_3', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'weekly_4', TRUE);
    $this
      ->verifyDateForm($form_edit);

    // Monthly tests
    $form_edit = $this
      ->dateForm($options, 'monthly_1');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_2');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_3');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_4');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_5');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_6');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_1', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_2', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_3', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_4', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_5', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'monthly_6', TRUE);
    $this
      ->verifyDateForm($form_edit);

    // Yearly tests
    $form_edit = $this
      ->dateForm($options, 'yearly_1');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_2');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_3');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_4');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_5');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_6');
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_1', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_2', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_3', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_4', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_5', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $form_edit = $this
      ->dateForm($options, 'yearly_6', TRUE);
    $this
      ->verifyDateForm($form_edit);
    $this
      ->deleteDateField();
  }
}