You are here

class SkinrContextDisplayTestCase in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_context/tests/skinr_context.test \SkinrContextDisplayTestCase

Tests API functionality.

Make sure this patch is applied to drupal core

Hierarchy

Expanded class hierarchy of SkinrContextDisplayTestCase

File

skinr_context/tests/skinr_context.test, line 272
Tests for the Skinr Context module.

View source
class SkinrContextDisplayTestCase extends SkinrWebTestCase {
  protected $profile = 'testing';
  public static function getInfo() {
    return array(
      'name' => 'Context - Display',
      'description' => 'Tests if applied skins appear on the front-end.',
      'dependencies' => array(
        'ctools',
        'context',
      ),
      'group' => 'Skinr',
    );
  }
  public function setUp() {
    parent::setUp(array(
      'block',
      'skinr',
      'skinr_context',
      'skinr_test',
    ));
    $this->admin_user = $this
      ->drupalCreateUser(array(
      'administer blocks',
    ));
    $this
      ->drupalLogin($this->admin_user);

    // Enable main system block for content region and the user menu block for
    // the first sidebar.
    // @see http://drupal.org/node/913086
    $default_theme = variable_get('theme_default', 'bartik');
    db_merge('block')
      ->key(array(
      'theme' => $default_theme,
      'module' => 'system',
      'delta' => 'main',
    ))
      ->fields(array(
      'status' => 1,
      'region' => 'content',
      'pages' => '',
    ))
      ->execute();
    db_merge('block')
      ->key(array(
      'theme' => $default_theme,
      'module' => 'system',
      'delta' => 'user-menu',
    ))
      ->fields(array(
      'status' => 1,
      'region' => 'sidebar_first',
      'pages' => '',
    ))
      ->execute();

    // Enable Garland.
    theme_enable(array(
      'garland',
    ));
  }
  public function testSkinrContextDisplayed() {

    // Save a group.
    $group = (object) array(
      'gid' => 'block:system__main:default',
      'module' => 'block',
      'element' => 'system__main',
      'title' => 'Default',
      'description' => '',
      'conditions' => array(
        'path' => array(
          'values' => array(
            '<front>' => '<front>',
          ),
        ),
      ),
      'condition_mode' => CONTEXT_CONDITION_MODE_OR,
      'weight' => 0,
      'status' => 1,
    );
    $this
      ->assertTrue(skinr_context_group_save($group), 'Skin settings group object saved.');

    // Save a skin configuration object.
    $skin = (object) array(
      'module' => 'block',
      'element' => 'system__main',
      'gid' => $group->gid,
      'theme' => 'bartik',
      'skin' => 'skinr_test_font',
      'options' => array(
        'font_1',
      ),
      'status' => 1,
    );
    $this
      ->assertTrue(skinr_skin_save($skin), 'Skin configuration object was saved.');

    // Go to the front page.
    $this
      ->drupalGet('');
    $this
      ->assertSkinrClass('block-system-main', 'font-1', 'CSS class of configured skin option found.');

    // Check another page to make sure it only appears on the front page.
    $this
      ->drupalGet('user');
    $this
      ->assertNoSkinrClass('block-system-main', 'font-1', 'CSS class of configured skin option not found on other pages.');

    // @todo Check for group B overriding group A.
  }

}

Members