Test Setup Failed
Pull Request — master (#216)
by Viruthagiri
05:38
created
tests/lib/wordpress-tests-lib/includes/wp-profiler.php 1 patch
Braces   +26 added lines, -20 removed lines patch added patch discarded remove patch
@@ -84,8 +84,7 @@  discard block
 block discarded – undo
84 84
 			$this->profile[$name]['queries'] = array_add( $this->profile[$name]['queries'], $item['queries'] );
85 85
 			#$this->_query_summary($item['queries'], $this->profile[$name]['queries']);
86 86
 
87
-		}
88
-		else {
87
+		} else {
89 88
 			$queries = array();
90 89
 			$this->_query_summary($item['queries'], $queries);
91 90
 			$this->profile[$name] = array(
@@ -115,17 +114,19 @@  discard block
 block discarded – undo
115 114
 	function log_filter($tag) {
116 115
 		if ($this->stack) {
117 116
 			global $wp_actions;
118
-			if ($tag == end($wp_actions))
119
-				@$this->stack[count($this->stack)-1]['actions'][$tag] ++;
120
-			else
121
-				@$this->stack[count($this->stack)-1]['filters'][$tag] ++;
117
+			if ($tag == end($wp_actions)) {
118
+							@$this->stack[count($this->stack)-1]['actions'][$tag] ++;
119
+			} else {
120
+							@$this->stack[count($this->stack)-1]['filters'][$tag] ++;
121
+			}
122 122
 		}
123 123
 		return $arg;
124 124
 	}
125 125
 
126 126
 	function log_action($tag) {
127
-		if ($this->stack)
128
-			@$this->stack[count($this->stack)-1]['actions'][$tag] ++;
127
+		if ($this->stack) {
128
+					@$this->stack[count($this->stack)-1]['actions'][$tag] ++;
129
+		}
129 130
 	}
130 131
 
131 132
 	function _current_action() {
@@ -153,36 +154,41 @@  discard block
 block discarded – undo
153 154
 		// this requires the savequeries patch at https://core.trac.wordpress.org/ticket/5218
154 155
 		$out = array();
155 156
 		foreach ($queries as $q) {
156
-			if (empty($q[2]))
157
-				@$out['unknown'] ++;
158
-			else
159
-				@$out[$q[2]] ++;
157
+			if (empty($q[2])) {
158
+							@$out['unknown'] ++;
159
+			} else {
160
+							@$out[$q[2]] ++;
161
+			}
160 162
 		}
161 163
 		return $out;
162 164
 	}
163 165
 
164 166
 	function _dirty_objects_count($dirty_objects) {
165 167
 		$out = array();
166
-		foreach (array_keys($dirty_objects) as $group)
167
-			$out[$group] = count($dirty_objects[$group]);
168
+		foreach (array_keys($dirty_objects) as $group) {
169
+					$out[$group] = count($dirty_objects[$group]);
170
+		}
168 171
 		return $out;
169 172
 	}
170 173
 
171 174
 	function array_add($a, $b) {
172 175
 		$out = $a;
173
-		foreach (array_keys($b) as $key)
174
-			if (array_key_exists($key, $out))
176
+		foreach (array_keys($b) as $key) {
177
+					if (array_key_exists($key, $out))
175 178
 				$out[$key] += $b[$key];
176
-			else
177
-				$out[$key] = $b[$key];
179
+		}
180
+			else {
181
+							$out[$key] = $b[$key];
182
+			}
178 183
 		return $out;
179 184
 	}
180 185
 
181 186
 	function array_sub($a, $b) {
182 187
 		$out = $a;
183
-		foreach (array_keys($b) as $key)
184
-			if (array_key_exists($key, $b))
188
+		foreach (array_keys($b) as $key) {
189
+					if (array_key_exists($key, $b))
185 190
 				$out[$key] -= $b[$key];
191
+		}
186 192
 		return $out;
187 193
 	}
188 194
 
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/speed-trap-listener.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,9 @@
 block discarded – undo
133 133
      */
134 134
     public function endTest(PHPUnit_Framework_Test $test, $time)
135 135
     {
136
-        if (!$test instanceof PHPUnit_Framework_TestCase) return;
136
+        if (!$test instanceof PHPUnit_Framework_TestCase) {
137
+        	return;
138
+        }
137 139
 
138 140
         $time = $this->toMilliseconds($time);
139 141
         $threshold = $this->getSlowThreshold($test);
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/testcase.php 1 patch
Braces   +60 added lines, -39 removed lines patch added patch discarded remove patch
@@ -256,14 +256,16 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 
258 258
 	function _create_temporary_tables( $query ) {
259
-		if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) )
260
-			return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 );
259
+		if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) {
260
+					return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 );
261
+		}
261 262
 		return $query;
262 263
 	}
263 264
 
264 265
 	function _drop_temporary_tables( $query ) {
265
-		if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) )
266
-			return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 );
266
+		if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) {
267
+					return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 );
268
+		}
267 269
 		return $query;
268 270
 	}
269 271
 
@@ -278,10 +280,12 @@  discard block
 block discarded – undo
278 280
 	function expectDeprecated() {
279 281
 		$annotations = $this->getAnnotations();
280 282
 		foreach ( array( 'class', 'method' ) as $depth ) {
281
-			if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) )
282
-				$this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] );
283
-			if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) )
284
-				$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] );
283
+			if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) {
284
+							$this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] );
285
+			}
286
+			if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) {
287
+							$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] );
288
+			}
285 289
 		}
286 290
 		add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) );
287 291
 		add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) );
@@ -344,13 +348,15 @@  discard block
 block discarded – undo
344 348
 	}
345 349
 
346 350
 	function deprecated_function_run( $function ) {
347
-		if ( ! in_array( $function, $this->caught_deprecated ) )
348
-			$this->caught_deprecated[] = $function;
351
+		if ( ! in_array( $function, $this->caught_deprecated ) ) {
352
+					$this->caught_deprecated[] = $function;
353
+		}
349 354
 	}
350 355
 
351 356
 	function doing_it_wrong_run( $function ) {
352
-		if ( ! in_array( $function, $this->caught_doing_it_wrong ) )
353
-			$this->caught_doing_it_wrong[] = $function;
357
+		if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) {
358
+					$this->caught_doing_it_wrong[] = $function;
359
+		}
354 360
 	}
355 361
 
356 362
 	function assertWPError( $actual, $message = '' ) {
@@ -394,7 +400,9 @@  discard block
 block discarded – undo
394 400
 		// to run them more than once without very carefully clearing everything
395 401
 		$_GET = $_POST = array();
396 402
 		foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) {
397
-			if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] );
403
+			if ( isset( $GLOBALS[$v] ) ) {
404
+				unset( $GLOBALS[$v] );
405
+			}
398 406
 		}
399 407
 		$parts = parse_url($url);
400 408
 		if (isset($parts['scheme'])) {
@@ -439,20 +447,23 @@  discard block
 block discarded – undo
439 447
 			return;
440 448
 		}
441 449
 
442
-		if ( WP_TESTS_FORCE_KNOWN_BUGS )
443
-			return;
450
+		if ( WP_TESTS_FORCE_KNOWN_BUGS ) {
451
+					return;
452
+		}
444 453
 		$tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) );
445 454
 		foreach ( $tickets as $ticket ) {
446 455
 			if ( is_numeric( $ticket ) ) {
447 456
 				$this->knownWPBug( $ticket );
448 457
 			} elseif ( 'UT' == substr( $ticket, 0, 2 ) ) {
449 458
 				$ticket = substr( $ticket, 2 );
450
-				if ( $ticket && is_numeric( $ticket ) )
451
-					$this->knownUTBug( $ticket );
459
+				if ( $ticket && is_numeric( $ticket ) ) {
460
+									$this->knownUTBug( $ticket );
461
+				}
452 462
 			} elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) {
453 463
 				$ticket = substr( $ticket, 6 );
454
-				if ( $ticket && is_numeric( $ticket ) )
455
-					$this->knownPluginBug( $ticket );
464
+				if ( $ticket && is_numeric( $ticket ) ) {
465
+									$this->knownPluginBug( $ticket );
466
+				}
456 467
 			}
457 468
 		}
458 469
 	}
@@ -461,30 +472,36 @@  discard block
 block discarded – undo
461 472
 	 * Skips the current test if there is an open WordPress ticket with id $ticket_id
462 473
 	 */
463 474
 	function knownWPBug( $ticket_id ) {
464
-		if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) )
465
-			return;
466
-		if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) )
467
-			$this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) );
475
+		if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) {
476
+					return;
477
+		}
478
+		if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) {
479
+					$this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) );
480
+		}
468 481
 	}
469 482
 
470 483
 	/**
471 484
 	 * Skips the current test if there is an open unit tests ticket with id $ticket_id
472 485
 	 */
473 486
 	function knownUTBug( $ticket_id ) {
474
-		if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) )
475
-			return;
476
-		if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) )
477
-			$this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) );
487
+		if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) {
488
+					return;
489
+		}
490
+		if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) {
491
+					$this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) );
492
+		}
478 493
 	}
479 494
 
480 495
 	/**
481 496
 	 * Skips the current test if there is an open plugin ticket with id $ticket_id
482 497
 	 */
483 498
 	function knownPluginBug( $ticket_id ) {
484
-		if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) )
485
-			return;
486
-		if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) )
487
-			$this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) );
499
+		if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) {
500
+					return;
501
+		}
502
+		if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) {
503
+					$this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) );
504
+		}
488 505
 	}
489 506
 
490 507
 	public static function forceTicket( $ticket ) {
@@ -506,9 +523,10 @@  discard block
 block discarded – undo
506 523
 	function temp_filename() {
507 524
 		$tmp_dir = '';
508 525
 		$dirs = array( 'TMP', 'TMPDIR', 'TEMP' );
509
-		foreach( $dirs as $dir )
510
-			if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) {
526
+		foreach( $dirs as $dir ) {
527
+					if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) {
511 528
 				$tmp_dir = $dir;
529
+		}
512 530
 				break;
513 531
 			}
514 532
 		if ( empty( $tmp_dir ) ) {
@@ -579,10 +597,12 @@  discard block
 block discarded – undo
579 597
 		}
580 598
 
581 599
 		$message = '';
582
-		if ( count($not_true) )
583
-			$message .= implode( $not_true, ', ' ) . ' is expected to be true. ';
584
-		if ( count($not_false) )
585
-			$message .= implode( $not_false, ', ' ) . ' is expected to be false.';
600
+		if ( count($not_true) ) {
601
+					$message .= implode( $not_true, ', ' ) . ' is expected to be true. ';
602
+		}
603
+		if ( count($not_false) ) {
604
+					$message .= implode( $not_false, ', ' ) . ' is expected to be false.';
605
+		}
586 606
 		$this->assertTrue( $passed, $message );
587 607
 	}
588 608
 
@@ -702,8 +722,9 @@  discard block
 block discarded – undo
702 722
 			$type = $upload['type'];
703 723
 		} else {
704 724
 			$mime = wp_check_filetype( $upload['file'] );
705
-			if ($mime)
706
-				$type = $mime['type'];
725
+			if ($mime) {
726
+							$type = $mime['type'];
727
+			}
707 728
 		}
708 729
 
709 730
 		$attachment = array(
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/functions.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 	global $wp_filter;
15 15
 	static $filter_id_count = 0;
16 16
 
17
-	if ( is_string($function) )
18
-		return $function;
17
+	if ( is_string($function) ) {
18
+			return $function;
19
+	}
19 20
 
20 21
 	if ( is_object($function) ) {
21 22
 		// Closures are currently implemented as objects
@@ -37,8 +38,9 @@  discard block
 block discarded – undo
37 38
 
38 39
 	$all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}");
39 40
 	if ($all_posts) {
40
-		foreach ($all_posts as $id)
41
-			wp_delete_post( $id, true );
41
+		foreach ($all_posts as $id) {
42
+					wp_delete_post( $id, true );
43
+		}
42 44
 	}
43 45
 }
44 46
 
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/install.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,9 +44,10 @@
 block discarded – undo
44 44
 	$wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
45 45
 
46 46
 	// We need to create references to ms global tables.
47
-	if ( $multisite )
48
-		$wpdb->$table = $prefixed_table;
49
-}
47
+	if ( $multisite ) {
48
+			$wpdb->$table = $prefixed_table;
49
+	}
50
+	}
50 51
 
51 52
 // Prefill a permalink structure so that WP doesn't try to determine one itself.
52 53
 add_action( 'populate_options', '_set_default_permalink_structure_for_tests' );
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/bootstrap.php 1 patch
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,9 +7,10 @@  discard block
 block discarded – undo
7 7
 $config_file_path = dirname( dirname( __FILE__ ) );
8 8
 if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
9 9
 	// Support the config file from the root of the develop repository.
10
-	if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' )
11
-		$config_file_path = dirname( dirname( $config_file_path ) );
12
-}
10
+	if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) {
11
+			$config_file_path = dirname( dirname( $config_file_path ) );
12
+	}
13
+	}
13 14
 $config_file_path .= '/wp-tests-config.php';
14 15
 
15 16
 /*
@@ -26,8 +27,9 @@  discard block
 block discarded – undo
26 27
 define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
27 28
 define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
28 29
 
29
-if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) )
30
+if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) {
30 31
 	define( 'WP_TESTS_FORCE_KNOWN_BUGS', false );
32
+}
31 33
 
32 34
 // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only
33 35
 define( 'DISABLE_WP_CRON', true );
@@ -126,8 +128,7 @@  discard block
 block discarded – undo
126 128
 				if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) {
127 129
 					PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );
128 130
 				}
129
-			}
130
-			catch ( PHPUnit_Framework_Exception $e ) {
131
+			} catch ( PHPUnit_Framework_Exception $e ) {
131 132
 				// Enforcing recognized arguments or correctly formed arguments is
132 133
 				// not really the concern here.
133 134
 				continue;
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/testcase-canonical.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -168,19 +168,22 @@  discard block
 block discarded – undo
168 168
 	public function assertCanonical( $test_url, $expected, $ticket = 0, $expected_doing_it_wrong = array() ) {
169 169
 		$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, (array) $expected_doing_it_wrong );
170 170
 
171
-		if ( $ticket )
172
-			$this->knownWPBug( $ticket );
171
+		if ( $ticket ) {
172
+					$this->knownWPBug( $ticket );
173
+		}
173 174
 
174 175
 		$ticket_ref = ($ticket > 0) ? 'Ticket #' . $ticket : null;
175 176
 global $wpdb;
176 177
 //print_r( $wpdb->get_results( "SELECT * FROM $wpdb->terms" ) );
177
-		if ( is_string($expected) )
178
-			$expected = array('url' => $expected);
179
-		elseif ( is_array($expected) && !isset($expected['url']) && !isset($expected['qv']) )
180
-			$expected = array( 'qv' => $expected );
178
+		if ( is_string($expected) ) {
179
+					$expected = array('url' => $expected);
180
+		} elseif ( is_array($expected) && !isset($expected['url']) && !isset($expected['qv']) ) {
181
+					$expected = array( 'qv' => $expected );
182
+		}
181 183
 
182
-		if ( !isset($expected['url']) && !isset($expected['qv']) )
183
-			$this->markTestSkipped('No valid expected output was provided');
184
+		if ( !isset($expected['url']) && !isset($expected['qv']) ) {
185
+					$this->markTestSkipped('No valid expected output was provided');
186
+		}
184 187
 
185 188
 		$this->go_to( home_url( $test_url ) );
186 189
 
@@ -193,8 +196,9 @@  discard block
 block discarded – undo
193 196
 			$this->assertEquals( $expected['url'], $parsed_can_url['path'] . (!empty($parsed_can_url['query']) ? '?' . $parsed_can_url['query'] : ''), $ticket_ref );
194 197
 		}
195 198
 
196
-		if ( ! isset($expected['qv']) )
197
-			return;
199
+		if ( ! isset($expected['qv']) ) {
200
+					return;
201
+		}
198 202
 
199 203
 		// "make" that the request and check the query is correct
200 204
 		$this->go_to( $can_url );
@@ -227,8 +231,10 @@  discard block
 block discarded – undo
227 231
 		$test_url = home_url( $test_url );
228 232
 
229 233
 		$can_url = redirect_canonical( $test_url, false );
230
-		if ( ! $can_url )
231
-			return $test_url; // No redirect will take place for this request
234
+		if ( ! $can_url ) {
235
+					return $test_url;
236
+		}
237
+		// No redirect will take place for this request
232 238
 
233 239
 		return $can_url;
234 240
 	}
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/utils.php 1 patch
Braces   +77 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,9 +10,10 @@  discard block
 block discarded – undo
10 10
 function strip_ws($txt) {
11 11
 	$lines = explode("\n", $txt);
12 12
 	$result = array();
13
-	foreach ($lines as $line)
14
-		if (trim($line))
13
+	foreach ($lines as $line) {
14
+			if (trim($line))
15 15
 			$result[] = trim($line);
16
+	}
16 17
 
17 18
 	return trim(join("\n", $result));
18 19
 }
@@ -38,21 +39,26 @@  discard block
 block discarded – undo
38 39
 	}
39 40
 
40 41
 	function current_filter() {
41
-		if (is_callable('current_filter'))
42
-			return current_filter();
42
+		if (is_callable('current_filter')) {
43
+					return current_filter();
44
+		}
43 45
 		global $wp_actions;
44 46
 		return end($wp_actions);
45 47
 	}
46 48
 
47 49
 	function action($arg) {
48
-if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
50
+if ($this->debug) {
51
+	dmp(__FUNCTION__, $this->current_filter());
52
+}
49 53
 		$args = func_get_args();
50 54
 		$this->events[] = array('action' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
51 55
 		return $arg;
52 56
 	}
53 57
 
54 58
 	function action2($arg) {
55
-if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
59
+if ($this->debug) {
60
+	dmp(__FUNCTION__, $this->current_filter());
61
+}
56 62
 
57 63
 		$args = func_get_args();
58 64
 		$this->events[] = array('action' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
@@ -60,7 +66,9 @@  discard block
 block discarded – undo
60 66
 	}
61 67
 
62 68
 	function filter($arg) {
63
-if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
69
+if ($this->debug) {
70
+	dmp(__FUNCTION__, $this->current_filter());
71
+}
64 72
 
65 73
 		$args = func_get_args();
66 74
 		$this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
@@ -68,7 +76,9 @@  discard block
 block discarded – undo
68 76
 	}
69 77
 
70 78
 	function filter2($arg) {
71
-if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
79
+if ($this->debug) {
80
+	dmp(__FUNCTION__, $this->current_filter());
81
+}
72 82
 
73 83
 		$args = func_get_args();
74 84
 		$this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
@@ -76,7 +86,9 @@  discard block
 block discarded – undo
76 86
 	}
77 87
 
78 88
 	function filter_append($arg) {
79
-if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
89
+if ($this->debug) {
90
+	dmp(__FUNCTION__, $this->current_filter());
91
+}
80 92
 
81 93
 		$args = func_get_args();
82 94
 		$this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args);
@@ -85,7 +97,9 @@  discard block
 block discarded – undo
85 97
 
86 98
 	function filterall($tag, $arg=NULL) {
87 99
 	// this one doesn't return the result, so it's safe to use with the new 'all' filter
88
-if ($this->debug) dmp(__FUNCTION__, $this->current_filter());
100
+if ($this->debug) {
101
+	dmp(__FUNCTION__, $this->current_filter());
102
+}
89 103
 
90 104
 		$args = func_get_args();
91 105
 		$this->events[] = array('filter' => __FUNCTION__, 'tag'=>$tag, 'args'=>array_slice($args, 1));
@@ -100,9 +114,10 @@  discard block
 block discarded – undo
100 114
 	function get_call_count($tag='') {
101 115
 		if ($tag) {
102 116
 			$count = 0;
103
-			foreach ($this->events as $e)
104
-				if ($e['action'] == $tag)
117
+			foreach ($this->events as $e) {
118
+							if ($e['action'] == $tag)
105 119
 					++$count;
120
+			}
106 121
 			return $count;
107 122
 		}
108 123
 		return count($this->events);
@@ -120,8 +135,9 @@  discard block
 block discarded – undo
120 135
 	// return an array of args passed in calls to this action
121 136
 	function get_args() {
122 137
 		$out = array();
123
-		foreach ($this->events as $e)
124
-			$out[] = $e['args'];
138
+		foreach ($this->events as $e) {
139
+					$out[] = $e['args'];
140
+		}
125 141
 		return $out;
126 142
 	}
127 143
 }
@@ -186,17 +202,18 @@  discard block
 block discarded – undo
186 202
 	$n = count($a);
187 203
 	$out = array();
188 204
 
189
-	if ($n < 1)
190
-		return $out;
205
+	if ($n < 1) {
206
+			return $out;
207
+	}
191 208
 
192 209
 	for ($i=0; $i<count($tree); $i++) {
193 210
 #		echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n";
194 211
 #		var_dump($tree[$i]['name'], $a[0]);
195 212
 		if ($tree[$i]['name'] == $a[0]) {
196 213
 #			echo "n == {$n}\n";
197
-			if ($n == 1)
198
-				$out[] = $tree[$i];
199
-			else {
214
+			if ($n == 1) {
215
+							$out[] = $tree[$i];
216
+			} else {
200 217
 				$subtree =& $tree[$i]['child'];
201 218
 				$call_args = array($subtree);
202 219
 				$call_args = array_merge($call_args, array_slice($a, 1));
@@ -210,8 +227,9 @@  discard block
 block discarded – undo
210 227
 
211 228
 function xml_join_atts($atts) {
212 229
 	$a = array();
213
-	foreach ($atts as $k=>$v)
214
-		$a[] = $k.'="'.$v.'"';
230
+	foreach ($atts as $k=>$v) {
231
+			$a[] = $k.'="'.$v.'"';
232
+	}
215 233
 	return join(' ', $a);
216 234
 }
217 235
 
@@ -220,14 +238,15 @@  discard block
 block discarded – undo
220 238
 
221 239
 	foreach (array_keys($data) as $i) {
222 240
 		$name = $data[$i]['name'];
223
-		if (!empty($data[$i]['attributes']))
224
-			$name .= ' '.xml_join_atts($data[$i]['attributes']);
241
+		if (!empty($data[$i]['attributes'])) {
242
+					$name .= ' '.xml_join_atts($data[$i]['attributes']);
243
+		}
225 244
 
226 245
 		if (!empty($data[$i]['child'])) {
227 246
 			$out[$name][] = xml_array_dumbdown($data[$i]['child']);
247
+		} else {
248
+					$out[$name] = $data[$i]['content'];
228 249
 		}
229
-		else
230
-			$out[$name] = $data[$i]['content'];
231 250
 	}
232 251
 
233 252
 	return $out;
@@ -236,9 +255,10 @@  discard block
 block discarded – undo
236 255
 function dmp() {
237 256
 	$args = func_get_args();
238 257
 
239
-	foreach ($args as $thing)
240
-		echo (is_scalar($thing) ? strval($thing) : var_export($thing, true)), "\n";
241
-}
258
+	foreach ($args as $thing) {
259
+			echo (is_scalar($thing) ? strval($thing) : var_export($thing, true)), "\n";
260
+	}
261
+	}
242 262
 
243 263
 function dmp_filter($a) {
244 264
 	dmp($a);
@@ -255,18 +275,17 @@  discard block
 block discarded – undo
255 275
 function gen_tests_array($name, $array) {
256 276
 	$out = array();
257 277
 	foreach ($array as $k=>$v) {
258
-		if (is_numeric($k))
259
-			$index = strval($k);
260
-		else
261
-			$index = "'".addcslashes($k, "\n\r\t'\\")."'";
278
+		if (is_numeric($k)) {
279
+					$index = strval($k);
280
+		} else {
281
+					$index = "'".addcslashes($k, "\n\r\t'\\")."'";
282
+		}
262 283
 
263 284
 		if (is_string($v)) {
264 285
 			$out[] = '$this->assertEquals( \'' . addcslashes($v, "\n\r\t'\\") . '\', $'.$name.'['.$index.'] );';
265
-		}
266
-		elseif (is_numeric($v)) {
286
+		} elseif (is_numeric($v)) {
267 287
 			$out[] = '$this->assertEquals( ' . $v . ', $'.$name.'['.$index.'] );';
268
-		}
269
-		elseif (is_array($v)) {
288
+		} elseif (is_array($v)) {
270 289
 			$out[] = gen_tests_array("{$name}[{$index}]", $v);
271 290
 		}
272 291
 	}
@@ -284,9 +303,10 @@  discard block
 block discarded – undo
284 303
 function drop_tables() {
285 304
 	global $wpdb;
286 305
 	$tables = $wpdb->get_col('SHOW TABLES;');
287
-	foreach ($tables as $table)
288
-		$wpdb->query("DROP TABLE IF EXISTS {$table}");
289
-}
306
+	foreach ($tables as $table) {
307
+			$wpdb->query("DROP TABLE IF EXISTS {$table}");
308
+	}
309
+	}
290 310
 
291 311
 function print_backtrace() {
292 312
 	$bt = debug_backtrace();
@@ -294,10 +314,12 @@  discard block
 block discarded – undo
294 314
 	$i = 0;
295 315
 	foreach ($bt as $stack) {
296 316
 		echo ++$i, ": ";
297
-		if ( isset($stack['class']) )
298
-			echo $stack['class'].'::';
299
-		if ( isset($stack['function']) )
300
-			echo $stack['function'].'() ';
317
+		if ( isset($stack['class']) ) {
318
+					echo $stack['class'].'::';
319
+		}
320
+		if ( isset($stack['function']) ) {
321
+					echo $stack['function'].'() ';
322
+		}
301 323
 		echo "line {$stack[line]} in {$stack[file]}\n";
302 324
 	}
303 325
 	echo "\n";
@@ -350,20 +372,24 @@  discard block
 block discarded – undo
350 372
 
351 373
 function _cleanup_query_vars() {
352 374
 	// clean out globals to stop them polluting wp and wp_query
353
-	foreach ( $GLOBALS['wp']->public_query_vars as $v )
354
-		unset( $GLOBALS[$v] );
375
+	foreach ( $GLOBALS['wp']->public_query_vars as $v ) {
376
+			unset( $GLOBALS[$v] );
377
+	}
355 378
 
356
-	foreach ( $GLOBALS['wp']->private_query_vars as $v )
357
-		unset( $GLOBALS[$v] );
379
+	foreach ( $GLOBALS['wp']->private_query_vars as $v ) {
380
+			unset( $GLOBALS[$v] );
381
+	}
358 382
 
359 383
 	foreach ( get_taxonomies( array() , 'objects' ) as $t ) {
360
-		if ( $t->public && ! empty( $t->query_var ) )
361
-			$GLOBALS['wp']->add_query_var( $t->query_var );
384
+		if ( $t->public && ! empty( $t->query_var ) ) {
385
+					$GLOBALS['wp']->add_query_var( $t->query_var );
386
+		}
362 387
 	}
363 388
 
364 389
 	foreach ( get_post_types( array() , 'objects' ) as $t ) {
365
-		if ( is_post_type_viewable( $t ) && ! empty( $t->query_var ) )
366
-			$GLOBALS['wp']->add_query_var( $t->query_var );
390
+		if ( is_post_type_viewable( $t ) && ! empty( $t->query_var ) ) {
391
+					$GLOBALS['wp']->add_query_var( $t->query_var );
392
+		}
367 393
 	}
368 394
 }
369 395
 
Please login to merge, or discard this patch.
tests/lib/wordpress-tests-lib/includes/testcase-ajax.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -119,8 +119,9 @@  discard block
 block discarded – undo
119 119
 	public function logout() {
120 120
 		unset( $GLOBALS['current_user'] );
121 121
 		$cookies = array(AUTH_COOKIE, SECURE_AUTH_COOKIE, LOGGED_IN_COOKIE, USER_COOKIE, PASS_COOKIE);
122
-		foreach ( $cookies as $c )
123
-			unset( $_COOKIE[$c] );
122
+		foreach ( $cookies as $c ) {
123
+					unset( $_COOKIE[$c] );
124
+		}
124 125
 	}
125 126
 
126 127
 	/**
@@ -195,7 +196,8 @@  discard block
 block discarded – undo
195 196
 
196 197
 		// Save the output
197 198
 		$buffer = ob_get_clean();
198
-		if ( !empty( $buffer ) )
199
-			$this->_last_response = $buffer;
199
+		if ( !empty( $buffer ) ) {
200
+					$this->_last_response = $buffer;
201
+		}
200 202
 	}
201 203
 }
Please login to merge, or discard this patch.