public function SpacesDashboardTestCase::testSettings in Spaces 7
Same name and namespace in other branches
- 6.3 spaces_dashboard/tests/spaces_dashboard.test \SpacesDashboardTestCase::testSettings()
- 7.3 spaces_dashboard/tests/spaces_dashboard.test \SpacesDashboardTestCase::testSettings()
Test that block accessibility settings work properly.
File
- spaces_dashboard/
tests/ spaces_dashboard.test, line 55
Class
Code
public function testSettings() {
// Enable dashboard feature
$edit = array(
'spaces_features[spaces_dashboard]' => 1,
);
$this
->drupalPost('features', $edit, t('Save configuration'));
$this
->assertText('The configuration options have been saved.');
// Enable core blocks for use with dashboard
$enabled = array(
'node-syndicate' => t('Syndicate'),
'user-login' => t('User login'),
);
$disabled = array(
'system-help' => t('System help'),
);
$edit = array();
foreach (array_keys($enabled) as $bid) {
$edit["spaces_dashboard_blocks[{$bid}]"] = 1;
}
$this
->drupalPost('features/spaces_dashboard', $edit, t('Save configuration'));
// Check that the variable was saved correctly.
$dashboard_blocks = variable_get('spaces_dashboard_blocks', array());
foreach (array_keys($enabled) as $bid) {
$this
->assertTrue($dashboard_blocks[$bid], t('Block settings saved correctly for @bid', array(
'@bid' => $bid,
)));
}
foreach (array_keys($disabled) as $bid) {
$this
->assertFalse($dashboard_blocks[$bid], t('Block settings saved correctly for @bid', array(
'@bid' => $bid,
)));
}
// Check that only the enabled blocks are available on the dashboard editor block.
$output = $this
->drupalGet('dashboard');
$this
->pass($output);
$this
->assertText('Dashboard', t('Dashboard'));
foreach ($enabled as $label) {
$this
->assertRaw($label, t('Block @label found.', array(
'@label' => $label,
)));
}
foreach ($disabled as $label) {
$this
->assertNoRaw($label, t('Block @label not usable.', array(
'@label' => $label,
)));
}
// @TODO: This XPath check does not work for some reason. Hard to tell why...
// $active = $this->xpath('//*[@id = "block-spaces_dashboard-editor"]//div[text() = "Syndicate"]');
// $this->assertTrue(!empty($active), t('Block Syndicate found.'));
}