function BytesTest::providerTestToInt
Provides data for testToInt.
Return value
array An array of arrays, each containing the argument for \Drupal\Component\Utility\Bytes::toInt(): size, and the expected return value.
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ BytesTest.php, line 42
Class
- BytesTest
- Tests bytes size parsing helper methods.
Namespace
Drupal\Tests\Component\UtilityCode
public function providerTestToInt() {
return [
[
'1',
1,
],
[
'1 byte',
1,
],
[
'1 KB',
Bytes::KILOBYTE,
],
[
'1 MB',
pow(Bytes::KILOBYTE, 2),
],
[
'1 GB',
pow(Bytes::KILOBYTE, 3),
],
[
'1 TB',
pow(Bytes::KILOBYTE, 4),
],
[
'1 PB',
pow(Bytes::KILOBYTE, 5),
],
[
'1 EB',
pow(Bytes::KILOBYTE, 6),
],
[
'1 ZB',
pow(Bytes::KILOBYTE, 7),
],
[
'1 YB',
pow(Bytes::KILOBYTE, 8),
],
[
'23476892 bytes',
23476892,
],
// 76 MB.
[
'76MRandomStringThatShouldBeIgnoredByParseSize.',
79691776,
],
// 76.24 GB (with typo).
[
'76.24 Giggabyte',
81862076662,
],
[
'1.5',
2,
],
[
'2.4',
2,
],
[
'',
0,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.