5 * Contains \Drupal\security_review\Tests\ChecklistWebTest.
8 namespace Drupal\security_review\Tests;
10 use Drupal\security_review\Checklist;
11 use Drupal\simpletest\WebTestBase;
14 * Contains tests related to the SecurityReview class.
16 * @group security_review
18 class ChecklistWebTest extends WebTestBase {
25 public static $modules = ['security_review'];
30 * @var \Drupal\user\Entity\User
35 * The security checks defined by Security Review.
37 * @var \Drupal\security_review\Check[]
42 * The security_review.checklist service.
44 * @var \Drupal\security_review\Checklist
49 * Sets up the testing environment.
51 protected function setUp() {
54 $this->checklist = \Drupal::getContainer()
55 ->get('security_review.checklist');
58 $this->user = $this->drupalCreateUser(
60 'run security checks',
61 'access security review list',
62 'access administration pages',
63 'administer site configuration',
66 $this->drupalLogin($this->user);
69 $this->checks = security_review_security_review_checks();
72 Checklist::clearCache();
76 * Tests a full checklist run.
78 * Tests whether the checks hasn't been run yet, then runs them and checks
79 * that their lastRun value is not 0.
81 public function testRun() {
82 foreach ($this->checks as $check) {
83 $this->assertEqual(0, $check->lastRun(), $check->getTitle() . ' has not been run yet.');
85 $this->checklist->runChecklist();
86 foreach ($this->checks as $check) {
87 $this->assertNotEqual(0, $check->lastRun(), $check->getTitle() . ' has been run.');
92 * Skips all checks then runs the checklist. No checks should be ran.
94 public function testSkippedRun() {
95 foreach ($this->checks as $check) {
98 $this->checklist->runChecklist();
99 foreach ($this->checks as $check) {
100 $this->assertEqual(0, $check->lastRun(), $check->getTitle() . ' has not been run.');