Simpletest Coverage - modules/simpletest/tests/system_test.module

1 <?php
2 // $Id: system_test.module,v 1.14 2009/08/05 16:16:41 webchick Exp $
3
4 /**
5 * Implement hook_menu().
6 */
7 function system_test_menu() {
8 $items['system-test/sleep/%'] = array(
9 'page callback' => 'system_test_sleep',
10 'page arguments' => array(2),
11 'access callback' => TRUE,
12 'type' => MENU_CALLBACK,
13 );
14 $items['system-test/auth'] = array(
15 'page callback' => 'system_test_basic_auth_page',
16 'access callback' => TRUE,
17 'type' => MENU_CALLBACK,
18 );
19 $items['system-test/redirect/%'] = array(
20 'title' => 'Redirect',
21 'page callback' => 'system_test_redirect',
22 'page arguments' => array(2),
23 'access arguments' => array('access content'),
24 'type' => MENU_CALLBACK,
25 );
26 $items['system-test/set-header'] = array(
27 'page callback' => 'system_test_set_header',
28 'access arguments' => array('access content'),
29 'type' => MENU_CALLBACK,
30 );
31 $items['system-test/redirect-noscheme'] = array(
32 'page callback' => 'system_test_redirect_noscheme',
33 'access arguments' => array('access content'),
34 'type' => MENU_CALLBACK,
35 );
36 $items['system-test/redirect-noparse'] = array(
37 'page callback' => 'system_test_redirect_noparse',
38 'access arguments' => array('access content'),
39 'type' => MENU_CALLBACK,
40 );
41 $items['system-test/redirect-invalid-scheme'] = array(
42 'page callback' => 'system_test_redirect_invalid_scheme',
43 'access arguments' => array('access content'),
44 'type' => MENU_CALLBACK,
45 );
46 $items['system-test/destination'] = array(
47 'title' => 'Redirect',
48 'page callback' => 'system_test_destination',
49 'page arguments' => array(2),
50 'access arguments' => array('access content'),
51 'type' => MENU_CALLBACK,
52 );
53
54 $items['system-test/variable-get'] = array(
55 'title' => 'Variable Get',
56 'page callback' => 'variable_get',
57 'page arguments' => array('simpletest_bootstrap_variable_test', NULL),
58 'access arguments' => array('access content'),
59 'type' => MENU_CALLBACK,
60 );
61
62 return $items;
63 }
64
65 function system_test_sleep($seconds) {
66 sleep($seconds);
67 }
68
69 function system_test_basic_auth_page() {
70 $output = t('$_SERVER[\'PHP_AUTH_USER\'] is @username.', array('@username' => $_SERVER['PHP_AUTH_USER']));
71 $output .= t('$_SERVER[\'PHP_AUTH_PW\'] is @password.', array('@password' => $_SERVER['PHP_AUTH_PW']));
72 return $output;
73 }
74
75 function system_test_redirect($code) {
76 $code = (int)$code;
77 if ($code != 200) {
78 header("Location: " . url('system-test/redirect/200', array('absolute' => TRUE)), TRUE, $code);
79 exit;
80 }
81 return '';
82 }
83
84 function system_test_set_header() {
85 drupal_set_header($_GET['name'], $_GET['value']);
86 return t('The following header was set: %name: %value', array('%name' => $_GET['name'], '%value' => $_GET['value']));
87 }
88
89 function system_test_redirect_noscheme() {
90 header("Location: localhost/path", TRUE, 301);
91 exit;
92 }
93
94 function system_test_redirect_noparse() {
95 header("Location: http:///path", TRUE, 301);
96 exit;
97 }
98
99 function system_test_redirect_invalid_scheme() {
100 header("Location: ftp://localhost/path", TRUE, 301);
101 exit;
102 }
103
104 function system_test_destination() {
105 return 'The destination: ' . drupal_get_destination();
106 }
107
108 /**
109 * Implement hook_modules_installed().
110 */
111 function system_test_modules_installed($modules) {
112 if (in_array('aggregator', $modules)) {
113 drupal_set_message(t('hook_modules_installed fired for aggregator'));
114 }
115 }
116
117 /**
118 * Implement hook_modules_enabled().
119 */
120 function system_test_modules_enabled($modules) {
121 if (in_array('aggregator', $modules)) {
122 drupal_set_message(t('hook_modules_enabled fired for aggregator'));
123 }
124 }
125
126 /**
127 * Implement hook_modules_disabled().
128 */
129 function system_test_modules_disabled($modules) {
130 if (in_array('aggregator', $modules)) {
131 drupal_set_message(t('hook_modules_disabled fired for aggregator'));
132 }
133 }
134
135 /**
136 * Implement hook_modules_uninstalled().
137 */
138 function system_test_modules_uninstalled($modules) {
139 if (in_array('aggregator', $modules)) {
140 drupal_set_message(t('hook_modules_uninstalled fired for aggregator'));
141 }
142 }
143
144 /**
145 * Implement hook_boot().
146 */
147 function system_test_boot() {
148 watchdog('system_test', 'hook_boot');
149 }
150
151 /**
152 * Implement hook_init().
153 */
154 function system_test_init() {
155 // Used by FrontPageTestCase to get the results of drupal_is_front_page().
156 if (variable_get('front_page_output', 0) && drupal_is_front_page()) {
157 drupal_set_message(t('On front page.'));
158 }
159 }
160
161 /**
162 * Implement hook_exit().
163 */
164 function system_test_exit() {
165 watchdog('system_test', 'hook_exit');
166 }
167
168 /**
169 * Implement hook_system_info_alter().
170 */
171 function system_test_system_info_alter(&$info, $file) {
172 // We need a static otherwise the last test will fail to alter common_test.
173 static $test;
174 if (($dependencies = variable_get('dependencies', array())) || $test) {
175 if ($file->name == 'module_test') {
176 $info['hidden'] = FALSE;
177 $info['dependencies'][] = array_shift($dependencies);
178 variable_set('dependencies', $dependencies);
179 $test = TRUE;
180 }
181 if ($file->name == 'common_test') {
182 $info['hidden'] = FALSE;
183 $info['version'] = '7.x-2.4-beta3';
184 }
185 }
186 }
187
188

Legend

Missed
lines code that were not excersized during program execution.
Covered
lines code were excersized during program execution.
Comment/non executable
Comment or non-executable line of code.
Dead
lines of code that according to xdebug could not be executed. This is counted as coverage code because in almost all cases it is code that runnable.