You are here

function SkinrContextUIAdminTestCase::testGroupSkinImportExport in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_context/tests/skinr_context_ui.test \SkinrContextUIAdminTestCase::testGroupSkinImportExport()

Tests skin configuration and group import and export forms.

File

skinr_context/tests/skinr_context_ui.test, line 237
Tests for the Skinr UI module.

Class

SkinrContextUIAdminTestCase
Tests UI functionality.

Code

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.');
}