class FileUrlTest
Same name and namespace in other branches
- 10 core/modules/file/tests/src/Kernel/FileUrlTest.php \Drupal\Tests\file\Kernel\FileUrlTest
- 11.x core/modules/file/tests/src/Kernel/FileUrlTest.php \Drupal\Tests\file\Kernel\FileUrlTest
- 8.9.x core/modules/file/tests/src/Kernel/FileUrlTest.php \Drupal\Tests\file\Kernel\FileUrlTest
Tests the file url.
@group file
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\file\Kernel\FileManagedUnitTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\file\Kernel\FileUrlTest extends \Drupal\Tests\file\Kernel\FileManagedUnitTestBase
- class \Drupal\Tests\file\Kernel\FileManagedUnitTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of FileUrlTest
File
-
core/
modules/ file/ tests/ src/ Kernel/ FileUrlTest.php, line 12
Namespace
Drupal\Tests\file\KernelView source
class FileUrlTest extends FileManagedUnitTestBase {
/**
* Tests 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 = \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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.