blob: aca3a93a8f9cfe818517aa9eccbc9bf760349ab2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?php
declare(strict_types=1);
namespace Drupal\Tests\file\Kernel;
use Drupal\Core\File\FileSystemInterface;
/**
* Tests the file URL.
*
* @group file
*/
class FileUrlTest extends FileManagedUnitTestBase {
/**
* Tests public files with a different host name from settings.
*/
public function testFilesUrlWithDifferentHostName(): void {
$test_base_url = 'http://www.example.com/cdn';
$this->setSetting('file_public_base_url', $test_base_url);
$filepath = \Drupal::service('file_system')->createFilename('test.txt', '');
$directory_uri = 'public://' . dirname($filepath);
\Drupal::service('file_system')->prepareDirectory($directory_uri, FileSystemInterface::CREATE_DIRECTORY);
$file = $this->createFile($filepath, NULL, 'public');
$url = $file->createFileUrl(FALSE);
$expected_url = $test_base_url . '/' . basename($filepath);
$this->assertSame($url, $expected_url);
}
}
|