You are here

class SkinrUITestCase in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 tests/skinr_ui.test \SkinrUITestCase

Base class for Skinr UI tests.

Hierarchy

Expanded class hierarchy of SkinrUITestCase

File

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

View source
class SkinrUITestCase extends DrupalWebTestCase {
  protected $profile = 'testing';
  function setUp() {
    $modules = func_get_args();
    if (isset($modules[0]) && is_array($modules[0])) {
      $modules = $modules[0];
    }
    parent::setUp(array_merge(array(
      'block',
      'comment',
      'contextual',
      'skinr_ui',
      'skinr_ui_test',
    ), $modules));
    $this->admin_user = $this
      ->drupalCreateUser(array(
      'administer blocks',
      'access contextual links',
      'administer skinr',
      'edit skin settings',
      'edit advanced skin settings',
    ));
    $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();
    db_merge('block')
      ->key(array(
      'theme' => $default_theme,
      'module' => 'search',
      'delta' => 'form',
    ))
      ->fields(array(
      'status' => 1,
      'region' => 'sidebar_first',
      'pages' => '',
    ))
      ->execute();
  }

  /**
   * Asserts that a class is set for the given element id.
   *
   * @param $id
   *   Id of the HTML element to check.
   * @param $class
   *   The class name to check for.
   * @param $message
   *   Message to display.
   * @return
   *   TRUE on pass, FALSE on fail.
   */
  function assertSkinrClass($id, $class, $message = '') {
    $elements = $this
      ->xpath('//div[@id=:id]', array(
      ':id' => $id,
    ));
    $class_attr = (string) $elements[0]['class'];
    $this
      ->assertTrue(strpos($class_attr, ' ' . $class . ' '), $message);
  }

  /**
   * Asserts that a class is not set for the given element id.
   *
   * @param $id
   *   Id of the HTML element to check.
   * @param $class
   *   The class name to check for.
   * @param $message
   *   Message to display.
   * @return
   *   TRUE on pass, FALSE on fail.
   */
  function assertNoSkinrClass($id, $class, $message = '') {
    $elements = $this
      ->xpath('//div[@id=:id]', array(
      ':id' => $id,
    ));
    $class_attr = (string) $elements[0]['class'];
    $this
      ->assertFalse(strpos($class_attr, ' ' . $class . ' '), $message);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SkinrUITestCase::$profile protected property 1
SkinrUITestCase::assertNoSkinrClass function Asserts that a class is not set for the given element id.
SkinrUITestCase::assertSkinrClass function Asserts that a class is set for the given element id.
SkinrUITestCase::setUp function 2