You are here

class ExtensionsReportCase in Site Audit 8.2

Class ExtensionsReportCase.

@group commands

Hierarchy

Expanded class hierarchy of ExtensionsReportCase

File

tests/extensionsReportTest.php, line 16
Contains /site_audit/tests/ExtensionsReportCase.

Namespace

Unish
View source
class ExtensionsReportCase extends SiteAuditTestAbstract {

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

  /**
   * Check should pass on a default installation.
   */
  public function testDevPass() {
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS, $output->checks->SiteAuditCheckExtensionsDev->score);
  }

  /**
   * Enable a dev extension. Should Warn.
   */
  public function testDevWarn() {
    $this
      ->drush('pm-download', array(
      'ipsum',
    ), $this->options);
    $this
      ->drush('pm-enable', array(
      'ipsum',
    ), $this->options);
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN, $output->checks->SiteAuditCheckExtensionsDev->score);
  }

  /**
   * Check should pass on a default installation.
   */
  public function testUnrecommendedPass() {
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS, $output->checks->SiteAuditCheckExtensionsUnrecommended->score);
  }

  /**
   * Enable a unrecommended extension. Should Warn.
   */
  public function testUnrecommendedWarn() {
    $this
      ->drush('pm-download', array(
      'php',
    ), $this->options);
    $this
      ->drush('pm-enable', array(
      'php',
    ), $this->options);
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL, $output->checks->SiteAuditCheckExtensionsUnrecommended->score);
  }

  /**
   * Download Two copies of an extension. Check should warn.
   */
  public function testDuplicateWarn1() {
    $this
      ->drush('pm-download', array(
      'php',
    ), $this->options);
    $this
      ->drush('pm-download', array(
      'php',
    ), $this->options + array(
      'destination' => 'profiles',
    ));
    $this
      ->drush('pm-enable', array(
      'php',
    ), $this->options);
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN, $output->checks->SiteAuditCheckExtensionsDuplicate->score);
  }

  /**
   * Multiple versions of the same module, one in profile, not enabled. Warn.
   */
  public function testDuplicateWarn2() {
    \mkdir($this->options['root'] . '/profiles/standard');
    \mkdir($this->options['root'] . '/profiles/standard/modules');
    $this
      ->drush('pm-download', array(
      'rules-8.x-3.0-unstable4',
    ), $this->options);
    $this
      ->drush('pm-download', array(
      'rules-8.x-3.0-unstable3',
    ), $this->options + array(
      'destination' => 'profiles/standard/modules',
    ));
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN, $output->checks->SiteAuditCheckExtensionsDuplicate->score);
  }

  /**
   * Multiple versions of the same module, one in profile and enabled. Pass.
   */
  public function testDuplicatePass() {
    \mkdir($this->options['root'] . '/profiles/standard');
    \mkdir($this->options['root'] . '/profiles/standard/modules');
    $this
      ->drush('pm-download', array(
      'rules-8.x-3.0-unstable4',
    ), $this->options);
    $this
      ->drush('pm-download', array(
      'rules-8.x-3.0-unstable3',
    ), $this->options + array(
      'destination' => 'profiles/standard/modules',
    ));
    $this
      ->drush('pm-enable', array(
      'rules',
    ), $this->options);
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS, $output->checks->SiteAuditCheckExtensionsDuplicate->score);
  }

  /**
   * Multiple versions of the same module, higher one in profile and enabled.
   *
   * Check should Warn.
   */
  public function testDuplicateWarn3() {
    \mkdir($this->options['root'] . '/profiles/standard');
    \mkdir($this->options['root'] . '/profiles/standard/modules');
    $this
      ->drush('pm-download', array(
      'rules-8.x-3.0-unstable3',
    ), $this->options);
    $this
      ->drush('pm-download', array(
      'rules-8.x-3.0-unstable4',
    ), $this->options + array(
      'destination' => 'profiles/standard/modules',
    ));
    $this
      ->drush('pm-enable', array(
      'rules',
    ), $this->options);
    $this
      ->drush('audit-extensions', array(), $this->options + array(
      'detail' => NULL,
      'json' => NULL,
    ));
    $output = json_decode($this
      ->getOutput());
    $this
      ->assertEquals(\SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN, $output->checks->SiteAuditCheckExtensionsDuplicate->score);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExtensionsReportCase::setUp public function Sets up the environment for this test.
ExtensionsReportCase::testDevPass public function Check should pass on a default installation.
ExtensionsReportCase::testDevWarn public function Enable a dev extension. Should Warn.
ExtensionsReportCase::testDuplicatePass public function Multiple versions of the same module, one in profile and enabled. Pass.
ExtensionsReportCase::testDuplicateWarn1 public function Download Two copies of an extension. Check should warn.
ExtensionsReportCase::testDuplicateWarn2 public function Multiple versions of the same module, one in profile, not enabled. Warn.
ExtensionsReportCase::testDuplicateWarn3 public function Multiple versions of the same module, higher one in profile and enabled.
ExtensionsReportCase::testUnrecommendedPass public function Check should pass on a default installation.
ExtensionsReportCase::testUnrecommendedWarn public function Enable a unrecommended extension. Should Warn.
SiteAuditTestAbstract::setUpSiteAuditTestEnvironment public function Sets up environment for running site_audit tests.