You are here

public function TaxonomyAccessWeightTest::testWeight in Taxonomy Access Control 7

Verifies that this module is weighted below the Taxonomy module.

File

./taxonomy_access.test, line 1520
Automated tests for the Taxonomy Access Control module.

Class

TaxonomyAccessWeightTest

Code

public function testWeight() {

  // Verify weight.
  $tax_weight = db_query("SELECT weight FROM {system}\n         WHERE name = 'taxonomy'")
    ->fetchField();
  $tax_access_weight = db_query("SELECT weight FROM {system}\n         WHERE name = 'taxonomy_access'")
    ->fetchField();
  $this
    ->assertTrue($tax_access_weight > $tax_weight, t("Weight of this module is @tax_access_weight. Weight of the Taxonomy module is @tax_weight.", array(
    '@tax_access_weight' => $tax_access_weight,
    '@tax_weight' => $tax_weight,
  )));

  // Disable module and set weight of the Taxonomy module to a high number.
  module_disable(array(
    'taxonomy_access',
  ), TRUE);
  db_update('system')
    ->fields(array(
    'weight' => rand(5000, 9000),
  ))
    ->condition('name', 'taxonomy')
    ->execute();

  // Re-enable module and re-verify weight.
  module_enable(array(
    'taxonomy_access',
  ), TRUE);
  $tax_weight = db_query("SELECT weight FROM {system}\n         WHERE name = 'taxonomy'")
    ->fetchField();
  $tax_access_weight = db_query("SELECT weight FROM {system}\n         WHERE name = 'taxonomy_access'")
    ->fetchField();
  $this
    ->assertTrue($tax_access_weight > $tax_weight, t("Weight of this module is @tax_access_weight. Weight of the Taxonomy module is @tax_weight.", array(
    '@tax_access_weight' => $tax_access_weight,
    '@tax_weight' => $tax_weight,
  )));
}