protected function ViewsHandlerFieldDateTest::assertRenderedDatesEqual

3.x views_handler_field_date.test protected ViewsHandlerFieldDateTest::assertRenderedDatesEqual($view, $map, $timezone = NULL)
1 call to ViewsHandlerFieldDateTest::assertRenderedDatesEqual()

File

tests/handlers/views_handler_field_date.test, line 72
Definition of ViewsHandlerFieldDateTest.

Class

ViewsHandlerFieldDateTest
Tests the core views_handler_field_date handler.

Code

protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
  foreach ($map as $date_format => $expected_result) {
    $check_result_number = 0;

    // If it's "today time ago" format we have to check the 6th element.
    if ($date_format == 'today time ago') {
      $check_result_number = 5;
    }

    // Correct the date format.
    if ($date_format == 'today time ago custom') {
      $date_format = 'today time ago';
    }
    $view->field['created']->options['date_format'] = $date_format;
    $t_args = array(
      '%value' => $expected_result,
      '%format' => $date_format,
    );
    if (isset($timezone)) {
      $t_args['%timezone'] = $timezone;
      $message = t('Value %value in %format format for timezone %timezone matches.', $t_args);
      $view->field['created']->options['timezone'] = $timezone;
    }
    else {
      $message = t('Value %value in %format format matches.', $t_args);
    }
    $actual_result = $view->field['created']->advanced_render($view->result[$check_result_number]);
    $this->assertEqual($expected_result, $actual_result, $message);
  }
}