1 common.test | CommonSizeUnitTestCase::setUp() |
Sets up unit test environment.
Unlike BackdropWebTestCase::setUp(), BackdropUnitTestCase::setUp() does not install modules because tests are performed without accessing the database. Any required files must be explicitly included by the child class setUp() method.
Overrides BackdropUnitTestCase::setUp
File
- core/
modules/ simpletest/ tests/ common.test, line 561 - Tests for common.inc functionality.
Class
- CommonSizeUnitTestCase
- Tests file size parsing and formatting functions.
Code
function setUp() {
$kb = BACKDROP_KILOBYTE;
$this->exact_test_cases = array(
'1 byte' => 1,
'1 KB' => $kb,
'1 MB' => $kb * $kb,
'1 GB' => $kb * $kb * $kb,
'1 TB' => $kb * $kb * $kb * $kb,
'1 PB' => $kb * $kb * $kb * $kb * $kb,
'1 EB' => $kb * $kb * $kb * $kb * $kb * $kb,
'1 ZB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb,
'1 YB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb * $kb,
);
$this->rounded_test_cases = array(
'2 bytes' => 2,
'1 MB' => ($kb * $kb) - 1, // rounded to 1 MB (not 1000 or 1024 kilobyte!)
round(3623651 / ($this->exact_test_cases['1 MB']), 2) . ' MB' => 3623651, // megabytes
round(67234178751368124 / ($this->exact_test_cases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes
round(235346823821125814962843827 / ($this->exact_test_cases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes
);
parent::setUp();
}