SecurityReviewTest.php in Security Review 8
File
tests/src/Kernel/SecurityReviewTest.php
View source
<?php
namespace Drupal\Tests\security_review\Kernel;
use Drupal\KernelTests\KernelTestBase;
class SecurityReviewTest extends KernelTestBase {
public static $modules = [
'security_review',
];
protected $securityReview;
protected function setUp() {
parent::setUp();
$this
->installConfig(static::$modules);
$this->securityReview = \Drupal::getContainer()
->get('security_review');
}
public function testConfigLogging() {
$this
->assertTrue($this->securityReview
->isLogging(), 'Logging enabled by default.');
$this->securityReview
->setLogging(FALSE);
$this
->assertFalse($this->securityReview
->isLogging(), 'Logging disabled.');
}
public function testConfigConfigured() {
$this
->assertFalse($this->securityReview
->isConfigured(), 'Not configured by default.');
$this->securityReview
->setConfigured(TRUE);
$this
->assertTrue($this->securityReview
->isConfigured(), 'Set to configured.');
}
public function testConfigUntrustedRoles() {
$this
->assertEquals([], $this->securityReview
->getUntrustedRoles(), 'untrusted_roles empty by default.');
$roles = [
0,
1,
2,
3,
4,
];
$this->securityReview
->setUntrustedRoles($roles);
$this
->assertEquals($roles, $this->securityReview
->getUntrustedRoles(), 'untrusted_roles set to test array.');
}
public function testConfigLastRun() {
$this
->assertEquals(0, $this->securityReview
->getLastRun(), 'last_run is 0 by default.');
$time = time();
$this->securityReview
->setLastRun($time);
$this
->assertEquals($time, $this->securityReview
->getLastRun(), 'last_run set to now.');
}
}