You are here

function FusionApplyUIBasicTestCase::testSkinEdit in Fusion Accelerator 7

Same name and namespace in other branches
  1. 7.2 fusion_apply/tests/fusion_apply_ui.test \FusionApplyUIBasicTestCase::testSkinEdit()

Tests basic configuration and applying of a skin.

@todo For some reason, contextual links are not visible in the debug output when running tests; likely a core bug in contextual.js. However, the links are contained in the output. Keep this in mind when manually reviewing the debug output after running tests! @todo Remove the overly verbose inline comments after the Fusion Apply development team has figured out how to write tests.

File

fusion_apply/tests/fusion_apply_ui.test, line 119
Tests for the Fusion Apply UI module.

Class

FusionApplyUIBasicTestCase
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 Fusion Apply 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/appearance/fusion/edit/nojs/block/system__user-menu/configure', array(
    'query' => array(
      'destination' => $front,
    ),
  ));

  // fusion_apply_test.module got enabled in setUp(), so its skins should be
  // available.
  // Verify that we can apply the fusion_apply_test_font skin to the block.
  $edit = array(
    'fusion_apply_settings[block_group][bartik][groups][typography][fusion_apply_test_font]' => 'font_1',
  );

  // 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
    ->assertFusionApplyClass('block-system-user-menu', 'font-1', 'CSS class of configured skin option found.');
}