From 707740e09c44fc4260084e976df6197fb1294616 Mon Sep 17 00:00:00 2001 From: xjm Date: Sat, 2 Dec 2017 05:35:13 -0600 Subject: [PATCH] Issue #2919872 by vaplas, dawehner: Move part of DownloadTest::testFileCreateUrl() to a new Kernel test --- core/modules/file/src/Tests/DownloadTest.php | 10 ------- .../file/tests/src/Kernel/FileUrlTest.php | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 core/modules/file/tests/src/Kernel/FileUrlTest.php diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index 239155cf401..8f85f09f960 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -118,16 +118,6 @@ class DownloadTest extends FileManagedTestBase { $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.')); - // Test public files with a different host name from settings. - $test_base_url = 'http://www.example.com/cdn'; - $this->settingsSet('file_public_base_url', $test_base_url); - $filepath = file_create_filename('test.txt', ''); - $directory_uri = 'public://' . dirname($filepath); - file_prepare_directory($directory_uri, FILE_CREATE_DIRECTORY); - $file = $this->createFile($filepath, NULL, 'public'); - $url = file_create_url($file->getFileUri()); - $expected_url = $test_base_url . '/' . basename($filepath); - $this->assertEqual($url, $expected_url); } /** diff --git a/core/modules/file/tests/src/Kernel/FileUrlTest.php b/core/modules/file/tests/src/Kernel/FileUrlTest.php new file mode 100644 index 00000000000..573fe254441 --- /dev/null +++ b/core/modules/file/tests/src/Kernel/FileUrlTest.php @@ -0,0 +1,27 @@ +setSetting('file_public_base_url', $test_base_url); + $filepath = file_create_filename('test.txt', ''); + $directory_uri = 'public://' . dirname($filepath); + file_prepare_directory($directory_uri, FILE_CREATE_DIRECTORY); + $file = $this->createFile($filepath, NULL, 'public'); + $url = file_create_url($file->getFileUri()); + $expected_url = $test_base_url . '/' . basename($filepath); + $this->assertSame($url, $expected_url); + } + +}