function TaxonomyAccessTestCase::checkRoleConfig in Taxonomy Access Control 7
Asserts that a status column and "Configure" link is found for the role.
Parameters
array $statuses: An associative array of role statuses, keyed by role ID. Each item should be TRUE if the role is enabled, and FALSE otherwise.
2 calls to TaxonomyAccessTestCase::checkRoleConfig()
- TaxonomyAccessConfigTest::testRoleEnableDisable in ./
taxonomy_access.test - Tests enabling and disabling TAC for a custom role.
- TaxonomyAccessConfigTest::testSetUpCheck in ./
taxonomy_access.test - Tests the initial state of the test environment.
File
- ./
taxonomy_access.test, line 226 - Automated tests for the Taxonomy Access Control module.
Class
- TaxonomyAccessTestCase
- Provides a base test class and helper methods for automated tests.
Code
function checkRoleConfig(array $statuses) {
$roles = _taxonomy_access_user_roles();
// Log in as the administrator.
$this
->drupalLogout();
$this
->drupalLogin($this->users['site_admin']);
$this
->drupalGet(TAXONOMY_ACCESS_CONFIG);
foreach ($statuses as $rid => $status) {
// Assert that a "Configure" link is available for the role.
$this
->assertLinkByHref(TAXONOMY_ACCESS_CONFIG . "/role/{$rid}/edit", 0, t('"Configure" link is available for role %rid.', array(
'%rid' => $rid,
)));
}
// Retrieve the grant status table.
$shown = array();
$table = $this
->xpath('//table/tbody');
$table = reset($table);
// SimpleXML has fake arrays so we have to do this to get the data out.
foreach ($table->tr as $row) {
$tds = array();
foreach ($row->td as $value) {
$tds[] = (string) $value;
}
$shown[$tds[0]] = $tds[1];
}
foreach ($statuses as $rid => $status) {
// Assert that the form shows the passed status.
if ($status) {
$this
->assertTrue($shown[$roles[$rid]] == t('Enabled'), format_string('Role %role is enabled.', array(
'%role' => $rid,
)));
}
else {
$this
->assertTrue($shown[$roles[$rid]] == t('Disabled'), format_string('Role %role is disabled.', array(
'%role' => $rid,
)));
}
// Assert that a "Configure" link is available for the role.
$this
->assertLinkByHref(TAXONOMY_ACCESS_CONFIG . "/role/{$rid}/edit", 0, t('"Configure" link is available for role %rid.', array(
'%rid' => $rid,
)));
}
}