You are here

public function BytesTest::providerTestToInt in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Utility/BytesTest.php \Drupal\Tests\Component\Utility\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 47
Contains \Drupal\Tests\Component\Utility\BytesTest.

Class

BytesTest
Tests bytes size parsing helper methods.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerTestToInt() {
  return array(
    array(
      '1',
      1,
    ),
    array(
      '1 byte',
      1,
    ),
    array(
      '1 KB',
      Bytes::KILOBYTE,
    ),
    array(
      '1 MB',
      pow(Bytes::KILOBYTE, 2),
    ),
    array(
      '1 GB',
      pow(Bytes::KILOBYTE, 3),
    ),
    array(
      '1 TB',
      pow(Bytes::KILOBYTE, 4),
    ),
    array(
      '1 PB',
      pow(Bytes::KILOBYTE, 5),
    ),
    array(
      '1 EB',
      pow(Bytes::KILOBYTE, 6),
    ),
    array(
      '1 ZB',
      pow(Bytes::KILOBYTE, 7),
    ),
    array(
      '1 YB',
      pow(Bytes::KILOBYTE, 8),
    ),
    array(
      '23476892 bytes',
      23476892,
    ),
    array(
      '76MRandomStringThatShouldBeIgnoredByParseSize.',
      79691776,
    ),
    // 76 MB
    array(
      '76.24 Giggabyte',
      81862076662,
    ),
  );
}