X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fsecurity_review%2Fsrc%2FTests%2FChecklistWebTest.php;fp=web%2Fmodules%2Fcontrib%2Fsecurity_review%2Fsrc%2FTests%2FChecklistWebTest.php;h=87fa67943be3f9425984f60b672f681f35204266;hp=0000000000000000000000000000000000000000;hb=ba1b5c55c66590c41ccc9844d3e62391b0399abb;hpb=93ef30d42f68e55d11d97312531118bbcd4cf318 diff --git a/web/modules/contrib/security_review/src/Tests/ChecklistWebTest.php b/web/modules/contrib/security_review/src/Tests/ChecklistWebTest.php new file mode 100644 index 000000000..87fa67943 --- /dev/null +++ b/web/modules/contrib/security_review/src/Tests/ChecklistWebTest.php @@ -0,0 +1,104 @@ +checklist = \Drupal::getContainer() + ->get('security_review.checklist'); + + // Login. + $this->user = $this->drupalCreateUser( + [ + 'run security checks', + 'access security review list', + 'access administration pages', + 'administer site configuration', + ] + ); + $this->drupalLogin($this->user); + + // Populate $checks. + $this->checks = security_review_security_review_checks(); + + // Clear cache. + Checklist::clearCache(); + } + + /** + * Tests a full checklist run. + * + * Tests whether the checks hasn't been run yet, then runs them and checks + * that their lastRun value is not 0. + */ + 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.'); + } + } + + /** + * Skips all checks then runs the checklist. No checks should be ran. + */ + 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.'); + } + } + +}