ChecklistWebTest.php in Security Review 8
File
tests/src/Functional/ChecklistWebTest.php
View source
<?php
namespace Drupal\Tests\security_review\Functional;
use Drupal\security_review\Checklist;
use Drupal\Tests\BrowserTestBase;
class ChecklistWebTest extends BrowserTestBase {
public static $modules = [
'security_review',
];
protected $user;
protected $checks;
protected $checklist;
protected function setUp() {
parent::setUp();
$this->checklist = \Drupal::getContainer()
->get('security_review.checklist');
$this->user = $this
->drupalCreateUser([
'run security checks',
'access security review list',
'access administration pages',
'administer site configuration',
]);
$this
->drupalLogin($this->user);
$this->checks = security_review_security_review_checks();
Checklist::clearCache();
}
public function testRun() {
foreach ($this->checks as $check) {
$this
->assertEqual(0, $check
->lastRun(), $check
->getTitle() . ' has not been run yet.');
}
$this->checklist
->runChecklist();
foreach ($this->checks as $check) {
$this
->assertNotEqual(0, $check
->lastRun(), $check
->getTitle() . ' has been run.');
}
}
public function testSkippedRun() {
foreach ($this->checks as $check) {
$check
->skip();
}
$this->checklist
->runChecklist();
foreach ($this->checks as $check) {
$this
->assertEqual(0, $check
->lastRun(), $check
->getTitle() . ' has not been run.');
}
}
}