You are here

function SkinrUIPluginTestCase::testBlock in Skinr 8.2

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

Tests block plugin.

File

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

Class

SkinrUIPluginTestCase
Tests UI functionality for Block plugin.

Code

function testBlock() {

  // Enable 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' => 'user-menu',
  ))
    ->fields(array(
    'status' => 1,
    'region' => 'sidebar_first',
    'pages' => '',
  ))
    ->execute();

  // Get front page.
  $this
    ->drupalGet('');

  // Make sure our contextual link appears on the page.
  $this
    ->assertLinkByHref('admin/structure/skinr/edit/block/system__user-menu/configure', 0, 'Contexual link to edit block\'s skin configuration was found.');

  // Make sure this block's options are returned.
  $this
    ->drupalGet('admin/structure/skinr/add');
  $this
    ->assertOptionExists('element', 'system__user-menu', 'User menu block was returned by block_skinr_ui_element_options().');

  // Test the returned element title.
  $skin = (object) array(
    'theme' => $default_theme,
    'module' => 'block',
    'element' => 'system__user-menu',
    'skin' => 'skinr_ui_test_bgcolor',
    'options' => array(
      'bgcolor_red',
    ),
    'status' => 1,
  );
  skinr_skin_save($skin);
  $title = skinr_invoke_all('skinr_ui_element_title', $skin->module, $skin->element, $skin->theme);
  $title = reset($title);
  $this
    ->assertTrue($title == 'User menu', 'Block title was returned.');
}