Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / tests / src / Kernel / FileUrlTest.php
diff --git a/web/core/modules/file/tests/src/Kernel/FileUrlTest.php b/web/core/modules/file/tests/src/Kernel/FileUrlTest.php
new file mode 100644 (file)
index 0000000..573fe25
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\Tests\file\Kernel;
+
+/**
+ * Tests the file url.
+ *
+ * @group file
+ */
+class FileUrlTest extends FileManagedUnitTestBase {
+
+  /**
+   * Test public files with a different host name from settings.
+   */
+  public function testFilesUrlWithDifferentHostName() {
+    $test_base_url = 'http://www.example.com/cdn';
+    $this->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);
+  }
+
+}