You are here

function SkinrUIBasicTestCase::testSkinEdit in Skinr 7.2

Same name and namespace in other branches
  1. 8.2 skinr_ui/src/Tests/skinr_ui.test \SkinrUIBasicTestCase::testSkinEdit()

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.

File

tests/skinr_ui.test, line 127
Tests for the Skinr UI module.

Class

SkinrUIBasicTestCase
Tests UI functionality.

Code

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