You are here

function SkinrContextUIBasicTestCase::testGroupList in Skinr 7.2

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

Tests basic configuration and applying of a skin.

File

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

Class

SkinrContextUIBasicTestCase
Tests UI functionality.

Code

function testGroupList() {

  // Add a group.
  $group = (object) array(
    'gid' => 'block:system__user-menu:default',
    'module' => 'block',
    'element' => 'system__user-menu',
    'title' => 'Default',
    'description' => '',
    'conditions' => array(
      'sitewide' => array(
        'values' => array(
          1 => 1,
        ),
      ),
    ),
    'condition_mode' => CONTEXT_CONDITION_MODE_OR,
    'weight' => 0,
    'status' => 1,
  );
  skinr_context_group_save($group);
  $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.
  $this
    ->clickLink(t('Edit skin'), 0);

  // Verify that we end up on the expected URL.
  $front = variable_get('site_frontpage', 'node');
  $this
    ->assertUrl('admin/structure/skinr/edit/block/system__user-menu/configure', array(
    'query' => array(
      'destination' => $front,
    ),
  ));

  // Make sure the group list is showing instead of the skin settings edit page.
  $this
    ->assertText('Skin settings group', 'Skin settings groups are listed.');

  // Click the first 'edit' link which should bring us to the group's edit
  // skin settings page.
  $this
    ->clickLink(t('edit'), 0);

  // Verify that we end up on the expected URL to configure skins for our group.
  $this
    ->assertUrl('admin/structure/skinr/edit/block/system__user-menu/' . $group->gid, array(
    'query' => array(
      'destination' => 'admin/structure/skinr/edit/block/system__user-menu/configure?destination=' . $front,
    ),
  ));

  // Verify that we can apply the skinr_ui_test_border skin to the block, and
  // limit the groups visibility to the front page.
  $edit = array(
    'skinr_group[title]' => 'SkinrContextGroupTitle',
    'skinr_group[description]' => 'SkinrContextGroupDescription',
    'skinr_settings[bartik][groups][general][skinr_ui_test_bgcolor]' => 'bgcolor_red',
    'conditions[state]' => 'path',
    'conditions[plugins][path][values]' => '<front>',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Verify that we were redirected back to the originating page.
  $this
    ->assertUrl('admin/structure/skinr/edit/block/system__user-menu/configure', array(
    'query' => array(
      'destination' => $front,
    ),
  ));

  // Make sure the group title and description were updated.
  $this
    ->assertText('SkinrContextGroupTitle', 'Skin settings group title was updated.');
  $this
    ->assertText('SkinrContextGroupDescription', 'Skin settings group description was updated.');

  // Click the done link.
  $this
    ->clickLink(t('Done'), 0);

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

  // Verify that the skin has only been applied to the front page.
  $this
    ->drupalGet('user');
  $this
    ->assertNoSkinrClass('block-system-user-menu', 'bgcolor-red', 'CSS class of configured skin option not found on other pages.');
}