1.20.x views_handler_field_file_extension.test public ViewsHandlerFileExtensionTest::testFileExtensionTarOption()

Tests the 'extension_detect_tar' handler option.

File

modules/views/tests/handlers/views_handler_field_file_extension.test, line 35
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]), '');
}