class SkinrUIBasicTestCase in Skinr 8.2
Same name and namespace in other branches
- 7.2 tests/skinr_ui.test \SkinrUIBasicTestCase
Tests UI functionality.
Hierarchy
- class \SkinrUITestCase extends \DrupalWebTestCase
- class \SkinrUIBasicTestCase
Expanded class hierarchy of SkinrUIBasicTestCase
File
- skinr_ui/
src/ Tests/ skinr_ui.test, line 112 - Tests for the Skinr UI module.
View source
class SkinrUIBasicTestCase extends SkinrUITestCase {
public static function getInfo() {
return array(
'name' => 'UI',
'description' => 'Tests basic Skinr UI functionality.',
'group' => 'Skinr',
);
}
/**
* Tests basic configuration and applying of a skin.
*
* @todo Remove the overly verbose inline comments after the Skinr development
* team has figured out how to write tests.
*/
function testSkinEdit() {
// Go to the front page, on which the user menu block should appear.
$this
->drupalGet('');
// Click the first (index 0) 'Edit skin' link on the page, which should be
// the link in the contextual links of the user menu block, since no other
// skinnable elements are visible on the page.
// For now, this is a simple way to assert and access Skinr links. In the
// future, we want to be more explicit in testing; i.e., verify that there
// is really only this link, its 'href' is correct, that it appears in the
// right location, etc.pp; DrupalWebTestCase ($this) provides many helper
// functions to assert such things.
$this
->clickLink(t('Edit skin'), 0);
// Verify that we end up on the expected URL to configure skins for the
// user menu block.
$front = variable_get('site_frontpage', 'node');
$this
->assertUrl('admin/structure/skinr/edit/block/system__user-menu/configure', array(
'query' => array(
'destination' => $front,
),
));
// skinr_ui_test.module got enabled in setUp(), so its skins should be
// available.
// Verify that we can apply the skinr_ui_test_border skin to the block.
$edit = array(
'skinr_settings[bartik][groups][general][skinr_ui_test_bgcolor]' => 'bgcolor_red',
);
// NULL means that we want to post to the page that is still contained in
// SimpleTest's internal browser; i.e., the page of the path above. Instead
// of passing NULL, you can also pass a Drupal system path and SimpleTest
// will automatically do a $this->drupalGet($path) for you before posting.
$this
->drupalPost(NULL, $edit, t('Save'));
// After posting, we expect to be redirected to the originating page, due
// to the 'destination' query parameter in the 'Edit skin' link. Since we
// came from the front page, Drupal will redirect us to the actual path of
// the front page, not ''.
// Verify that we were redirected to the originating page.
$this
->assertUrl($front);
// Verify that the skin has been applied.
$this
->assertSkinrClass('block-system-user-menu', 'bgcolor-red', 'CSS class of configured skin option found.');
}
/**
* Tests access control for editing additional CSS classes.
*/
function testSkinAdditionalEdit() {
// Verify that we can apply additional CSS classes.
$edit = array(
'skinr_settings[bartik][groups][_additional][_additional]' => 'additional',
);
$this
->drupalPost('admin/structure/skinr/edit/block/system__user-menu/configure', $edit, t('Save'));
// Verify that the skin has been applied.
$this
->drupalGet('');
$this
->assertSkinrClass('block-system-user-menu', 'additional', 'Additional CSS class <em>additional</em> of configured skin option found.');
// Now let's check the same for a user that has no access to alter this.
$user = $this
->drupalCreateUser(array(
'edit skin settings',
));
$this
->drupalLogin($user);
// Verify that the additional CSS classes field is not enabled.
$this
->drupalGet('admin/structure/skinr/edit/block/system__user-menu/configure');
$this
->assertNoFieldByName('skinr_settings[bartik][groups][_additional][_additional]', NULL, 'Additional CSS classes field is not enabled for this user.');
// Save form when additional CSS classes is not set.
$edit = array();
$this
->drupalPost(NULL, $edit, t('Save'));
// Verify that the old class is still applied.
$this
->drupalGet('');
$this
->assertSkinrClass('block-system-user-menu', 'additional', 'Additional CSS class <em>additional</em> of configured skin option found.');
}
/**
* Tests output of widgets on the skin configuration form.
*/
function testSkinEditWidgets() {
// Go to the edit page for system__user_menu block.
$this
->drupalGet('admin/structure/skinr/library');
$this
->drupalGet('admin/structure/skinr/edit/block/system__user-menu/configure');
// Check for output from empty groups.
$this
->assertNoRaw('id="edit-skinr-settings-block-group-bartik-box"', 'Resulting empty group is not displayed.');
// Check the widgets.
$this
->assertFieldByName('skinr_settings[bartik][groups][general][skinr_ui_test_bgcolor]', NULL, 'Widget with valid type is displayed.');
$this
->assertNoFieldByName('skinr_settings[bartik][groups][box][skinr_ui_test_border]', NULL, 'Widget with invalid type is not displayed.');
// Custom widget with form callback.
$this
->assertFieldByName('skinr_settings[bartik][groups][general][skinr_ui_test_custom][custom]', NULL, 'Widget with form callback is displayed.');
$this
->assertNoFieldChecked('edit-skinr-settings-bartik-groups-general-skinr-ui-test-custom-custom', 'Value for custom widget empty.');
// Now make sure default values work for custom widgets.
$skin = (object) array(
'theme' => 'bartik',
'module' => 'block',
'element' => 'system__user-menu',
'skin' => 'skinr_ui_test_custom',
'options' => array(
'custom',
),
'status' => 1,
);
skinr_skin_save($skin);
$this
->drupalGet('admin/structure/skinr/edit/block/system__user-menu/configure');
$this
->assertFieldChecked('edit-skinr-settings-bartik-groups-general-skinr-ui-test-custom-custom', 'Value for custom widget set.');
}
/**
* Tests access control for editing additional CSS classes.
*/
function testSkinEditThemeHooks() {
// Widget should appear for system blocks.
$this
->drupalGet('admin/structure/skinr/edit/block/system__user-menu/configure');
$this
->assertField('edit-skinr-settings-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to system blocks, appeared on the configuration form for system\'s user-menu block.');
// Widget should not appear search blocks.
$this
->drupalGet('admin/structure/skinr/edit/block/search__form/configure');
$this
->assertNoField('edit-skinr-settings-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to system blocks, did not appear on the configuration form for search\'s form block.');
// Widget should appear for page node comments.
$this
->drupalGet('admin/structure/skinr/edit/comment/page/configure');
$this
->assertField('edit-skinr-settings-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node comments, appeared on the configuration form for page node comments.');
// Widget should not appear for article node comments.
$this
->drupalGet('admin/structure/skinr/edit/comment/article/configure');
$this
->assertNoField('edit-skinr-settings-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node comments, did not appear on the configuration form for article node comments.');
// Widget should appear for page nodes.
$this
->drupalGet('admin/structure/skinr/edit/node/page/configure');
$this
->assertField('edit-skinr-settings-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node types, appeared on the configuration form for page node types.');
// Widget should not appear for article nodes.
$this
->drupalGet('admin/structure/skinr/edit/node/article/configure');
$this
->assertNoField('edit-skinr-settings-bartik-groups-general-skinr-ui-test-color-color-white', 'The widget, which is limited to page node types, did not appear on the configuration form for article node types.');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SkinrUIBasicTestCase:: |
public static | function | ||
SkinrUIBasicTestCase:: |
function | Tests access control for editing additional CSS classes. | ||
SkinrUIBasicTestCase:: |
function | Tests basic configuration and applying of a skin. | ||
SkinrUIBasicTestCase:: |
function | Tests access control for editing additional CSS classes. | ||
SkinrUIBasicTestCase:: |
function | Tests output of widgets on the skin configuration form. | ||
SkinrUITestCase:: |
protected | property | 1 | |
SkinrUITestCase:: |
function | Asserts that a class is not set for the given element id. | ||
SkinrUITestCase:: |
function | Asserts that a class is set for the given element id. | ||
SkinrUITestCase:: |
function | 2 |