class FileSaveHtaccessLoggingTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php \Drupal\Tests\system\Functional\File\FileSaveHtaccessLoggingTest
- 10 core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php \Drupal\Tests\system\Functional\File\FileSaveHtaccessLoggingTest
- 9 core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php \Drupal\Tests\system\Functional\File\FileSaveHtaccessLoggingTest
- 8.9.x core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php \Drupal\Tests\system\Functional\File\FileSaveHtaccessLoggingTest
Tests the log message added by the HtaccessWriter service.
Attributes
#[Group('File')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\DrupalTestCaseTrait, \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\Tests\system\Functional\File\FileSaveHtaccessLoggingTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of FileSaveHtaccessLoggingTest
File
-
core/
modules/ system/ tests/ src/ Functional/ File/ FileSaveHtaccessLoggingTest.php, line 15
Namespace
Drupal\Tests\system\Functional\FileView source
class FileSaveHtaccessLoggingTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'dblog',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the HtaccessWriter service write functionality.
*/
public function testHtaccessSave() : void {
// Prepare test directories.
$private = $this->publicFilesDirectory . '/test/private';
// Verify that HtaccessWriter service returns FALSE if .htaccess cannot be
// written and writes a correctly formatted message to the error log.
// Set $private to TRUE so all possible .htaccess lines are written.
/** @var \Drupal\Core\File\HtaccessWriterInterface $htaccess */
$htaccess = \Drupal::service('file.htaccess_writer');
$this->assertFalse($htaccess->write($private, TRUE));
$this->drupalLogin($this->drupalCreateUser([
'access site reports',
]));
$this->drupalGet('admin/reports/dblog');
$this->clickLink("Security warning: Couldn't write .htaccess file.");
$lines = FileSecurity::htaccessLines(TRUE);
foreach (array_filter(explode("\n", $lines)) as $line) {
$this->assertSession()
->assertEscaped($line);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.