diff --git a/core/lib/Drupal/Core/Bootstrap/Bootstrap.php b/core/lib/Drupal/Core/Bootstrap/Bootstrap.php index 5e7514a..4acf5d7 100644 --- a/core/lib/Drupal/Core/Bootstrap/Bootstrap.php +++ b/core/lib/Drupal/Core/Bootstrap/Bootstrap.php @@ -67,7 +67,7 @@ public static function checkMemoryLimit($required, $memory_limit = NULL) { * the command line script should pass in the desired value via the * 'REMOTE_ADDR' key. * - * @param $variables + * @param array $variables * (optional) An associative array of variables within $_SERVER that should * be replaced. If the special element 'url' is provided in this array, it * will be used to populate some of the server defaults; it should be set to diff --git a/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php b/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php index 22c03fd..1d736cd 100644 --- a/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php +++ b/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php @@ -11,7 +11,9 @@ use Drupal\Tests\UnitTestCase; /** - * Tests for overriding server variables via the API. + * Tests for various bootstrap operations. + * + * @see \Drupal\Core\Bootstrap\Bootstrap */ class BootstrapTest extends UnitTestCase { public static function getInfo() { @@ -25,7 +27,7 @@ public static function getInfo() { /** * Tests providing a direct URL to to drupal_override_server_variables(). * - * @dataProvider provider + * @dataProvider providerTestOverrideServerVariables */ public function testOverrideServerVariables($url, $expected_server_values) { // Remember the original value of $_SERVER, since the function call below @@ -42,9 +44,31 @@ public function testOverrideServerVariables($url, $expected_server_values) { } /** + * Tests that the Bootstrap::checkMemoryLimit() method works as expected. + */ + function testCheckMemoryLimit() { + $memory_limit = ini_get('memory_limit'); + // Test that a very reasonable amount of memory is available. + $this->assertTrue(Bootstrap::checkMemoryLimit('30MB'), '30MB of memory tested available.'); + + // Get the available memory and multiply it by two to make it unreasonably + // high. + $twice_avail_memory = ($memory_limit * 2) . 'MB'; + // The function should always return true if the memory limit is set to -1. + $this->assertTrue(Bootstrap::checkMemoryLimit($twice_avail_memory, -1), 'Bootstrap::checkMemoryLimit() returns 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. + $this->assertFalse(Bootstrap::checkMemoryLimit('30MB', '16MB'), 'Bootstrap::checkMemoryLimit() returns FALSE with a 16MB upper limit on a 30MB requirement.'); + + // Test that an equal amount of memory to the amount requested returns TRUE. + $this->assertTrue(Bootstrap::checkMemoryLimit('30MB', '30MB'), 'Bootstrap::checkMemoryLimit() returns TRUE when requesting 30MB on a 30MB requirement.'); + } + + /** * Provide data for self::testDrupalOverrideServerVariablesProvideURL(). */ - public function provider() { + public function providerTestOverrideServerVariables() { return array( // Array of the form array(uri, expected values). array( diff --git a/core/tests/Drupal/Tests/Core/Bootstrap/MiscUnitTest.php b/core/tests/Drupal/Tests/Core/Bootstrap/MiscUnitTest.php deleted file mode 100644 index 3518cd2..0000000 --- a/core/tests/Drupal/Tests/Core/Bootstrap/MiscUnitTest.php +++ /dev/null @@ -1,47 +0,0 @@ - 'Miscellaneous bootstrap unit tests', - 'description' => 'Test miscellaneous functions in bootstrap.inc.', - 'group' => 'Bootstrap', - ); - } - - /** - * Tests that the Bootstrap::checkMemoryLimit() method works as expected. - */ - function testCheckMemoryLimit() { - $memory_limit = ini_get('memory_limit'); - // Test that a very reasonable amount of memory is available. - $this->assertTrue(Bootstrap::checkMemoryLimit('30MB'), '30MB of memory tested available.'); - - // Get the available memory and multiply it by two to make it unreasonably - // high. - $twice_avail_memory = ($memory_limit * 2) . 'MB'; - // The function should always return true if the memory limit is set to -1. - $this->assertTrue(Bootstrap::checkMemoryLimit($twice_avail_memory, -1), 'Bootstrap::checkMemoryLimit() returns 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. - $this->assertFalse(Bootstrap::checkMemoryLimit('30MB', '16MB'), 'Bootstrap::checkMemoryLimit() returns FALSE with a 16MB upper limit on a 30MB requirement.'); - - // Test that an equal amount of memory to the amount requested returns TRUE. - $this->assertTrue(Bootstrap::checkMemoryLimit('30MB', '30MB'), 'Bootstrap::checkMemoryLimit() returns TRUE when requesting 30MB on a 30MB requirement.'); - } -}