You are here

class UsersReportCase in Site Audit 8.2

Class UsersReportCase.

@group commands

Hierarchy

Expanded class hierarchy of UsersReportCase

File

tests/usersReportTest.php, line 16
Contains /site_audit/tests/UsersReportCase.

Namespace

Unish
View source
class UsersReportCase extends SiteAuditTestAbstract {

  /**
   * Sets up the environment for this test.
   */
  public function setUp() {
    $this
      ->setUpSiteAuditTestEnvironment();
  }

  /**
   * Block the user with uid 1. Check should Fail.
   */
  public function testBlockedNumberOneFail() {
    $this
      ->drush('user-block', array(
      1,
    ), $this->options);
    $this
      ->drush('audit-users', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL, $output->checks->SiteAuditCheckUsersBlockedNumberOne->score);
  }

  /**
   * UnBlock the user with uid 1. Check should Pass.
   */
  public function testBlockedNumberOnePass() {
    $this
      ->drush('user-unblock', array(
      1,
    ), $this->options);
    $this
      ->drush('audit-users', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS, $output->checks->SiteAuditCheckUsersBlockedNumberOne->score);
  }

  /**
   * Delete user with uid 1. Check should Fail.
   */
  public function testWhoIsNumberOneFail() {
    $this
      ->drush('user-cancel', array(
      1,
    ), $this->options);

    // Add a new user so that user count is not zero which will cause CountAll
    // test to abort this report.
    $this
      ->drush('user-create', array(
      'site_audit',
    ), $this->options + array(
      'mail' => 'person@example.com',
      'password' => 'site_audit',
    ));
    $this
      ->drush('audit-users', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL, $output->checks->SiteAuditCheckUsersWhoIsNumberOne->score);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SiteAuditTestAbstract::setUpSiteAuditTestEnvironment public function Sets up environment for running site_audit tests.
UsersReportCase::setUp public function Sets up the environment for this test.
UsersReportCase::testBlockedNumberOneFail public function Block the user with uid 1. Check should Fail.
UsersReportCase::testBlockedNumberOnePass public function UnBlock the user with uid 1. Check should Pass.
UsersReportCase::testWhoIsNumberOneFail public function Delete user with uid 1. Check should Fail.