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