diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index af785c1..f99f327 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -117,15 +117,14 @@ function testFileCreateUrl() { // when $script_path is not empty (i.e., when not using clean URLs). $clean_url_settings = array( 'clean' => '', - // @todo Reinstate non-clean URL testing. - // 'unclean' => 'index.php/', + 'unclean' => 'index.php/', ); foreach ($clean_url_settings as $clean_url_setting => $script_path) { $clean_urls = $clean_url_setting == 'clean'; $request = $this->prepareRequestForGenerator($clean_urls); $base_path = $request->getSchemeAndHttpHost() . $request->getBasePath(); - $this->assertFileUrl('public', '', $basename, $base_path . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $basename_encoded); - $this->assertFileUrl('private', '', $basename, $base_path . '/' . $script_path . 'system/files/' . $basename_encoded); + $this->checkUrl('public', '', $basename, $base_path . '/' . file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $basename_encoded); + $this->checkUrl('private', '', $basename, $base_path . '/' . $script_path . 'system/files/' . $basename_encoded); } $this->assertEqual(file_create_url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Generated URL matches expected URL.')); } @@ -146,7 +145,7 @@ function testFileCreateUrl() { * @param $expected_url * The expected URL */ - private function assertFileUrl($scheme, $directory, $filename, $expected_url) { + private function checkUrl($scheme, $directory, $filename, $expected_url) { // Convert $filename to a valid filename, i.e. strip characters not // supported by the filesystem, and create the file in the specified // directory. diff --git a/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php b/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php index 6e98a39..b57ce9f 100644 --- a/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php +++ b/core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php @@ -148,10 +148,9 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash = $this->assertNotEqual($original_uri, $modified_uri, 'An extra slash was added to the generated file URI.'); $generate_url = $this->style->buildUrl($modified_uri, $clean_url); } - // @todo Reinstate non-clean URL testing. - // if (!$clean_url) { - // $this->assertTrue(strpos($generate_url, 'index.php/') !== FALSE, 'When using non-clean URLS, the system path contains the script name.'); - // } + if (!$clean_url) { + $this->assertTrue(strpos($generate_url, 'index.php/') !== FALSE, 'When using non-clean URLS, the system path contains the script name.'); + } // Add some extra chars to the token. $this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url)); $this->assertResponse(403, 'Image was inaccessible at the URL with an invalid token.'); diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php index d76b448..4753539 100644 --- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php @@ -417,10 +417,7 @@ function testLanguageDomain() { // Test URL in another language: http://it.example.com/admin. // Base path gives problems on the testbot, so $correct_link is hard-coded. // @see UrlAlterFunctionalTest::assertUrlOutboundAlter (path.test). - // @todo Using \Drupal::url() doesn't use the language prefixing. - // $italian_url = \Drupal::url('system.admin', [], ['language' => $languages['it'], 'script' => '']); - $italian_url = \Drupal::urlGenerator()->generateFromPath('admin', ['language' => $languages['it'], 'script' => '']); - + $italian_url = url('admin', array('language' => $languages['it'], 'script' => '')); $url_scheme = \Drupal::request()->isSecure() ? 'https://' : 'http://'; $correct_link = $url_scheme . $link; $this->assertEqual($italian_url, $correct_link, format_string('The url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url))); @@ -429,8 +426,7 @@ function testLanguageDomain() { $this->settingsSet('mixed_mode_sessions', TRUE); $this->rebuildContainer(); - // $italian_url = \Drupal::url('system.admin', ['https' => TRUE, 'language' => $languages['it'], 'script' => '']); - $italian_url = \Drupal::urlGenerator()->generateFromPath('admin', ['https' => TRUE, 'language' => $languages['it'], 'script' => '']); + $italian_url = url('admin', array('https' => TRUE, 'language' => $languages['it'], 'script' => '')); $correct_link = 'https://' . $link; $this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url))); $this->settingsSet('mixed_mode_sessions', FALSE); @@ -438,10 +434,8 @@ function testLanguageDomain() { // Test HTTPS via current URL scheme. $request = Request::create('', 'GET', array(), array(), array(), array('HTTPS' => 'on')); $this->container->get('request_stack')->push($request); - - // $italian_url = \Drupal::url('system.admin', [], ['language' => $languages['it'], 'script' => '']); - $italian_url = \Drupal::urlGenerator()->generateFromPath('admin', ['language' => $languages['it'], 'script' => '']); - + $generator = $this->container->get('url_generator'); + $italian_url = url('admin', array('language' => $languages['it'], 'script' => '')); $correct_link = 'https://' . $link; $this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url))); } diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php index 59abbfe..772ac2a 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -51,9 +51,9 @@ protected function setUp() { parent::setUp(); // Update module should not go out to d.o to check for updates. We override - // the URL to the frontpage, which of course does not provide update data, - // hence no data will be found. - \Drupal::config('update.settings')->set('fetch.url', \Drupal::url('', [], array('absolute' => TRUE)))->save(); + // the url to the default update_test xml path. But without providing + // a mock xml file, no update data will be found. + \Drupal::config('update.settings')->set('fetch.url', url('update-test', array('absolute' => TRUE)))->save(); // Setup timestamps to identify old and new translation sources. $this->timestampOld = REQUEST_TIME - 300; diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module index 255345f..d9fd382 100644 --- a/core/modules/locale/tests/modules/locale_test/locale_test.module +++ b/core/modules/locale/tests/modules/locale_test/locale_test.module @@ -46,15 +46,19 @@ function locale_test_locale_translation_projects_alter(&$projects) { $projects['drupal']['server_pattern'] = 'translations://'; if (\Drupal::state()->get('locale.test_projects_alter')) { + + // Instead of the default ftp.drupal.org we use the file system of the test + // instance to simulate a remote file location. + $url = url(NULL, array('absolute' => TRUE)); + $remote_url = $url . PublicStream::basePath() . '/remote/'; + // Completely replace the project data with a set of test projects. $projects = array( 'contrib_module_one' => array( 'name' => 'contrib_module_one', 'info' => array( 'name' => 'Contributed module one', - // Instead of the default ftp.drupal.org we use the file system of the - // test instance to simulate a remote file location. - 'interface translation server pattern' => file_create_url('public://remote/%core/%project/%project-%version.%language._po'), + 'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po', 'package' => 'Other', 'version' => '8.x-1.1', 'project' => 'contrib_module_one', @@ -69,9 +73,7 @@ function locale_test_locale_translation_projects_alter(&$projects) { 'name' => 'contrib_module_two', 'info' => array( 'name' => 'Contributed module two', - // Instead of the default ftp.drupal.org we use the file system of the - // test instance to simulate a remote file location. - 'interface translation server pattern' => file_create_url('public://remote/%core/%project/%project-%version.%language._po'), + 'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po', 'package' => 'Other', 'version' => '8.x-2.0-beta4', 'project' => 'contrib_module_two', @@ -86,9 +88,7 @@ function locale_test_locale_translation_projects_alter(&$projects) { 'name' => 'contrib_module_three', 'info' => array( 'name' => 'Contributed module three', - // Instead of the default ftp.drupal.org we use the file system of the - // test instance to simulate a remote file location. - 'interface translation server pattern' => file_create_url('public://remote/%core/%project/%project-%version.%language._po'), + 'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po', 'package' => 'Other', 'version' => '8.x-1.0', 'project' => 'contrib_module_three', diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 94cb9d8..5ff660c 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -2697,6 +2697,7 @@ protected function prepareRequestForGenerator($clean_urls = TRUE, $override_serv $request = Request::create($request_path, 'GET', array(), array(), array(), $server); $this->container->get('request_stack')->push($request); + $this->container->get('router.request_context')->fromRequest($request); return $request; } }