More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / modules / contrib / security_review / src / Tests / CheckWebTest.php
diff --git a/web/modules/contrib/security_review/src/Tests/CheckWebTest.php b/web/modules/contrib/security_review/src/Tests/CheckWebTest.php
new file mode 100644 (file)
index 0000000..1f8a452
--- /dev/null
@@ -0,0 +1,74 @@
+<?php
+
+namespace Drupal\security_review\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Contains tests for Check that don't suffice with KernelTestBase.
+ *
+ * @group security_review
+ */
+class CheckWebTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['security_review'];
+
+  /**
+   * The security checks defined by Security Review.
+   *
+   * @var \Drupal\security_review\Check[]
+   */
+  protected $checks;
+
+  /**
+   * The test user.
+   *
+   * @var \Drupal\user\Entity\User
+   */
+  protected $user;
+
+  /**
+   * Sets up the testing environment, logs the user in, populates $check.
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Login.
+    $this->user = $this->drupalCreateUser(
+      [
+        'run security checks',
+        'access security review list',
+        'access administration pages',
+        'administer site configuration',
+      ]
+    );
+    $this->drupalLogin($this->user);
+
+    // Get checks.
+    $this->checks = security_review_security_review_checks();
+  }
+
+  /**
+   * Tests Check::skip().
+   *
+   * Checks whether skip() marks the check as skipped, and checks the
+   * skippedBy() value.
+   */
+  public function testSkipCheck() {
+    foreach ($this->checks as $check) {
+      $check->skip();
+
+      $is_skipped = $check->isSkipped();
+      $skipped_by = $check->skippedBy();
+
+      $this->assertTrue($is_skipped, $check->getTitle() . ' skipped.');
+      $this->assertEqual($this->user->id(), $skipped_by->id(), 'Skipped by ' . $skipped_by->label());
+    }
+  }
+
+}