You are here

function SkinrUIAdminTestCase::testSkinListing in Skinr 7.2

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

Tests skin configuration listing functionality.

File

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

Class

SkinrUIAdminTestCase
Tests administrative pages functionality.

Code

function testSkinListing() {
  $skin = (object) array(
    'theme' => 'skinr_test_subtheme',
    'module' => 'block',
    'element' => 'system__user-menu',
    '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('admin/structure/skinr/skin/' . $skin->sid . '/delete', 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
    ->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);
  $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?
}