views_handler_field_file_extension.test
Definition of ViewsHandlerFileExtensionTest.
File
-
tests/
handlers/ views_handler_field_file_extension.test
View source
<?php
/**
* @file
* Definition of ViewsHandlerFileExtensionTest.
*/
/**
* Tests the views_handler_field_file_extension handler.
*/
class ViewsHandlerFileExtensionTest extends ViewsSqlTest {
/**
*
*/
public static function getInfo() {
return array(
'name' => 'Field: File extension',
'description' => 'Test the views_handler_field_file_extension handler.',
'group' => 'Views Handlers',
);
}
/**
*
*/
public function dataSet() {
$data = parent::dataSet();
$data[0]['name'] = 'file.png';
$data[1]['name'] = 'file.tar';
$data[2]['name'] = 'file.tar.gz';
$data[3]['name'] = 'file';
return $data;
}
/**
*
*/
public function viewsData() {
$data = parent::viewsData();
$data['views_test']['name']['field']['handler'] = 'views_handler_field_file_extension';
$data['views_test']['name']['real field'] = 'name';
return $data;
}
/**
* Tests the 'extension_detect_tar' handler option.
*/
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]), '');
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
ViewsHandlerFileExtensionTest | Tests the views_handler_field_file_extension handler. |