Skip to content
This repository
Browse code

Making CodeCoverageManager and CakeSession tests run in php4. Removin…

…g test case for removed method.
  • Loading branch information...
commit 5d280ea9779fb47b70377e70c9a01d08c039c34c 1 parent 2093f05
Mark Story authored January 14, 2010
1  cake/tests/cases/libs/cake_session.test.php
@@ -167,6 +167,7 @@ function testStarted() {
167 167
 		$this->assertTrue($this->Session->started());
168 168
 
169 169
 		unset($_SESSION);
  170
+		$_SESSION = null;
170 171
 		$this->assertFalse($this->Session->started());
171 172
 		$this->assertTrue($this->Session->start());
172 173
 	}
168  cake/tests/cases/libs/code_coverage_manager.test.php
@@ -96,9 +96,9 @@ function remove($var) {
96 96
 			$contents[1] = array_filter($contents[1], "remove");
97 97
 
98 98
 			foreach ($contents[1] as $file) {
99  
-				CodeCoverageManager::init('libs'.DS.$file, $reporter);
  99
+				CodeCoverageManager::init('libs' . DS . $file, $reporter);
100 100
 				CodeCoverageManager::report(false);
101  
-				$this->assertNoErrors('libs'.DS.$file);
  101
+				$this->assertNoErrors('libs' . DS . $file);
102 102
 			}
103 103
 		}
104 104
 	}
@@ -139,174 +139,12 @@ function testGetTestObjectFileNameFromTestCaseFile() {
139 139
 		$this->assertIdentical(APP.'plugins'.DS.'bugs'.DS.'models'.DS.'some_file.php', $expected);
140 140
 
141 141
 		$manager->pluginTest = false;
142  
-		$manager->reporter = new CLIReporter;
  142
+		$manager->reporter = new CakeCliReporter;
143 143
 		$expected = $manager->__testObjectFileFromCaseFile('libs/set.test.php', false);
144 144
 		$this->assertIdentical(ROOT.DS.'cake'.DS.'libs'.DS.'set.php', $expected);
145 145
 	}
146 146
 
147 147
 /**
148  
- * testOfHtmlReport method
149  
- *
150  
- * @access public
151  
- * @return void
152  
- */
153  
-	function testOfHtmlReport() {
154  
-		$manager =& CodeCoverageManager::getInstance();
155  
-		$code = <<<PHP
156  
-/**
157  
- * Set class
158  
- *
159  
- * @package       cake
160  
- * @subpackage    cake.tests.cases.libs
161  
- */
162  
-		class Set extends Object {
163  
-
164  
-/**
165  
-		 * Value of the Set object.
166  
-		 *
167  
-		 * @var array
168  
-		 * @access public
169  
-		 */
170  
-			var \$value = array();
171  
-
172  
-/**
173  
-		 * Constructor. Defaults to an empty array.
174  
-		 *
175  
-		 * @access public
176  
-		 */
177  
-			function __construct() {
178  
-				if (func_num_args() == 1 && is_array(func_get_arg(0))) {
179  
-					\$this->value = func_get_arg(0);
180  
-				} else {
181  
-					\$this->value = func_get_args();
182  
-				}
183  
-			}
184  
-
185  
-/**
186  
-		 * Returns the contents of the Set object
187  
-		 *
188  
-		 * @return array
189  
-		 * @access public
190  
-		 */
191  
-			function &get() {
192  
-				return \$this->value;
193  
-			}
194  
-
195  
-/**
196  
-		 * This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
197  
-		 * to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
198  
-		 * but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.
199  
-		 *
200  
-		 * Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
201  
-		 *
202  
-		 * @param array \$arr1 Array to be merged
203  
-		 * @param array \$arr2 Array to merge with
204  
-		 * @return array Merged array
205  
-		 * @access public
206  
-		 */
207  
-			function merge(\$arr1, \$arr2 = null) {
208  
-				\$args = func_get_args();
209  
-
210  
-				if (isset(\$this) && is_a(\$this, 'set')) {
211  
-					\$backtrace = debug_backtrace();
212  
-					\$previousCall = strtolower(\$backtrace[1]['class'].'::'.\$backtrace[1]['function']);
213  
-					if (\$previousCall != 'set::merge') {
214  
-						\$r =& \$this->value;
215  
-						array_unshift(\$args, null);
216  
-					}
217  
-				}
218  
-				if (!isset(\$r)) {
219  
-					\$r = (array)current(\$args);
220  
-				}
221  
-
222  
-				while ((\$arg = next(\$args)) !== false) {
223  
-					if (is_a(\$arg, 'set')) {
224  
-						\$arg = \$arg->get();
225  
-					}
226  
-
227  
-					foreach ((array)\$arg as \$key => \$val)	 {
228  
-						if (is_array(\$val) && isset(\$r[\$key]) && is_array(\$r[\$key])) {
229  
-							\$r[\$key] = Set::merge(\$r[\$key], \$val);
230  
-						} elseif (is_int(\$key)) {
231  
-
232  
-						} else {
233  
-							\$r[\$key] = \$val;
234  
-						}
235  
-					}
236  
-				}
237  
-				return \$r;
238  
-			}
239  
-PHP;
240  
-
241  
-		$testObjectFile = explode("\n", $code);
242  
-		$coverageData = array(
243  
-			0 => 1,
244  
-			1 => 1,
245  
-			2 => -2,
246  
-			3 => -2,
247  
-			4 => -2,
248  
-			5 => -2,
249  
-			6 => -2,
250  
-			7 => -2,
251  
-			8 => -1,
252  
-			9 => -2,
253  
-			10 => -2,
254  
-			11 => -2,
255  
-			12 => -2,
256  
-			13 => -2,
257  
-			14 => 1,
258  
-			15 => 1,
259  
-			16 => -1,
260  
-			17 => 1,
261  
-			18 => 1,
262  
-			19 => -1,
263  
-			20 => 1,
264  
-			21 => -2,
265  
-			22 => -2,
266  
-			23 => -2,
267  
-			24 => -2,
268  
-			25 => -2,
269  
-			26 => -2,
270  
-			27 => 1,
271  
-			28 => -1,
272  
-			29 => 1,
273  
-			30 => 1,
274  
-			31 => -2,
275  
-			32 => -2,
276  
-			33 => -2,
277  
-			34 => -2,
278  
-			35 => -2,
279  
-			36 => -2,
280  
-			37 => -2,
281  
-			38 => -2,
282  
-			39 => -2,
283  
-			40 => -2,
284  
-			41 => -2,
285  
-			42 => -2,
286  
-			43 => -1,
287  
-		);
288  
-		$execCodeLines = range(0, 72);
289  
-		$result = explode("</div>", $report = $manager->reportCaseHtml($testObjectFile, $coverageData, $execCodeLines));
290  
-
291  
-		foreach ($result as $num => $line) {
292  
-			$num++;
293  
-			if (array_key_exists($num, $coverageData)) {
294  
-				if ($coverageData[$num] == 1) {
295  
-					$this->assertTrue(strpos($line, 'covered') !== false, $num.': '.$line." fails");
296  
-				}
297  
-
298  
-				if (!array_key_exists($num, $execCodeLines) || $coverageData[$num] == -2) {
299  
-					$this->assertTrue(strpos($line, 'ignored') !== false, $num.': '.$line." fails");
300  
-				}
301  
-
302  
-				if ($coverageData[$num] == -1) {
303  
-					$this->assertTrue(strpos($line, 'uncovered') !== false, $num.': '.$line." fails");
304  
-				}
305  
-			}
306  
-		}
307  
-	}
308  
-
309  
-/**
310 148
  * testOfHtmlDiffReport method
311 149
  *
312 150
  * @access public

0 notes on commit 5d280ea

Please sign in to comment.
Something went wrong with that request. Please try again.