You are here

function SkinrContextUIAdminTestCase::testSkinListingWithGroups in Skinr 7.2

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

Tests skin configuration listing functionality.

File

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

Class

SkinrContextUIAdminTestCase
Tests UI functionality.

Code

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 = skinr_skin_load_unchanged($default_skin->sid);
  $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?
}