You are here

public function SkinrContextApiTestCase::testSkinrContextGroupHooks in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_context/tests/skinr_context.test \SkinrContextApiTestCase::testSkinrContextGroupHooks()

Test hook invocations for CRUD operations on skin settings groups.

File

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

Class

SkinrContextApiTestCase
Tests Skinr Context API functionality.

Code

public function testSkinrContextGroupHooks() {
  $group = (object) array(
    'gid' => 'block:system__user-menu:default',
    'module' => 'block',
    'element' => 'system__user-menu',
    'title' => 'Default',
    'description' => '',
    'conditions' => array(
      'sitewide' => array(
        'values' => array(
          1 => 1,
        ),
      ),
    ),
    'condition_mode' => CONTEXT_CONDITION_MODE_OR,
    'weight' => 0,
    'status' => 1,
  );
  $_SESSION['skinr_test'] = array();
  skinr_context_group_save($group);
  $this
    ->verbose(highlight_string('<?php ' . var_export($group, TRUE), TRUE));
  $this
    ->verbose(highlight_string('<?php ' . var_export($_SESSION['skinr_test'], TRUE), TRUE));
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_presave called');
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_insert called');
  $_SESSION['skinr_test'] = array();
  $group = skinr_context_group_load($group->gid);
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_load called');
  $_SESSION['skinr_test'] = array();
  $group = skinr_context_group_load_unchanged($group->gid);
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_load called');
  $_SESSION['skinr_test'] = array();
  $group->status = 0;
  skinr_context_group_save($group);
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_presave called');
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_update called');
  $_SESSION['skinr_test'] = array();
  skinr_context_group_delete($group->gid);
  $this
    ->assertHookMessage('skinr_context_test_skinr_context_group_delete called');
}