Including security review as a submodule - with patched for Yaffs.
[yaffs-website] / web / modules / contrib / security_review / src / Tests / CheckWebTest.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\security_review\Tests\CheckWebTest.
6  */
7
8 namespace Drupal\security_review\Tests;
9
10 use Drupal\simpletest\WebTestBase;
11
12 /**
13  * Contains tests for Check that don't suffice with KernelTestBase.
14  *
15  * @group security_review
16  */
17 class CheckWebTest extends WebTestBase {
18
19   /**
20    * Modules to enable.
21    *
22    * @var array
23    */
24   public static $modules = ['security_review'];
25
26   /**
27    * The security checks defined by Security Review.
28    *
29    * @var \Drupal\security_review\Check[]
30    */
31   protected $checks;
32
33   /**
34    * The test user.
35    *
36    * @var \Drupal\user\Entity\User
37    */
38   protected $user;
39
40   /**
41    * Sets up the testing environment, logs the user in, populates $check.
42    */
43   protected function setUp() {
44     parent::setUp();
45
46     // Login.
47     $this->user = $this->drupalCreateUser(
48       [
49         'run security checks',
50         'access security review list',
51         'access administration pages',
52         'administer site configuration',
53       ]
54     );
55     $this->drupalLogin($this->user);
56
57     // Get checks.
58     $this->checks = security_review_security_review_checks();
59   }
60
61   /**
62    * Tests Check::skip().
63    *
64    * Checks whether skip() marks the check as skipped, and checks the
65    * skippedBy() value.
66    */
67   public function testSkipCheck() {
68     foreach ($this->checks as $check) {
69       $check->skip();
70
71       $is_skipped = $check->isSkipped();
72       $skipped_by = $check->skippedBy();
73
74       $this->assertTrue($is_skipped, $check->getTitle() . ' skipped.');
75       $this->assertEqual($this->user->id(), $skipped_by->id(), 'Skipped by ' . $skipped_by->label());
76     }
77   }
78
79 }