summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/theme_test.module
blob: ad22367b831424326365a60ced883c47a5cc4db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
// $Id$

/**
 * Implements hook_menu().
 */
function theme_test_menu() {
  $items['theme-test/suggestion'] = array(
    'title' => 'Suggestion',
    'page callback' => '_theme_test_suggestion',
    'access arguments' => array('access content'),
    'theme callback' => '_theme_custom_theme',
    'type' => MENU_CALLBACK,
  );
  $items['theme-test/hook-init'] = array(
    'page callback' => 'theme_test_hook_init_page_callback',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implements hook_init().
 */
function theme_test_init() {
  // First, force the theme registry to be rebuilt on this page request. This
  // allows us to test a full initialization of the theme system in the code
  // below.
  drupal_theme_rebuild();
  // Next, initialize the theme system by storing themed text in a global
  // variable. We will use this later in theme_test_hook_init_page_callback()
  // to test that even when the theme system is initialized this early, it is
  // still capable of returning output and theming the page as a whole.
  $GLOBALS['theme_test_output'] = theme('more_link', array('url' => 'user', 'title' => 'Themed output generated in hook_init()'));
}

/**
 * Menu callback for testing themed output generated in hook_init().
 */
function theme_test_hook_init_page_callback() {
  return $GLOBALS['theme_test_output'];
}

/**
 * Custom theme callback.
 */
function _theme_custom_theme() {
  return 'test_theme';
}

/**
 * Page callback, calls a theme hook suggestion.
 */
function _theme_test_suggestion() {
  return theme(array('breadcrumb__suggestion', 'breadcrumb'), array());
}

/**
 * Implements hook_preprocess_breadcrumb().
 *
 * Set a variable that can later be tested to see if this function ran.
 */
function theme_test_preprocess_breadcrumb(&$variables) {
  $variables['theme_test_preprocess_breadcrumb'] = 1;
}