diff --git a/core/lib/Drupal/Component/Utility/Bytes.php b/core/lib/Drupal/Component/Utility/Bytes.php index 0bc5aa9..aae2a51 100644 --- a/core/lib/Drupal/Component/Utility/Bytes.php +++ b/core/lib/Drupal/Component/Utility/Bytes.php @@ -25,7 +25,7 @@ class Bytes { * An integer or string size expressed as a number of bytes with optional SI * or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8 bytes, 9mbytes). * - * @return integer + * @return int * An integer representation of the size in bytes. */ public static function parseSize($size) { diff --git a/core/lib/Drupal/Core/Bootstrap/Bootstrap.php b/core/lib/Drupal/Core/Bootstrap/Bootstrap.php index c837d6d..1d7138b 100644 --- a/core/lib/Drupal/Core/Bootstrap/Bootstrap.php +++ b/core/lib/Drupal/Core/Bootstrap/Bootstrap.php @@ -26,7 +26,7 @@ class Bootstrap { * 6GiB, 8bytes, 9mbytes). If no value is passed, the current PHP * memory_limit will be used. Defaults to NULL. * - * @return boolean + * @return bool * TRUE if there is sufficient memory to allow the operation, or FALSE * otherwise. */ diff --git a/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php b/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php index e57c86e..439308c 100644 --- a/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php +++ b/core/tests/Drupal/Tests/Core/Bootstrap/BootstrapTest.php @@ -8,7 +8,10 @@ namespace Drupal\Tests\Core\Bootstrap; use Drupal\Core\Bootstrap\Bootstrap; +use Drupal\Core\Controller\ControllerResolver; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Tests\UnitTestCase; +use Symfony\Component\HttpFoundation\Request; /** * Tests for various bootstrap operations. @@ -19,6 +22,7 @@ * @group Bootstrap */ class BootstrapTest extends UnitTestCase { + public static function getInfo() { return array( 'name' => 'Overriding server variables', @@ -30,21 +34,27 @@ public static function getInfo() { /** * Tests providing a direct URL to to drupal_override_server_variables(). * - * @param string $url - * The url argument for Bootstrap::overrideServerVariables(). + * @param array $overrides + * The variables argument for Bootstrap::overrideServerVariables(). * @param array $expected_server_values * Expected values of the `$_SERVER` variable after calling * Bootstrap::overrideServerVariables(). * * @dataProvider providerTestOverrideServerVariables */ - public function testOverrideServerVariables($url, $expected_server_values) { + public function testOverrideServerVariables($overrides, $expected_server_values) { + // Create request and container. + $request = new Request(); + $container = new ContainerBuilder(); + $container->set('request', $request); + \Drupal::setContainer($container); + // Remember the original value of $_SERVER, since the function call below // will modify it. $original_server = $_SERVER; // Call drupal_override_server_variables() and ensure that all expected // $_SERVER variables were modified correctly. - Bootstrap::overrideServerVariables(array('url' => $url)); + Bootstrap::overrideServerVariables($overrides); foreach ($expected_server_values as $key => $value) { $this->assertSame($_SERVER[$key], $value); } @@ -76,7 +86,7 @@ public function testCheckMemoryLimit($required, $memory_limit, $expected, $messa * * @return array * An array of arrays, each containing: - * - 'url' - The url argument for Bootstrap::overrideServerVariables(). + * - 'overrides' - The variables argument to Bootstrap::overrideServerVariables(). * - 'expected_server_values' - Expected values of the `$_SERVER` variable * after calling Bootstrap::overrideServerVariables(). */ @@ -84,21 +94,30 @@ public function providerTestOverrideServerVariables() { return array( // Array of the form array(uri, expected values). array( - 'http://example.com', + array( + 'url' => 'http://example.com', + 'SCRIPT_NAME' => '/index.php', + ), array( 'HTTP_HOST' => 'example.com', - 'SCRIPT_NAME' => isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL, + 'SCRIPT_NAME' => '/index.php', ), ), array( - 'http://example.com/index.php', + array( + 'url' => 'http://example.com/index.php', + 'SCRIPT_NAME' => '/index.php', + ), array( 'HTTP_HOST' => 'example.com', 'SCRIPT_NAME' => '/index.php', ), ), array( - 'http://example.com/subdirectory/index.php', + array( + 'url' => 'http://example.com/subdirectory/index.php', + 'SCRIPT_NAME' => '/subdirectory/index.php', + ), array( 'HTTP_HOST' => 'example.com', 'SCRIPT_NAME' => '/subdirectory/index.php',