class SystemFilesTest
Tests system.files route.
Attributes
#[Group('routing')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\Routing\SystemFilesTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of SystemFilesTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Routing/ SystemFilesTest.php, line 15
Namespace
Drupal\FunctionalTests\RoutingView source
class SystemFilesTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function prepareSettings() : void {
parent::prepareSettings();
// Allow info files to be accessed by the `module` and `theme` stream
// wrappers.
$services_file = $this->siteDirectory . '/services.yml';
$this->assertFileExists($services_file);
$services = file_get_contents($services_file);
$services = Yaml::decode($services);
$services['parameters']['stream_wrapper.allowed_file_extensions'] = [
'module' => [
'yml',
],
'theme' => [
'yml',
],
];
file_put_contents($services_file, Yaml::encode($services));
}
/**
* Test theme and module stream wrappers are not available via system.files route.
*/
public function testExtensionStreamWrappers() : void {
$path = 'system/system.info.yml';
$this->assertFileExists('module://' . $path);
$this->drupalGet('/system/files/module', [
'query' => [
'file' => $path,
],
]);
$this->assertSession()
->statusCodeEquals(404);
$this->drupalGet('/system/files/module/' . $path);
$this->assertSession()
->statusCodeEquals(404);
$path = 'stark/stark.info.yml';
$this->assertFileExists('theme://' . $path);
$this->drupalGet('/system/files/theme', [
'query' => [
'file' => $path,
],
]);
$this->assertSession()
->statusCodeEquals(404);
$this->drupalGet('/system/files/theme/' . $path);
$this->assertSession()
->statusCodeEquals(404);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.