You are here

public function ViewsHandlerFileExtensionTest::testFileExtensionTarOption in Views (for Drupal 7) 7.3

Tests the 'extension_detect_tar' handler option.

File

tests/handlers/views_handler_field_file_extension.test, line 41
Definition of ViewsHandlerFileExtensionTest.

Class

ViewsHandlerFileExtensionTest
Tests the views_handler_field_file_extension handler.

Code

public function testFileExtensionTarOption() {
  $view = $this
    ->getBasicView();
  $view->display['default']->handler
    ->override_option('fields', array(
    'name' => array(
      'id' => 'name',
      'table' => 'views_test',
      'field' => 'name',
    ),
  ));
  $this
    ->executeView($view);

  // Test without the tar option.
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[0]), 'png');
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[1]), 'tar');
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[2]), 'gz');
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[3]), '');

  // Test with the tar option.
  $view->field['name']->options['extension_detect_tar'] = TRUE;
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[0]), 'png');
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[1]), 'tar');
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[2]), 'tar.gz');
  $this
    ->assertEqual($view->field['name']
    ->advanced_render($view->result[3]), '');
}