diff --git a/core/tests/Drupal/Tests/Component/Utility/BytesTest.php b/core/tests/Drupal/Tests/Component/Utility/BytesTest.php index 5c024f3..a1c4ca6 100644 --- a/core/tests/Drupal/Tests/Component/Utility/BytesTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/BytesTest.php @@ -13,6 +13,8 @@ /** * Tests bytes size parsing helper methods. * + * @group Drupal + * @group Utility * @coversDefaultClass \Drupal\Component\Utility\Bytes */ class BytesTest extends UnitTestCase { @@ -20,7 +22,7 @@ class BytesTest extends UnitTestCase { public static function getInfo() { return array( 'name' => 'Bytes utility helpers', - 'description' => 'Parse a predefined amount of bytes and compare the output with the expected value.', + 'description' => '', 'group' => 'Utility', ); } @@ -32,7 +34,7 @@ public static function getInfo() { * @covers ::toInt */ public function testToInt($size, $expected_int) { - $this->assertEquals(Bytes::toInt($size), $expected_int); + $this->assertEquals($expected_int, Bytes::toInt($size)); } public function providerTestToInt() { diff --git a/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php b/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php index 2b160dc..c415d8a 100644 --- a/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php @@ -28,57 +28,29 @@ public static function getInfo() { } /** - * Tests that the Environment::checkMemoryLimit() method works as expected. - * - * @param string $required - * The required memory limit argument for Environment::checkMemoryLimit(). - * @param string $memory_limit - * The memory limit argument for Environment::checkMemoryLimit(). - * @param boolean $expected - * The expected return value from Environment::checkMemoryLimit(). - * @param string $message - * The message to print on test failure. + * Tests Environment::checkMemoryLimit(). * * @dataProvider providerTestCheckMemoryLimit * @covers ::checkMemoryLimit */ - public function testCheckMemoryLimit($required, $memory_limit, $expected, $message) { - $return = Environment::checkMemoryLimit($required, $memory_limit); - $this->assertEquals($return, $expected, $message); + public function testCheckMemoryLimit($required, $custom_memory_limit, $expected) { + $actual = Environment::checkMemoryLimit($required, $custom_memory_limit); + $this->assertEquals($expected, $actual); } - /** - * Data provider for self::testCheckMemoryLimit(). - * - * @return array - * An array of arrays, each containing: - * - required: The required memory limit argument for - * Environment::checkMemoryLimit(). - * - memory_limit: The memory limit argument for - * Environment::checkMemoryLimit(). - * - expected: The expected return value from - * Environment::checkMemoryLimit(). - * - message: The message to print on test failure. - */ public function providerTestCheckMemoryLimit() { $memory_limit = ini_get('memory_limit'); $twice_avail_memory = ($memory_limit * 2) . 'MB'; return array( - // Test that a very reasonable amount of memory is available. - array('30MB', NULL, TRUE, '30MB of memory tested not available.'), - - // Get the available memory and multiply it by two to make it unreasonably - // high. - array($twice_avail_memory, -1, TRUE, 'Environment::checkMemoryLimit() failed to return TRUE when a limit of -1 (none) is supplied'), - - // Test that even though we have 30MB of memory available - the function - // returns FALSE when given an upper limit for how much memory can be used. - array('30MB', '16MB', FALSE, 'Environment::checkMemoryLimit() failed to return FALSE with a 16MB upper limit on a 30MB requirement.'), - - // Test that an equal amount of memory to the amount requested returns - // TRUE. - array('30MB', '30MB', TRUE, 'Environment::checkMemoryLimit() failed to return TRUE when requesting 30MB on a 30MB requirement.'), + // Minimal amount of memory should be available. + array('30MB', NULL, TRUE), + // Exceed a custom (unlimited) memory limit. + array($twice_avail_memory, -1, TRUE), + // Exceed a custom memory limit. + array('30MB', '16MB', FALSE), + // Available = required. + array('30MB', '30MB', TRUE), ); }