You are here

public function SecurityReviewTestCase::testCheckResults in Security Review 7

File

tests/security_review.test, line 93
security_review.test. Drupal test cases for Security Review.

Class

SecurityReviewTestCase
Tests the functionality of the Security Review module.

Code

public function testCheckResults() {
  $checklist = security_review_get_checklist();
  $secrev_checks = $checklist['security_review'];

  // Assert that all checks return expected format.
  foreach ($secrev_checks as $name => $check) {
    $callback = $check['callback'];
    $return = $callback();
    $this
      ->assertTrue(is_array($return), "Check {$name} returns an array");
    $this
      ->assertTrue(array_key_exists('result', $return), "Check {$name} has key 'result'");
  }

  // Note, not all checks can be tested (such as file permission checks)
  // because of the shared dependencies of simpletest with the host.
  // Test text formats check.
  $check = security_review_check_input_formats();
  $this
    ->assertTrue($check['result'], 'Text formats check passes');

  // No content yet submitted.
  $check = security_review_check_field();
  $this
    ->assertTrue($check['result'], 'Unsafe content in fields check passes');

  // Error reporting defaults to screen.
  $check = security_review_check_error_reporting();
  $this
    ->assertFalse($check['result'], 'Error reporting check fails');

  // Failed logins is null.
  $check = security_review_check_failed_logins();
  $this
    ->assertTrue(is_null($check['result']), 'Failed logins check is null');

  // Upload extensions passes.
  $check = security_review_check_upload_extensions();
  $this
    ->assertTrue($check['result'], 'Upload extensions check passes');

  // No admin permissions granted.
  $check = security_review_check_admin_permissions();
  $this
    ->assertTrue($check['result'], 'Admin permission check passes');
}