You are here

protected function OpignoWebTestCase::enableBlock in Opigno 7

Helper function to enable a block.

File

tests/OpignoWebTestCase.test, line 156
Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests.

Class

OpignoWebTestCase
@file Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests.

Code

protected function enableBlock($module, $delta, $region = 'sidebar_first', $pages_visible = array(), $pages_unvisible = array()) {
  $block = array(
    'module' => $module,
    'delta' => $delta,
    'theme' => variable_get('theme_default', 'bartik'),
    'status' => 1,
    'weight' => 0,
    'region' => $region,
    'visibility' => (int) empty($pages_visible),
    'pages' => implode("\n", !empty($pages_visible) ? $pages_visible : $pages_unvisible),
    'cache' => -1,
  );
  $query = db_insert('block')
    ->fields(array(
    'module',
    'delta',
    'theme',
    'status',
    'weight',
    'region',
    'visibility',
    'pages',
    'cache',
  ));
  $query
    ->values($block);
  $query
    ->execute();
}