You are here

function SkinrUIAdminTestCase::testSkinDefaultStatus in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 tests/skinr_ui.test \SkinrUIAdminTestCase::testSkinDefaultStatus()

Tests default status of skins.

The skinr_test_basetheme skin defined by the skinr_test_basetheme theme specifies a default status for itself. Its subtheme should inherit the status of the basetheme.

@todo Add assertions for 'default status' itself.

File

skinr_ui/src/Tests/skinr_ui.test, line 355
Tests for the Skinr UI module.

Class

SkinrUIAdminTestCase
Tests administrative pages functionality.

Code

function testSkinDefaultStatus() {

  // Verify that it is enabled for the skinr_test_subtheme.
  $this
    ->drupalGet('admin/structure/skinr/library/list/skinr_test_subtheme');
  $this
    ->assertFieldChecked('edit-skins-general-skinr-test-basetheme-enable', 'skinr_test_basetheme skin is enabled for skinr_test_subtheme.');

  // Verify that it is disabled for Bartik by default.
  $this
    ->drupalGet('admin/structure/skinr/library/list/bartik');
  $this
    ->assertNoFieldChecked('edit-skins-general-skinr-test-basetheme-enable', 'skinr_test_basetheme skin is disabled for Bartik.');

  // Verify that it is disabled for Garland by default.
  $this
    ->drupalGet('admin/structure/skinr/library/list/garland');
  $this
    ->assertNoFieldChecked('edit-skins-general-skinr-test-basetheme-enable', 'skinr_test_basetheme skin is disabled for Garland.');

  // Override the status for skinr_test_subtheme and Bartik, then verify them.
  $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);
  $skin = entity_load('skin', $skin->sid);

  // Override the default skin.
  $skin->element = 'system-main';
  $this
    ->drupalGet('admin/structure/skinr');
  $this
    ->clickLink(t('disable'), 1);

  // Unaltered skin configuration object should have been saved with only the status updated.
  // Load an uncached version of the skin configuration object.
  $skin = entity_load('skin', $skin->sid, TRUE);
  $this
    ->assertFalse($skin->status, 'Status was disabled successfully.');
  $this
    ->assertEqual($skin->element, 'system__user-menu', 'Only status was updated, even though the object was modified before updating status.');

  // Enable the skin configuration.
  $this
    ->drupalGet('admin/structure/skinr');
  $this
    ->clickLink(t('enable'), 0);

  // Load an uncached version of the skin configuration object.
  $skin = entity_load('skin', $skin->sid, TRUE);
  $this
    ->assertTrue($skin->status, 'Status was enabled successfully.');
}