Including security review as a submodule - with patched for Yaffs.
[yaffs-website] / web / modules / contrib / security_review / src / Tests / SecurityReviewTest.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\security_review\Tests\SecurityReviewTest.
6  */
7
8 namespace Drupal\security_review\Tests;
9
10 use Drupal\simpletest\KernelTestBase;
11
12 /**
13  * Contains tests related to the SecurityReview class.
14  *
15  * @group security_review
16  */
17 class SecurityReviewTest extends KernelTestBase {
18
19   /**
20    * Modules to enable.
21    *
22    * @var array
23    */
24   public static $modules = ['security_review'];
25
26   /**
27    * The security_review service.
28    *
29    * @var \Drupal\security_review\SecurityReview
30    */
31   protected $securityReview;
32
33   /**
34    * Sets up the testing environment.
35    */
36   protected function setUp() {
37     parent::setUp();
38     $this->installConfig(static::$modules);
39     $this->securityReview = \Drupal::getContainer()->get('security_review');
40   }
41
42   /**
43    * Tests the 'logging' setting.
44    */
45   public function testConfigLogging() {
46     $this->assertTrue($this->securityReview->isLogging(), 'Logging enabled by default.');
47     $this->securityReview->setLogging(FALSE);
48     $this->assertFalse($this->securityReview->isLogging(), 'Logging disabled.');
49   }
50
51   /**
52    * Tests the 'configured' setting.
53    */
54   public function testConfigConfigured() {
55     $this->assertFalse($this->securityReview->isConfigured(), 'Not configured by default.');
56     $this->securityReview->setConfigured(TRUE);
57     $this->assertTrue($this->securityReview->isConfigured(), 'Set to configured.');
58   }
59
60   /**
61    * Tests the 'untrusted_roles' setting.
62    */
63   public function testConfigUntrustedRoles() {
64     $this->assertEqual($this->securityReview->getUntrustedRoles(), [], 'untrusted_roles empty by default.');
65
66     $roles = [0, 1, 2, 3, 4];
67     $this->securityReview->setUntrustedRoles($roles);
68     $this->assertEqual($roles, $this->securityReview->getUntrustedRoles(), 'untrusted_roles set to test array.');
69   }
70
71   /**
72    * Tests the 'last_run' setting.
73    */
74   public function testConfigLastRun() {
75     $this->assertEqual(0, $this->securityReview->getLastRun(), 'last_run is 0 by default.');
76     $time = time();
77     $this->securityReview->setLastRun($time);
78     $this->assertEqual($time, $this->securityReview->getLastRun(), 'last_run set to now.');
79   }
80
81 }