b12149190db42558f01d214e308e66104113da24
[yaffs-website] / web / core / profiles / demo_umami / modules / demo_umami_content / tests / src / Functional / DefaultContentFilesAccessTest.php
1 <?php
2
3 namespace Drupal\Tests\demo_umami_content\Functional;
4
5 use Drupal\Core\Site\Settings;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Tests that files provided by demo_umami_content are not accessible.
10  *
11  * @group demo_umami_content
12  */
13 class DefaultContentFilesAccessTest extends BrowserTestBase {
14
15   /**
16    * Tests that sample images, recipes and articles are not accessible.
17    */
18   public function testAccessDeniedToFiles() {
19     // The demo_umami profile should not be used because we want to ensure that
20     // if you install another profile these files are not available.
21     $this->assertNotSame('demo_umami', Settings::get('install_profile'));
22
23     $files_to_test = [
24       'images/chocolate-brownie-umami.jpg',
25       'recipe_instructions/chocolate-brownie-umami.html',
26       'article_body/lets-hear-it-for-carrots.html',
27       'articles.csv',
28     ];
29     foreach ($files_to_test as $file) {
30       // Hard code the path since the demo_umami profile is not installed.
31       $content_path = "core/profiles/demo_umami/modules/demo_umami_content/default_content/$file";
32       $this->assertFileExists($this->root . '/' . $content_path);
33       $this->drupalGet($content_path);
34       $this->assertSession()->statusCodeEquals(403);
35     }
36   }
37
38 }