DefaultContentFilesAccessTest.php in Drupal 9
File
core/profiles/demo_umami/modules/demo_umami_content/tests/src/Functional/DefaultContentFilesAccessTest.php
View source
<?php
namespace Drupal\Tests\demo_umami_content\Functional;
use Drupal\Tests\BrowserTestBase;
class DefaultContentFilesAccessTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public function testAccessDeniedToFiles() {
$this
->assertNotSame('demo_umami', \Drupal::installProfile());
$files_to_test = [
'images/heritage-carrots.jpg',
'languages/en/recipe_instructions/mediterranean-quiche-umami.html',
'languages/en/article_body/lets-hear-it-for-carrots.html',
'languages/en/node/article.csv',
];
foreach ($files_to_test as $file) {
$content_path = "core/profiles/demo_umami/modules/demo_umami_content/default_content/{$file}";
$this
->assertFileExists($this->root . '/' . $content_path);
$this
->drupalGet($content_path);
$this
->assertSession()
->statusCodeEquals(403);
}
}
}