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