Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / file / tests / src / Kernel / FileUrlTest.php
1 <?php
2
3 namespace Drupal\Tests\file\Kernel;
4
5 /**
6  * Tests the file url.
7  *
8  * @group file
9  */
10 class FileUrlTest extends FileManagedUnitTestBase {
11
12   /**
13    * Test public files with a different host name from settings.
14    */
15   public function testFilesUrlWithDifferentHostName() {
16     $test_base_url = 'http://www.example.com/cdn';
17     $this->setSetting('file_public_base_url', $test_base_url);
18     $filepath = file_create_filename('test.txt', '');
19     $directory_uri = 'public://' . dirname($filepath);
20     file_prepare_directory($directory_uri, FILE_CREATE_DIRECTORY);
21     $file = $this->createFile($filepath, NULL, 'public');
22     $url = file_create_url($file->getFileUri());
23     $expected_url = $test_base_url . '/' . basename($filepath);
24     $this->assertSame($url, $expected_url);
25   }
26
27 }