class SkinrContextUIAdminTestCase in Skinr 8.2
Same name and namespace in other branches
- 7.2 skinr_context/tests/skinr_context_ui.test \SkinrContextUIAdminTestCase
Tests UI functionality.
Hierarchy
- class \SkinrUITestCase extends \DrupalWebTestCase
- class \SkinrContextUITestCase
- class \SkinrContextUIAdminTestCase
- class \SkinrContextUITestCase
Expanded class hierarchy of SkinrContextUIAdminTestCase
File
- skinr_context/
tests/ skinr_context_ui.test, line 156 - Tests for the Skinr UI module.
View source
class SkinrContextUIAdminTestCase extends SkinrContextUITestCase {
public static function getInfo() {
return array(
'name' => 'Context UI - Administration',
'description' => 'Tests administrative Skinr Context UI functionality.',
'dependencies' => array(
'ctools',
'context',
'context_ui',
),
'group' => 'Skinr',
);
}
function setUp() {
parent::setUp(array(
'skinr_test',
'skinr_context_test_default',
));
}
/**
* Tests skin configuration listing functionality.
*/
function testSkinListingWithGroups() {
$group = (object) array(
'gid' => 'block:system__user-menu:skinlistingwithgroup',
'module' => 'block',
'element' => 'system__user-menu',
'title' => 'SkinListingWithGroup',
'description' => '',
'conditions' => array(
'sitewide' => array(
'values' => array(
1 => 1,
),
),
),
'condition_mode' => CONTEXT_CONDITION_MODE_OR,
'weight' => 0,
'status' => 1,
);
skinr_context_group_save($group);
$skin = (object) array(
'theme' => 'skinr_test_subtheme',
'module' => 'block',
'element' => 'system__user-menu',
'gid' => $group->gid,
'skin' => 'skinr_test_subtheme',
'options' => array(
'option1',
'option2',
),
'status' => 1,
);
skinr_skin_save($skin);
// Verify that the skin configuration appears on the skin configurations overview page.
$this
->drupalGet('admin/structure/skinr');
$this
->assertLinkByHref(drupal_encode_path('admin/structure/skinr/edit/' . $skin->module . '/' . $skin->element . '/' . $skin->gid), 0, 'Skin configuration was found on overview page.');
// Test that revert link doesn't appear for default skin configurations.
$default_skin = skinr_skin_load_by_uuid('501ff0c3-db03-0944-9910-3a788f38097a');
$this
->verbose(highlight_string(print_r($default_skin, TRUE), TRUE));
$this
->assertNoLinkByHref('admin/structure/skinr/skin/' . $default_skin->sid . '/revert', 0, 'No revert operation is available for default skin configuration.');
// Test that delete link does not appear for default skin configurations.
$this
->assertNoLinkByHref('admin/structure/skinr/skin/' . $default_skin->sid . '/delete', 0, 'No delete operation is available for default skin configuration.');
// Test that revert link appears for skin configurations in code that are
// overridden in databse.
$default_skin->options = array(
'options3',
);
skinr_skin_save($default_skin);
$this
->drupalGet('admin/structure/skinr');
$this
->assertLinkByHref('admin/structure/skinr/skin/' . $default_skin->sid . '/revert', 0, 'Revert operation is available for overridden skin configuration.');
// Test that delete link does not appear for overridden skin configurations.
$this
->assertNoLinkByHref('admin/structure/skinr/skin/' . $default_skin->sid . '/delete', 0, 'No delete operation is available for overridden skin configuration.');
// Test reverting overridden skin.
$this
->clickLink(t('revert'), 0);
$edit = array(
'skinr_settings[bartik][groups][_additional][_additional]' => 'additional',
);
$this
->drupalPost(NULL, array(), t('Revert'));
// Load an uncached version of the skin configuration object.
$default_skin = entity_load('skin', $default_skin->sid, TRUE);
$this
->assertTrue(skinr_skin_storage($default_skin) == SKINR_STORAGE_IN_CODE, 'Overridden skin configuration was reverted to default.');
// @todo Should we check the filtering and update options functionality?
}
/**
* Tests skin configuration and group import and export forms.
*/
function testGroupSkinImportExport() {
$this
->drupalGet('admin/structure/skinr/import');
$gid1 = 'node:page:default';
$gid2 = 'block:user__online:default';
$uuid1 = '16daa322-5ac0-49e4-cda2-809a13bb965b';
$uuid2 = '7384adb8-50a8-67d4-2dcd-5acda9b5c76e';
$edit = array(
'skinr_groups' => "\$group = new stdClass();\n\$group->status = TRUE; /* Edit this to false to make a default group disabled initially */\n\$group->api_version = " . SKINR_VERSION . ";\n\$group->gid = '" . $gid1 . "';\n\$group->module = 'block';\n\$group->element = 'system__main';\n\$group->title = 'Default';\n\$group->description = '';\n\$group->conditions = array(\n 'sitewide' => array(\n 'values' => array(\n 1 => 1,\n ),\n ),\n);\n\$group->condition_mode = 0;\n\$group->weight = 0;\n\$groups['" . $gid1 . "'] = \$group;\n\n\$group = new stdClass();\n\$group->status = TRUE; /* Edit this to false to make a default group disabled initially */\n\$group->api_version = " . SKINR_VERSION . ";\n\$group->gid = '" . $gid2 . "';\n\$group->module = 'block';\n\$group->element = 'system__user-menu';\n\$group->title = 'Default';\n\$group->description = 'Default export description.';\n\$group->conditions = array(\n 'sitewide' => array(\n 'values' => array(\n 1 => 1,\n ),\n ),\n);\n\$group->condition_mode = 0;\n\$group->weight = 0;\n\$groups['" . $gid2 . "'] = \$group;\n",
'skinr_skins' => "\$skin = new stdClass();\n\$skin->status = TRUE; /* Edit this to false to make a default skin disabled initially */\n\$skin->api_version = " . SKINR_VERSION . ";\n\$skin->uuid = '" . $uuid1 . "';\n\$skin->theme = 'bartik';\n\$skin->module = 'block';\n\$skin->element = 'system__main';\n\$skin->skin = 'skinr_test_example';\n\$skin->options = array(\n 'option1' => 'option1',\n);\n\$skin->gid = '" . $gid1 . "';\n\$skins['" . $uuid1 . "'] = \$skin;\n\n\$skin = new stdClass();\n\$skin->status = TRUE; /* Edit this to false to make a default skin disabled initially */\n\$skin->api_version = " . SKINR_VERSION . ";\n\$skin->uuid = '" . $uuid2 . "';\n\$skin->theme = 'bartik';\n\$skin->module = 'block';\n\$skin->element = 'system__user-menu';\n\$skin->skin = 'skinr_test_subtheme';\n\$skin->options = array(\n 'option1' => 'option1',\n 'option2' => 'option2',\n);\n\$skin->gid = '" . $gid2 . "';\n\$skins['" . $uuid2 . "'] = \$skin;\n",
);
$this
->drupalPost(NULL, $edit, t('Import'));
// Now check if the imported skin configuration groups exist.
$group1 = skinr_context_group_load($gid1);
$group2 = skinr_context_group_load($gid2);
$this
->assertTrue(isset($group1->gid) && $group1->gid == $gid1 && isset($group2->gid) && $group2->gid == $gid2, 'Successfully imported skin configuration groups.');
// Now check if the imported skin configurations exist.
$skin1 = skinr_skin_load_by_uuid($uuid1);
$skin2 = skinr_skin_load_by_uuid($uuid2);
$this
->assertTrue(isset($skin1->uuid) && $skin1->uuid == $uuid1 && $skin1->gid == $gid1 && isset($skin2->uuid) && $skin2->uuid == $uuid2 && $skin2->gid == $gid2, 'Successfully imported skin configurations with linked groups.');
// Test export.
$this
->drupalGet('admin/structure/skinr/export');
$this
->drupalPost(NULL, array(
'theme' => 'bartik',
), t('Export'));
$this
->assertFieldByName('skinr_groups', $edit['skinr_groups'], 'Skin configuration group export value is correct.');
$this
->assertFieldByName('skinr_skins', $edit['skinr_skins'], 'Skin configuration export value is correct.');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SkinrContextUIAdminTestCase:: |
public static | function | ||
SkinrContextUIAdminTestCase:: |
function |
Overrides SkinrContextUITestCase:: |
||
SkinrContextUIAdminTestCase:: |
function | Tests skin configuration and group import and export forms. | ||
SkinrContextUIAdminTestCase:: |
function | Tests skin configuration listing functionality. | ||
SkinrContextUITestCase:: |
protected | property |
Overrides SkinrUITestCase:: |
|
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. |