diff --git a/core/lib/Drupal/Core/Render/ElementInfoManager.php b/core/lib/Drupal/Core/Render/ElementInfoManager.php index 1054b85..52249ca 100644 --- a/core/lib/Drupal/Core/Render/ElementInfoManager.php +++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php @@ -57,8 +57,11 @@ public function getInfo($type) { if (!isset($this->elementInfo)) { $this->elementInfo = $this->buildInfo(); } - $info = isset($this->elementInfo[$type]) ? $this->elementInfo[$type] : array(); - $info['#defaults_loaded'] = TRUE; + $info = []; + if (isset($this->elementInfo[$type])) { + $info = $this->elementInfo[$type]; + $info['#defaults_loaded'] = TRUE; + } return $info; } diff --git a/core/modules/system/src/Tests/Database/LoggingTest.php b/core/modules/system/src/Tests/Database/LoggingTest.php index cf83b01..a8aec80 100644 --- a/core/modules/system/src/Tests/Database/LoggingTest.php +++ b/core/modules/system/src/Tests/Database/LoggingTest.php @@ -16,6 +16,13 @@ */ class LoggingTest extends DatabaseTestBase { + protected function setUp() { + parent::setUp(); + + // By default we use a memory sqlite implementation + } + + /** * Tests that we can log the existence of a query. */ @@ -63,6 +70,13 @@ function testEnableTargetLogging() { // Clone the primary credentials to a replica connection and to another fake // connection. $connection_info = Database::getConnectionInfo('default'); + + // Skip this test in case we use a sqlite memory storage, as replicas don't + // work there. + if ($connection_info['default']['driver'] === 'sqlite' && $connection_info['default']['database'] == ':memory:') { + $this->markTestSkipped(); + } + Database::addConnectionInfo('default', 'replica', $connection_info['default']); Database::startLog('testing1'); @@ -113,6 +127,12 @@ function testEnableMultiConnectionLogging() { $connection_info = Database::getConnectionInfo('default'); Database::addConnectionInfo('test2', 'default', $connection_info['default']); + // Skip this test in case we use a sqlite memory storage, as multiple + // connections to the same memory instance won't work. + if ($connection_info['default']['driver'] === 'sqlite' && $connection_info['default']['database'] == ':memory:') { + $this->markTestSkipped(); + } + Database::startLog('testing1'); Database::startLog('testing1', 'test2'); diff --git a/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php index e970fe3..fc2beaf 100644 --- a/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ModuleHandlerTest.php @@ -33,12 +33,14 @@ public function containerBuild(ContainerBuilder $container) { */ function testModuleList() { $module_list = array(); - $module_list[] = 'system'; $this->assertModuleList($module_list, 'Initial'); + // @fixme ModuleInstaller calls system_rebuild_module_data which is part of system.module. + include_once $this->root . '/core/modules/system/system.module'; + // Try to install a new module. - $this->moduleHandler()->install(array('ban')); + $this->moduleInstaller()->install(array('ban')); $module_list[] = 'ban'; sort($module_list); $this->assertModuleList($module_list, 'After adding a module'); diff --git a/core/modules/system/src/Tests/File/UrlRewritingTest.php b/core/modules/system/src/Tests/File/UrlRewritingTest.php index 82e266b..6ccf6d5 100644 --- a/core/modules/system/src/Tests/File/UrlRewritingTest.php +++ b/core/modules/system/src/Tests/File/UrlRewritingTest.php @@ -29,6 +29,7 @@ class UrlRewritingTest extends FileTestBase { function testShippedFileURL() { // Test generating an URL to a shipped file (i.e. a file that is part of // Drupal core, a module or a theme, for example a JavaScript file). + $base_path = base_path(); if ($base_path !== '/') { $base_path .= '/'; @@ -59,7 +60,19 @@ function testShippedFileURL() { $this->assertEqual('/' . $base_path . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.'); $filepath = 'core/misc/favicon.ico'; $url = file_create_url($filepath); - $this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.'); + $this->assertEqual('/' . $base_path . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.'); + + // Test alteration of file URLs with query strings and/or fragment. + \Drupal::state()->delete('file_test.hook_file_url_alter'); + $filepath = 'core/misc/favicon.ico'; + $url = file_create_url($filepath . '?foo'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=', $url, 'Correctly generated url. The query string is present.'); + $url = file_create_url($filepath . '?foo=bar'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar', $url, 'Correctly generated url. The query string is present.'); + $url = file_create_url($filepath . '#v1.2'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '#v1.2', $url, 'Correctly generated url. The fragment is present.'); + $url = file_create_url($filepath . '?foo=bar#v1.2'); + $this->assertEqual($GLOBALS['base_url'] . '/' . $filepath . '?foo=bar#v1.2', $url, 'Correctly generated url. The query string amd fragment is present.'); } /** diff --git a/core/tests/Drupal/Tests/KernelTestBase.php b/core/tests/Drupal/Tests/KernelTestBase.php index e923a04..d012fd3 100644 --- a/core/tests/Drupal/Tests/KernelTestBase.php +++ b/core/tests/Drupal/Tests/KernelTestBase.php @@ -215,7 +215,7 @@ protected function setUp() { */ protected function bootEnvironment() { $this->streamWrappers = array(); - \Drupal::setContainer(NULL); + \Drupal::unsetContainer(); // @see /core/tests/bootstrap.php $this->classLoader = $GLOBALS['loader']; @@ -495,7 +495,7 @@ private function getCompiledContainerBuilder(array $modules) { } // Destruct and trigger garbage collection. - \Drupal::setContainer(NULL); + \Drupal::unsetContainer(); $kernel->shutdown(); $kernel = NULL; // @see register() @@ -670,8 +670,10 @@ protected function tearDown() { } // Clean up statics, container, and settings. - drupal_static_reset(); - \Drupal::setContainer(NULL); + if (function_exists('drupal_static_reset')) { + drupal_static_reset(); + } + \Drupal::unsetContainer(); $this->container = NULL; new Settings(array()); diff --git a/core/tests/Drupal/Tests/KernelTestBaseTest.php b/core/tests/Drupal/Tests/KernelTestBaseTest.php index 04e78b3..d63da4e 100644 --- a/core/tests/Drupal/Tests/KernelTestBaseTest.php +++ b/core/tests/Drupal/Tests/KernelTestBaseTest.php @@ -27,9 +27,9 @@ public function testSetUpBeforeClass() { } /** - * @covers ::prepareEnvironment + * @covers ::bootEnvironment */ - public function testPrepareEnvironment() { + public function testBootEnvironment() { $this->assertRegExp('/^simpletest\d{6}$/', $this->databasePrefix); $this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory); $this->assertEquals(array( @@ -145,25 +145,25 @@ public function testCompiledContainerIsDestructed() { * @covers ::render */ public function testRender() { - $type = 'html_tag'; + $type = 'processed_text'; $element_info = $this->container->get('element_info'); - $this->assertEmpty($this->container->get('element_info')->getInfo($type)); + $this->assertEmpty($element_info->getInfo($type)); - $this->enableModules(array('system')); + $this->enableModules(array('filter')); $this->assertNotSame($element_info, $this->container->get('element_info')); $this->assertNotEmpty($this->container->get('element_info')->getInfo($type)); $build = array( - '#type' => $type, + '#type' => 'html_tag', '#tag' => 'h3', '#value' => 'Inner', ); $expected = "