1 date_themes.test public DateThemeTestCase::testDateDisplaySingle()

Test date_display_single theme function.

File

core/modules/date/tests/date_themes.test, line 15
Test Date module theme functions.

Class

DateThemeTestCase
Testing date theme functions to render dates correctly.

Code

public function testDateDisplaySingle() {
  // Single date with timezone offset included in format.
  $variables = array(
    'date' => '2019-03-29T12:00+0100',
    'timezone' => '+0100',
    'dates' => array(
      'format' => 'Y-m-d\TH:iO',
    ),
    'attributes' => array(),
  );
  $expected = '<span class="date-display-single">2019-03-29T12:00+0100</span>';
  $output = theme('date_display_single', $variables);
  $success = $this->assertEqual($expected, $output, 'Single date with offset renders correctly.');
  if (!$success) {
    $this->verbose('<br />Expected:<pre>' . check_plain($expected) . '</pre>Got:<pre>' . check_plain($output) . '</pre>');
  }

  // Single date with timezone name as format.
  $variables = array(
    'date' => 'Europe/Berlin',
    'timezone' => 'Europe/Berlin',
    'dates' => array(
      'format' => 'e',
    ),
    'attributes' => array(),
  );
  $expected = '<span class="date-display-single">Europe/Berlin</span>';
  $output = theme('date_display_single', $variables);
  $success = $this->assertEqual($expected, $output, 'Single date as timezone identifier renders correctly.');
  if (!$success) {
    $this->verbose('<br />Expected:<pre>' . check_plain($expected) . '</pre>Got:<pre>' . check_plain($output) . '</pre>');
  }
}