function FieldFileSizeTest::testFieldFileSize
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php \Drupal\Tests\views\Kernel\Handler\FieldFileSizeTest::testFieldFileSize()
- 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php \Drupal\Tests\views\Kernel\Handler\FieldFileSizeTest::testFieldFileSize()
- 11.x core/modules/views/tests/src/Kernel/Handler/FieldFileSizeTest.php \Drupal\Tests\views\Kernel\Handler\FieldFileSizeTest::testFieldFileSize()
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ FieldFileSizeTest.php, line 42
Class
- FieldFileSizeTest
- Tests the core Drupal\views\Plugin\views\field\FileSize handler.
Namespace
Drupal\Tests\views\Kernel\HandlerCode
public function testFieldFileSize() : void {
$view = Views::getView('test_view');
$view->setDisplay();
$view->displayHandlers
->get('default')
->overrideOption('fields', [
'age' => [
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
],
]);
$this->executeView($view);
// Test with the formatted option.
$this->assertEquals('', $view->field['age']
->advancedRender($view->result[0]));
$this->assertEquals('10 bytes', $view->field['age']
->advancedRender($view->result[1]));
$this->assertEquals('1000 bytes', $view->field['age']
->advancedRender($view->result[2]));
$this->assertEquals('9.77 KB', $view->field['age']
->advancedRender($view->result[3]));
// Test with the bytes option.
$view->field['age']->options['file_size_display'] = 'bytes';
$this->assertEquals('', $view->field['age']
->advancedRender($view->result[0]));
$this->assertEquals('10', $view->field['age']
->advancedRender($view->result[1]));
$this->assertEquals('1000', $view->field['age']
->advancedRender($view->result[2]));
$this->assertEquals('10000', $view->field['age']
->advancedRender($view->result[3]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.