@@ -412,37 +412,37 @@ |
||
412 | 412 | ini_set( 'pcre.backtrack_limit', $i ); |
413 | 413 | |
414 | 414 | switch( $strategy ) { |
415 | - case 'split': |
|
416 | - preg_split( $pattern, $subject ); |
|
417 | - break; |
|
418 | - case 'match': |
|
419 | - preg_match( $pattern, $subject ); |
|
420 | - break; |
|
421 | - case 'match_all': |
|
422 | - $matches = array(); |
|
423 | - preg_match_all( $pattern, $subject, $matches ); |
|
424 | - break; |
|
415 | + case 'split': |
|
416 | + preg_split( $pattern, $subject ); |
|
417 | + break; |
|
418 | + case 'match': |
|
419 | + preg_match( $pattern, $subject ); |
|
420 | + break; |
|
421 | + case 'match_all': |
|
422 | + $matches = array(); |
|
423 | + preg_match_all( $pattern, $subject, $matches ); |
|
424 | + break; |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | ini_set( 'pcre.backtrack_limit', $saved_config ); |
428 | 428 | |
429 | 429 | switch( preg_last_error() ) { |
430 | - case PREG_NO_ERROR: |
|
431 | - return $i; |
|
432 | - case PREG_BACKTRACK_LIMIT_ERROR: |
|
433 | - continue; |
|
434 | - case PREG_RECURSION_LIMIT_ERROR: |
|
435 | - trigger_error('PCRE recursion limit encountered before backtrack limit.'); |
|
436 | - return; |
|
437 | - case PREG_BAD_UTF8_ERROR: |
|
438 | - trigger_error('UTF-8 error during PCRE benchmark.'); |
|
439 | - return; |
|
440 | - case PREG_INTERNAL_ERROR: |
|
441 | - trigger_error('Internal error during PCRE benchmark.'); |
|
442 | - return; |
|
443 | - default: |
|
444 | - trigger_error('Unexpected error during PCRE benchmark.'); |
|
445 | - return; |
|
430 | + case PREG_NO_ERROR: |
|
431 | + return $i; |
|
432 | + case PREG_BACKTRACK_LIMIT_ERROR: |
|
433 | + continue; |
|
434 | + case PREG_RECURSION_LIMIT_ERROR: |
|
435 | + trigger_error('PCRE recursion limit encountered before backtrack limit.'); |
|
436 | + return; |
|
437 | + case PREG_BAD_UTF8_ERROR: |
|
438 | + trigger_error('UTF-8 error during PCRE benchmark.'); |
|
439 | + return; |
|
440 | + case PREG_INTERNAL_ERROR: |
|
441 | + trigger_error('Internal error during PCRE benchmark.'); |
|
442 | + return; |
|
443 | + default: |
|
444 | + trigger_error('Unexpected error during PCRE benchmark.'); |
|
445 | + return; |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 |
@@ -10,9 +10,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | // misc help functions and utilities |
4 | 4 | |
5 | -function rand_str($len=32) { |
|
5 | +function rand_str($len = 32) { |
|
6 | 6 | return substr(md5(uniqid(rand())), 0, $len); |
7 | 7 | } |
8 | 8 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * PHP5 constructor. |
30 | 30 | */ |
31 | - function __construct( $debug = 0 ) { |
|
31 | + function __construct($debug = 0) { |
|
32 | 32 | $this->reset(); |
33 | 33 | $this->debug = $debug; |
34 | 34 | } |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | |
81 | 81 | $args = func_get_args(); |
82 | 82 | $this->events[] = array('filter' => __FUNCTION__, 'tag'=>$this->current_filter(), 'args'=>$args); |
83 | - return $arg . '_append'; |
|
83 | + return $arg.'_append'; |
|
84 | 84 | } |
85 | 85 | |
86 | - function filterall($tag, $arg=NULL) { |
|
86 | + function filterall($tag, $arg = NULL) { |
|
87 | 87 | // this one doesn't return the result, so it's safe to use with the new 'all' filter |
88 | 88 | if ($this->debug) dmp(__FUNCTION__, $this->current_filter()); |
89 | 89 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | // return a count of the number of times the action was called since the last reset |
100 | - function get_call_count($tag='') { |
|
100 | + function get_call_count($tag = '') { |
|
101 | 101 | if ($tag) { |
102 | 102 | $count = 0; |
103 | 103 | foreach ($this->events as $e) |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * PHP5 constructor. |
137 | 137 | */ |
138 | - function __construct( $in ) { |
|
138 | + function __construct($in) { |
|
139 | 139 | $this->xml = xml_parser_create(); |
140 | 140 | xml_set_object($this->xml, $this); |
141 | - xml_parser_set_option($this->xml,XML_OPTION_CASE_FOLDING, 0); |
|
141 | + xml_parser_set_option($this->xml, XML_OPTION_CASE_FOLDING, 0); |
|
142 | 142 | xml_set_element_handler($this->xml, array($this, 'startHandler'), array($this, 'endHandler')); |
143 | 143 | xml_set_character_data_handler($this->xml, array($this, 'dataHandler')); |
144 | 144 | $this->parse($in); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | if ($n < 1) |
190 | 190 | return $out; |
191 | 191 | |
192 | - for ($i=0; $i<count($tree); $i++) { |
|
192 | + for ($i = 0; $i < count($tree); $i++) { |
|
193 | 193 | # echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n"; |
194 | 194 | # var_dump($tree[$i]['name'], $a[0]); |
195 | 195 | if ($tree[$i]['name'] == $a[0]) { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if ($n == 1) |
198 | 198 | $out[] = $tree[$i]; |
199 | 199 | else { |
200 | - $subtree =& $tree[$i]['child']; |
|
200 | + $subtree = & $tree[$i]['child']; |
|
201 | 201 | $call_args = array($subtree); |
202 | 202 | $call_args = array_merge($call_args, array_slice($a, 1)); |
203 | 203 | $out = array_merge($out, call_user_func_array('xml_find', $call_args)); |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | $index = "'".addcslashes($k, "\n\r\t'\\")."'"; |
262 | 262 | |
263 | 263 | if (is_string($v)) { |
264 | - $out[] = '$this->assertEquals( \'' . addcslashes($v, "\n\r\t'\\") . '\', $'.$name.'['.$index.'] );'; |
|
264 | + $out[] = '$this->assertEquals( \''.addcslashes($v, "\n\r\t'\\").'\', $'.$name.'['.$index.'] );'; |
|
265 | 265 | } |
266 | 266 | elseif (is_numeric($v)) { |
267 | - $out[] = '$this->assertEquals( ' . $v . ', $'.$name.'['.$index.'] );'; |
|
267 | + $out[] = '$this->assertEquals( '.$v.', $'.$name.'['.$index.'] );'; |
|
268 | 268 | } |
269 | 269 | elseif (is_array($v)) { |
270 | 270 | $out[] = gen_tests_array("{$name}[{$index}]", $v); |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | $i = 0; |
295 | 295 | foreach ($bt as $stack) { |
296 | 296 | echo ++$i, ": "; |
297 | - if ( isset($stack['class']) ) |
|
297 | + if (isset($stack['class'])) |
|
298 | 298 | echo $stack['class'].'::'; |
299 | - if ( isset($stack['function']) ) |
|
299 | + if (isset($stack['function'])) |
|
300 | 300 | echo $stack['function'].'() '; |
301 | 301 | echo "line {$stack[line]} in {$stack[file]}\n"; |
302 | 302 | } |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | // mask out any input fields matching the given name |
307 | -function mask_input_value($in, $name='_wpnonce') { |
|
307 | +function mask_input_value($in, $name = '_wpnonce') { |
|
308 | 308 | return preg_replace('@<input([^>]*) name="'.preg_quote($name).'"([^>]*) value="[^>]*" />@', '<input$1 name="'.preg_quote($name).'"$2 value="***" />', $in); |
309 | 309 | } |
310 | 310 | |
311 | -if ( !function_exists( 'str_getcsv' ) ) { |
|
312 | - function str_getcsv( $input, $delimiter = ',', $enclosure = '"', $escape = "\\" ) { |
|
313 | - $fp = fopen( 'php://temp/', 'r+' ); |
|
314 | - fputs( $fp, $input ); |
|
315 | - rewind( $fp ); |
|
316 | - $data = fgetcsv( $fp, strlen( $input ), $delimiter, $enclosure ); |
|
317 | - fclose( $fp ); |
|
311 | +if (!function_exists('str_getcsv')) { |
|
312 | + function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = "\\") { |
|
313 | + $fp = fopen('php://temp/', 'r+'); |
|
314 | + fputs($fp, $input); |
|
315 | + rewind($fp); |
|
316 | + $data = fgetcsv($fp, strlen($input), $delimiter, $enclosure); |
|
317 | + fclose($fp); |
|
318 | 318 | return $data; |
319 | 319 | } |
320 | 320 | } |
@@ -322,19 +322,19 @@ discard block |
||
322 | 322 | /** |
323 | 323 | * Removes the post type and its taxonomy associations. |
324 | 324 | */ |
325 | -function _unregister_post_type( $cpt_name ) { |
|
326 | - unset( $GLOBALS['wp_post_types'][ $cpt_name ] ); |
|
327 | - unset( $GLOBALS['_wp_post_type_features'][ $cpt_name ] ); |
|
325 | +function _unregister_post_type($cpt_name) { |
|
326 | + unset($GLOBALS['wp_post_types'][$cpt_name]); |
|
327 | + unset($GLOBALS['_wp_post_type_features'][$cpt_name]); |
|
328 | 328 | |
329 | - foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy ) { |
|
330 | - if ( false !== $key = array_search( $cpt_name, $taxonomy->object_type ) ) { |
|
331 | - unset( $taxonomy->object_type[$key] ); |
|
329 | + foreach ($GLOBALS['wp_taxonomies'] as $taxonomy) { |
|
330 | + if (false !== $key = array_search($cpt_name, $taxonomy->object_type)) { |
|
331 | + unset($taxonomy->object_type[$key]); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | -function _unregister_taxonomy( $taxonomy_name ) { |
|
337 | - unset( $GLOBALS['wp_taxonomies'][$taxonomy_name] ); |
|
336 | +function _unregister_taxonomy($taxonomy_name) { |
|
337 | + unset($GLOBALS['wp_taxonomies'][$taxonomy_name]); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -344,32 +344,32 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @param string $status |
346 | 346 | */ |
347 | -function _unregister_post_status( $status ) { |
|
348 | - unset( $GLOBALS['wp_post_statuses'][ $status ] ); |
|
347 | +function _unregister_post_status($status) { |
|
348 | + unset($GLOBALS['wp_post_statuses'][$status]); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | function _cleanup_query_vars() { |
352 | 352 | // clean out globals to stop them polluting wp and wp_query |
353 | - foreach ( $GLOBALS['wp']->public_query_vars as $v ) |
|
354 | - unset( $GLOBALS[$v] ); |
|
353 | + foreach ($GLOBALS['wp']->public_query_vars as $v) |
|
354 | + unset($GLOBALS[$v]); |
|
355 | 355 | |
356 | - foreach ( $GLOBALS['wp']->private_query_vars as $v ) |
|
357 | - unset( $GLOBALS[$v] ); |
|
356 | + foreach ($GLOBALS['wp']->private_query_vars as $v) |
|
357 | + unset($GLOBALS[$v]); |
|
358 | 358 | |
359 | - foreach ( get_taxonomies( array() , 'objects' ) as $t ) { |
|
360 | - if ( $t->public && ! empty( $t->query_var ) ) |
|
361 | - $GLOBALS['wp']->add_query_var( $t->query_var ); |
|
359 | + foreach (get_taxonomies(array(), 'objects') as $t) { |
|
360 | + if ($t->public && !empty($t->query_var)) |
|
361 | + $GLOBALS['wp']->add_query_var($t->query_var); |
|
362 | 362 | } |
363 | 363 | |
364 | - 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 ); |
|
364 | + 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); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | function _clean_term_filters() { |
371 | - remove_filter( 'get_terms', array( 'Featured_Content', 'hide_featured_term' ), 10, 2 ); |
|
372 | - remove_filter( 'get_the_terms', array( 'Featured_Content', 'hide_the_featured_term' ), 10, 3 ); |
|
371 | + remove_filter('get_terms', array('Featured_Content', 'hide_featured_term'), 10, 2); |
|
372 | + remove_filter('get_the_terms', array('Featured_Content', 'hide_the_featured_term'), 10, 3); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | $this->charset = $wpdb->charset; |
387 | 387 | } |
388 | 388 | |
389 | - public function __call( $name, $arguments ) { |
|
390 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
389 | + public function __call($name, $arguments) { |
|
390 | + return call_user_func_array(array($this, $name), $arguments); |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -396,37 +396,37 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return int The backtrack count. |
398 | 398 | */ |
399 | -function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) { |
|
400 | - $saved_config = ini_get( 'pcre.backtrack_limit' ); |
|
399 | +function benchmark_pcre_backtracking($pattern, $subject, $strategy) { |
|
400 | + $saved_config = ini_get('pcre.backtrack_limit'); |
|
401 | 401 | |
402 | 402 | // Attempt to prevent PHP crashes. Adjust these lower when needed. |
403 | - if ( version_compare( phpversion(), '5.4.8', '>' ) ) { |
|
403 | + if (version_compare(phpversion(), '5.4.8', '>')) { |
|
404 | 404 | $limit = 1000000; |
405 | 405 | } else { |
406 | - $limit = 20000; // 20,000 is a reasonable upper limit, but see also https://core.trac.wordpress.org/ticket/29557#comment:10 |
|
406 | + $limit = 20000; // 20,000 is a reasonable upper limit, but see also https://core.trac.wordpress.org/ticket/29557#comment:10 |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | // Start with small numbers, so if a crash is encountered at higher numbers we can still debug the problem. |
410 | - for( $i = 4; $i <= $limit; $i *= 2 ) { |
|
410 | + for ($i = 4; $i <= $limit; $i *= 2) { |
|
411 | 411 | |
412 | - ini_set( 'pcre.backtrack_limit', $i ); |
|
412 | + ini_set('pcre.backtrack_limit', $i); |
|
413 | 413 | |
414 | - switch( $strategy ) { |
|
414 | + switch ($strategy) { |
|
415 | 415 | case 'split': |
416 | - preg_split( $pattern, $subject ); |
|
416 | + preg_split($pattern, $subject); |
|
417 | 417 | break; |
418 | 418 | case 'match': |
419 | - preg_match( $pattern, $subject ); |
|
419 | + preg_match($pattern, $subject); |
|
420 | 420 | break; |
421 | 421 | case 'match_all': |
422 | 422 | $matches = array(); |
423 | - preg_match_all( $pattern, $subject, $matches ); |
|
423 | + preg_match_all($pattern, $subject, $matches); |
|
424 | 424 | break; |
425 | 425 | } |
426 | 426 | |
427 | - ini_set( 'pcre.backtrack_limit', $saved_config ); |
|
427 | + ini_set('pcre.backtrack_limit', $saved_config); |
|
428 | 428 | |
429 | - switch( preg_last_error() ) { |
|
429 | + switch (preg_last_error()) { |
|
430 | 430 | case PREG_NO_ERROR: |
431 | 431 | return $i; |
432 | 432 | case PREG_BACKTRACK_LIMIT_ERROR: |
@@ -119,8 +119,9 @@ discard block |
||
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 |
||
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 | } |
@@ -57,18 +57,18 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | public static function setUpBeforeClass() { |
60 | - if ( ! defined( 'DOING_AJAX' ) ) { |
|
61 | - define( 'DOING_AJAX', true ); |
|
60 | + if (!defined('DOING_AJAX')) { |
|
61 | + define('DOING_AJAX', true); |
|
62 | 62 | } |
63 | 63 | |
64 | - remove_action( 'admin_init', '_maybe_update_core' ); |
|
65 | - remove_action( 'admin_init', '_maybe_update_plugins' ); |
|
66 | - remove_action( 'admin_init', '_maybe_update_themes' ); |
|
64 | + remove_action('admin_init', '_maybe_update_core'); |
|
65 | + remove_action('admin_init', '_maybe_update_plugins'); |
|
66 | + remove_action('admin_init', '_maybe_update_themes'); |
|
67 | 67 | |
68 | 68 | // Register the core actions |
69 | - foreach ( array_merge( self::$_core_actions_get, self::$_core_actions_post ) as $action ) { |
|
70 | - if ( function_exists( 'wp_ajax_' . str_replace( '-', '_', $action ) ) ) { |
|
71 | - add_action( 'wp_ajax_' . $action, 'wp_ajax_' . str_replace( '-', '_', $action ), 1 ); |
|
69 | + foreach (array_merge(self::$_core_actions_get, self::$_core_actions_post) as $action) { |
|
70 | + if (function_exists('wp_ajax_'.str_replace('-', '_', $action))) { |
|
71 | + add_action('wp_ajax_'.$action, 'wp_ajax_'.str_replace('-', '_', $action), 1); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | public function setUp() { |
83 | 83 | parent::setUp(); |
84 | 84 | |
85 | - add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 ); |
|
85 | + add_filter('wp_die_ajax_handler', array($this, 'getDieHandler'), 1, 1); |
|
86 | 86 | |
87 | - set_current_screen( 'ajax' ); |
|
87 | + set_current_screen('ajax'); |
|
88 | 88 | |
89 | 89 | // Clear logout cookies |
90 | - add_action( 'clear_auth_cookie', array( $this, 'logout' ) ); |
|
90 | + add_action('clear_auth_cookie', array($this, 'logout')); |
|
91 | 91 | |
92 | 92 | // Suppress warnings from "Cannot modify header information - headers already sent by" |
93 | 93 | $this->_error_level = error_reporting(); |
94 | - error_reporting( $this->_error_level & ~E_WARNING ); |
|
94 | + error_reporting($this->_error_level & ~E_WARNING); |
|
95 | 95 | |
96 | 96 | // Make some posts |
97 | - self::factory()->post->create_many( 5 ); |
|
97 | + self::factory()->post->create_many(5); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -105,22 +105,22 @@ discard block |
||
105 | 105 | parent::tearDown(); |
106 | 106 | $_POST = array(); |
107 | 107 | $_GET = array(); |
108 | - unset( $GLOBALS['post'] ); |
|
109 | - unset( $GLOBALS['comment'] ); |
|
110 | - remove_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 ); |
|
111 | - remove_action( 'clear_auth_cookie', array( $this, 'logout' ) ); |
|
112 | - error_reporting( $this->_error_level ); |
|
113 | - set_current_screen( 'front' ); |
|
108 | + unset($GLOBALS['post']); |
|
109 | + unset($GLOBALS['comment']); |
|
110 | + remove_filter('wp_die_ajax_handler', array($this, 'getDieHandler'), 1, 1); |
|
111 | + remove_action('clear_auth_cookie', array($this, 'logout')); |
|
112 | + error_reporting($this->_error_level); |
|
113 | + set_current_screen('front'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Clear login cookies, unset the current user |
118 | 118 | */ |
119 | 119 | public function logout() { |
120 | - unset( $GLOBALS['current_user'] ); |
|
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 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return callback |
129 | 129 | */ |
130 | 130 | public function getDieHandler() { |
131 | - return array( $this, 'dieHandler' ); |
|
131 | + return array($this, 'dieHandler'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | * </code> |
147 | 147 | * @param string $message |
148 | 148 | */ |
149 | - public function dieHandler( $message ) { |
|
149 | + public function dieHandler($message) { |
|
150 | 150 | $this->_last_response .= ob_get_clean(); |
151 | 151 | |
152 | - if ( '' === $this->_last_response ) { |
|
153 | - if ( is_scalar( $message ) ) { |
|
154 | - throw new WPAjaxDieStopException( (string) $message ); |
|
152 | + if ('' === $this->_last_response) { |
|
153 | + if (is_scalar($message)) { |
|
154 | + throw new WPAjaxDieStopException((string) $message); |
|
155 | 155 | } else { |
156 | - throw new WPAjaxDieStopException( '0' ); |
|
156 | + throw new WPAjaxDieStopException('0'); |
|
157 | 157 | } |
158 | 158 | } else { |
159 | - throw new WPAjaxDieContinueException( $message ); |
|
159 | + throw new WPAjaxDieContinueException($message); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * E.g. administrator, editor, author, contributor, subscriber |
166 | 166 | * @param string $role |
167 | 167 | */ |
168 | - protected function _setRole( $role ) { |
|
168 | + protected function _setRole($role) { |
|
169 | 169 | $post = $_POST; |
170 | - $user_id = self::factory()->user->create( array( 'role' => $role ) ); |
|
171 | - wp_set_current_user( $user_id ); |
|
170 | + $user_id = self::factory()->user->create(array('role' => $role)); |
|
171 | + wp_set_current_user($user_id); |
|
172 | 172 | $_POST = array_merge($_POST, $post); |
173 | 173 | } |
174 | 174 | |
@@ -181,21 +181,21 @@ discard block |
||
181 | 181 | protected function _handleAjax($action) { |
182 | 182 | |
183 | 183 | // Start output buffering |
184 | - ini_set( 'implicit_flush', false ); |
|
184 | + ini_set('implicit_flush', false); |
|
185 | 185 | ob_start(); |
186 | 186 | |
187 | 187 | // Build the request |
188 | 188 | $_POST['action'] = $action; |
189 | 189 | $_GET['action'] = $action; |
190 | - $_REQUEST = array_merge( $_POST, $_GET ); |
|
190 | + $_REQUEST = array_merge($_POST, $_GET); |
|
191 | 191 | |
192 | 192 | // Call the hooks |
193 | - do_action( 'admin_init' ); |
|
194 | - do_action( 'wp_ajax_' . $_REQUEST['action'], null ); |
|
193 | + do_action('admin_init'); |
|
194 | + do_action('wp_ajax_'.$_REQUEST['action'], null); |
|
195 | 195 | |
196 | 196 | // Save the output |
197 | 197 | $buffer = ob_get_clean(); |
198 | - if ( !empty( $buffer ) ) |
|
198 | + if (!empty($buffer)) |
|
199 | 199 | $this->_last_response = $buffer; |
200 | 200 | } |
201 | 201 | } |
@@ -21,13 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | // Copy of core's function, but accepts a path. |
23 | 23 | function abspath( $path = false ) { |
24 | - if ( ! $path ) |
|
25 | - $path = ABSPATH; |
|
24 | + if ( ! $path ) { |
|
25 | + $path = ABSPATH; |
|
26 | + } |
|
26 | 27 | $folder = $this->find_folder( $path ); |
27 | 28 | |
28 | 29 | // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. |
29 | - if ( ! $folder && $this->is_dir('/wp-includes') ) |
|
30 | - $folder = '/'; |
|
30 | + if ( ! $folder && $this->is_dir('/wp-includes') ) { |
|
31 | + $folder = '/'; |
|
32 | + } |
|
31 | 33 | return $folder; |
32 | 34 | } |
33 | 35 | |
@@ -51,21 +53,25 @@ discard block |
||
51 | 53 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
52 | 54 | */ |
53 | 55 | function setfs( $paths ) { |
54 | - if ( ! is_array($paths) ) |
|
55 | - $paths = explode( "\n", $paths ); |
|
56 | + if ( ! is_array($paths) ) { |
|
57 | + $paths = explode( "\n", $paths ); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | $paths = array_filter( array_map( 'trim', $paths ) ); |
58 | 61 | |
59 | 62 | foreach ( $paths as $path ) { |
60 | 63 | // Allow for comments |
61 | - if ( '#' == $path[0] ) |
|
62 | - continue; |
|
64 | + if ( '#' == $path[0] ) { |
|
65 | + continue; |
|
66 | + } |
|
63 | 67 | |
64 | 68 | // Directories |
65 | - if ( '/' == $path[ strlen($path) -1 ] ) |
|
66 | - $this->mkdir( $path ); |
|
67 | - else // Files (with dummy content for now) |
|
69 | + if ( '/' == $path[ strlen($path) -1 ] ) { |
|
70 | + $this->mkdir( $path ); |
|
71 | + } else { |
|
72 | + // Files (with dummy content for now) |
|
68 | 73 | $this->put_contents( $path, 'This is a test file' ); |
74 | + } |
|
69 | 75 | } |
70 | 76 | |
71 | 77 | } |
@@ -95,8 +101,9 @@ discard block |
||
95 | 101 | $dirname = str_replace( '\\', '/', dirname( $path ) ); |
96 | 102 | $this->mkdir( $dirname ); |
97 | 103 | $parent_node = $this->locate_parent_node( $path ); |
98 | - if ( ! $parent_node ) |
|
99 | - return false; |
|
104 | + if ( ! $parent_node ) { |
|
105 | + return false; |
|
106 | + } |
|
100 | 107 | } |
101 | 108 | |
102 | 109 | $node = new MockFS_Directory_Node( $path ); |
@@ -108,8 +115,9 @@ discard block |
||
108 | 115 | } |
109 | 116 | |
110 | 117 | function put_contents( $path, $contents = '', $mode = null ) { |
111 | - if ( ! $this->is_dir( dirname( $path ) ) ) |
|
112 | - $this->mkdir( dirname( $path ) ); |
|
118 | + if ( ! $this->is_dir( dirname( $path ) ) ) { |
|
119 | + $this->mkdir( dirname( $path ) ); |
|
120 | + } |
|
113 | 121 | |
114 | 122 | $parent = $this->locate_parent_node( $path ); |
115 | 123 | $new_file = new MockFS_File_Node( $path, $contents ); |
@@ -119,8 +127,9 @@ discard block |
||
119 | 127 | } |
120 | 128 | |
121 | 129 | function get_contents( $file ) { |
122 | - if ( ! $this->is_file( $file ) ) |
|
123 | - return false; |
|
130 | + if ( ! $this->is_file( $file ) ) { |
|
131 | + return false; |
|
132 | + } |
|
124 | 133 | return $this->fs_map[ $file ]->contents; |
125 | 134 | } |
126 | 135 | |
@@ -129,8 +138,9 @@ discard block |
||
129 | 138 | } |
130 | 139 | |
131 | 140 | function chdir( $path ) { |
132 | - if ( ! isset( $this->fs_map[ $path ] ) ) |
|
133 | - return false; |
|
141 | + if ( ! isset( $this->fs_map[ $path ] ) ) { |
|
142 | + return false; |
|
143 | + } |
|
134 | 144 | |
135 | 145 | $this->cwd = $this->fs_map[ $path ]; |
136 | 146 | return true; |
@@ -152,11 +162,13 @@ discard block |
||
152 | 162 | |
153 | 163 | function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { |
154 | 164 | |
155 | - if ( empty( $path ) || '.' == $path ) |
|
156 | - $path = $this->cwd(); |
|
165 | + if ( empty( $path ) || '.' == $path ) { |
|
166 | + $path = $this->cwd(); |
|
167 | + } |
|
157 | 168 | |
158 | - if ( ! $this->exists( $path ) ) |
|
159 | - return false; |
|
169 | + if ( ! $this->exists( $path ) ) { |
|
170 | + return false; |
|
171 | + } |
|
160 | 172 | |
161 | 173 | $limit_file = false; |
162 | 174 | if ( $this->is_file( $path ) ) { |
@@ -166,24 +178,28 @@ discard block |
||
166 | 178 | |
167 | 179 | $ret = array(); |
168 | 180 | foreach ( $this->fs_map[ $path ]->children as $entry ) { |
169 | - if ( '.' == $entry->name || '..' == $entry->name ) |
|
170 | - continue; |
|
181 | + if ( '.' == $entry->name || '..' == $entry->name ) { |
|
182 | + continue; |
|
183 | + } |
|
171 | 184 | |
172 | - if ( ! $include_hidden && '.' == $entry->name ) |
|
173 | - continue; |
|
185 | + if ( ! $include_hidden && '.' == $entry->name ) { |
|
186 | + continue; |
|
187 | + } |
|
174 | 188 | |
175 | - if ( $limit_file && $entry->name != $limit_file ) |
|
176 | - continue; |
|
189 | + if ( $limit_file && $entry->name != $limit_file ) { |
|
190 | + continue; |
|
191 | + } |
|
177 | 192 | |
178 | 193 | $struc = array(); |
179 | 194 | $struc['name'] = $entry->name; |
180 | 195 | $struc['type'] = $entry->type; |
181 | 196 | |
182 | 197 | if ( 'd' == $struc['type'] ) { |
183 | - if ( $recursive ) |
|
184 | - $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
185 | - else |
|
186 | - $struc['files'] = array(); |
|
198 | + if ( $recursive ) { |
|
199 | + $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
200 | + } else { |
|
201 | + $struc['files'] = array(); |
|
202 | + } |
|
187 | 203 | } |
188 | 204 | |
189 | 205 | $ret[ $entry->name ] = $struc; |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | // Copy of core's function, but accepts a path. |
23 | - function abspath( $path = false ) { |
|
24 | - if ( ! $path ) |
|
23 | + function abspath($path = false) { |
|
24 | + if (!$path) |
|
25 | 25 | $path = ABSPATH; |
26 | - $folder = $this->find_folder( $path ); |
|
26 | + $folder = $this->find_folder($path); |
|
27 | 27 | |
28 | 28 | // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. |
29 | - if ( ! $folder && $this->is_dir('/wp-includes') ) |
|
29 | + if (!$folder && $this->is_dir('/wp-includes')) |
|
30 | 30 | $folder = '/'; |
31 | 31 | return $folder; |
32 | 32 | } |
@@ -37,35 +37,35 @@ discard block |
||
37 | 37 | * Sets initial filesystem environment and/or clears the current environment. |
38 | 38 | * Can also be passed the initial filesystem to be setup which is passed to self::setfs() |
39 | 39 | */ |
40 | - function init( $paths = '', $home_dir = '/' ) { |
|
41 | - $this->fs = new MockFS_Directory_Node( '/' ); |
|
40 | + function init($paths = '', $home_dir = '/') { |
|
41 | + $this->fs = new MockFS_Directory_Node('/'); |
|
42 | 42 | $this->fs_map = array( |
43 | 43 | '/' => $this->fs, |
44 | 44 | ); |
45 | 45 | $this->cache = array(); // Used by find_folder() and friends |
46 | - $this->cwd = isset( $this->fs_map[ $home_dir ] ) ? $this->fs_map[ $home_dir ] : '/'; |
|
47 | - $this->setfs( $paths ); |
|
46 | + $this->cwd = isset($this->fs_map[$home_dir]) ? $this->fs_map[$home_dir] : '/'; |
|
47 | + $this->setfs($paths); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
52 | 52 | */ |
53 | - function setfs( $paths ) { |
|
54 | - if ( ! is_array($paths) ) |
|
55 | - $paths = explode( "\n", $paths ); |
|
53 | + function setfs($paths) { |
|
54 | + if (!is_array($paths)) |
|
55 | + $paths = explode("\n", $paths); |
|
56 | 56 | |
57 | - $paths = array_filter( array_map( 'trim', $paths ) ); |
|
57 | + $paths = array_filter(array_map('trim', $paths)); |
|
58 | 58 | |
59 | - foreach ( $paths as $path ) { |
|
59 | + foreach ($paths as $path) { |
|
60 | 60 | // Allow for comments |
61 | - if ( '#' == $path[0] ) |
|
61 | + if ('#' == $path[0]) |
|
62 | 62 | continue; |
63 | 63 | |
64 | 64 | // Directories |
65 | - if ( '/' == $path[ strlen($path) -1 ] ) |
|
66 | - $this->mkdir( $path ); |
|
65 | + if ('/' == $path[strlen($path) - 1]) |
|
66 | + $this->mkdir($path); |
|
67 | 67 | else // Files (with dummy content for now) |
68 | - $this->put_contents( $path, 'This is a test file' ); |
|
68 | + $this->put_contents($path, 'This is a test file'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -73,120 +73,120 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * Locates a filesystem "node" |
75 | 75 | */ |
76 | - private function locate_node( $path ) { |
|
77 | - return isset( $this->fs_map[ $path ] ) ? $this->fs_map[ $path ] : false; |
|
76 | + private function locate_node($path) { |
|
77 | + return isset($this->fs_map[$path]) ? $this->fs_map[$path] : false; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Locates a filesystem node for the parent of the given item |
82 | 82 | */ |
83 | - private function locate_parent_node( $path ) { |
|
84 | - $dirname = str_replace( '\\', '/', dirname( $path ) ); |
|
85 | - return $this->locate_node( trailingslashit( $dirname ) ); |
|
83 | + private function locate_parent_node($path) { |
|
84 | + $dirname = str_replace('\\', '/', dirname($path)); |
|
85 | + return $this->locate_node(trailingslashit($dirname)); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Here starteth the WP_Filesystem functions. |
89 | 89 | |
90 | - function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) { |
|
91 | - $path = trailingslashit( $path ); |
|
90 | + function mkdir($path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false) { |
|
91 | + $path = trailingslashit($path); |
|
92 | 92 | |
93 | - $parent_node = $this->locate_parent_node( $path ); |
|
94 | - if ( ! $parent_node ) { |
|
95 | - $dirname = str_replace( '\\', '/', dirname( $path ) ); |
|
96 | - $this->mkdir( $dirname ); |
|
97 | - $parent_node = $this->locate_parent_node( $path ); |
|
98 | - if ( ! $parent_node ) |
|
93 | + $parent_node = $this->locate_parent_node($path); |
|
94 | + if (!$parent_node) { |
|
95 | + $dirname = str_replace('\\', '/', dirname($path)); |
|
96 | + $this->mkdir($dirname); |
|
97 | + $parent_node = $this->locate_parent_node($path); |
|
98 | + if (!$parent_node) |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
102 | - $node = new MockFS_Directory_Node( $path ); |
|
102 | + $node = new MockFS_Directory_Node($path); |
|
103 | 103 | |
104 | - $parent_node->children[ $node->name ] = $node; |
|
105 | - $this->fs_map[ $path ] = $node; |
|
104 | + $parent_node->children[$node->name] = $node; |
|
105 | + $this->fs_map[$path] = $node; |
|
106 | 106 | |
107 | 107 | return true; |
108 | 108 | } |
109 | 109 | |
110 | - function put_contents( $path, $contents = '', $mode = null ) { |
|
111 | - if ( ! $this->is_dir( dirname( $path ) ) ) |
|
112 | - $this->mkdir( dirname( $path ) ); |
|
110 | + function put_contents($path, $contents = '', $mode = null) { |
|
111 | + if (!$this->is_dir(dirname($path))) |
|
112 | + $this->mkdir(dirname($path)); |
|
113 | 113 | |
114 | - $parent = $this->locate_parent_node( $path ); |
|
115 | - $new_file = new MockFS_File_Node( $path, $contents ); |
|
114 | + $parent = $this->locate_parent_node($path); |
|
115 | + $new_file = new MockFS_File_Node($path, $contents); |
|
116 | 116 | |
117 | - $parent->children[ $new_file->name ] = $new_file; |
|
118 | - $this->fs_map[ $path ] = $new_file; |
|
117 | + $parent->children[$new_file->name] = $new_file; |
|
118 | + $this->fs_map[$path] = $new_file; |
|
119 | 119 | } |
120 | 120 | |
121 | - function get_contents( $file ) { |
|
122 | - if ( ! $this->is_file( $file ) ) |
|
121 | + function get_contents($file) { |
|
122 | + if (!$this->is_file($file)) |
|
123 | 123 | return false; |
124 | - return $this->fs_map[ $file ]->contents; |
|
124 | + return $this->fs_map[$file]->contents; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | function cwd() { |
128 | 128 | return $this->cwd->path; |
129 | 129 | } |
130 | 130 | |
131 | - function chdir( $path ) { |
|
132 | - if ( ! isset( $this->fs_map[ $path ] ) ) |
|
131 | + function chdir($path) { |
|
132 | + if (!isset($this->fs_map[$path])) |
|
133 | 133 | return false; |
134 | 134 | |
135 | - $this->cwd = $this->fs_map[ $path ]; |
|
135 | + $this->cwd = $this->fs_map[$path]; |
|
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | |
139 | - function exists( $path ) { |
|
140 | - return isset( $this->fs_map[ $path ] ) || isset( $this->fs_map[ trailingslashit( $path ) ] ); |
|
139 | + function exists($path) { |
|
140 | + return isset($this->fs_map[$path]) || isset($this->fs_map[trailingslashit($path)]); |
|
141 | 141 | } |
142 | 142 | |
143 | - function is_file( $file ) { |
|
144 | - return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); |
|
143 | + function is_file($file) { |
|
144 | + return isset($this->fs_map[$file]) && $this->fs_map[$file]->is_file(); |
|
145 | 145 | } |
146 | 146 | |
147 | - function is_dir( $path ) { |
|
148 | - $path = trailingslashit( $path ); |
|
147 | + function is_dir($path) { |
|
148 | + $path = trailingslashit($path); |
|
149 | 149 | |
150 | - return isset( $this->fs_map[ $path ] ) && $this->fs_map[ $path ]->is_dir(); |
|
150 | + return isset($this->fs_map[$path]) && $this->fs_map[$path]->is_dir(); |
|
151 | 151 | } |
152 | 152 | |
153 | - function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { |
|
153 | + function dirlist($path = '.', $include_hidden = true, $recursive = false) { |
|
154 | 154 | |
155 | - if ( empty( $path ) || '.' == $path ) |
|
155 | + if (empty($path) || '.' == $path) |
|
156 | 156 | $path = $this->cwd(); |
157 | 157 | |
158 | - if ( ! $this->exists( $path ) ) |
|
158 | + if (!$this->exists($path)) |
|
159 | 159 | return false; |
160 | 160 | |
161 | 161 | $limit_file = false; |
162 | - if ( $this->is_file( $path ) ) { |
|
163 | - $limit_file = $this->locate_node( $path )->name; |
|
164 | - $path = dirname( $path ) . '/'; |
|
162 | + if ($this->is_file($path)) { |
|
163 | + $limit_file = $this->locate_node($path)->name; |
|
164 | + $path = dirname($path).'/'; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | $ret = array(); |
168 | - foreach ( $this->fs_map[ $path ]->children as $entry ) { |
|
169 | - if ( '.' == $entry->name || '..' == $entry->name ) |
|
168 | + foreach ($this->fs_map[$path]->children as $entry) { |
|
169 | + if ('.' == $entry->name || '..' == $entry->name) |
|
170 | 170 | continue; |
171 | 171 | |
172 | - if ( ! $include_hidden && '.' == $entry->name ) |
|
172 | + if (!$include_hidden && '.' == $entry->name) |
|
173 | 173 | continue; |
174 | 174 | |
175 | - if ( $limit_file && $entry->name != $limit_file ) |
|
175 | + if ($limit_file && $entry->name != $limit_file) |
|
176 | 176 | continue; |
177 | 177 | |
178 | 178 | $struc = array(); |
179 | 179 | $struc['name'] = $entry->name; |
180 | 180 | $struc['type'] = $entry->type; |
181 | 181 | |
182 | - if ( 'd' == $struc['type'] ) { |
|
183 | - if ( $recursive ) |
|
184 | - $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
182 | + if ('d' == $struc['type']) { |
|
183 | + if ($recursive) |
|
184 | + $struc['files'] = $this->dirlist(trailingslashit($path).trailingslashit($struc['name']), $include_hidden, $recursive); |
|
185 | 185 | else |
186 | 186 | $struc['files'] = array(); |
187 | 187 | } |
188 | 188 | |
189 | - $ret[ $entry->name ] = $struc; |
|
189 | + $ret[$entry->name] = $struc; |
|
190 | 190 | } |
191 | 191 | return $ret; |
192 | 192 | } |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | public $type; // The type of the entry 'f' for file, 'd' for Directory |
199 | 199 | public $path; // The full path to the entry. |
200 | 200 | |
201 | - function __construct( $path ) { |
|
201 | + function __construct($path) { |
|
202 | 202 | $this->path = $path; |
203 | - $this->name = basename( $path ); |
|
203 | + $this->name = basename($path); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | function is_file() { |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | public $type = 'f'; |
222 | 222 | public $contents = ''; // The contents of the file |
223 | 223 | |
224 | - function __construct( $path, $contents = '' ) { |
|
225 | - parent::__construct( $path ); |
|
224 | + function __construct($path, $contents = '') { |
|
225 | + parent::__construct($path); |
|
226 | 226 | $this->contents = $contents; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | \ No newline at end of file |
@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | $type = $upload['type']; |
105 | 105 | } else { |
106 | 106 | $mime = wp_check_filetype( $upload['file'] ); |
107 | - if ($mime) |
|
108 | - $type = $mime['type']; |
|
107 | + if ($mime) { |
|
108 | + $type = $mime['type']; |
|
109 | + } |
|
109 | 110 | } |
110 | 111 | |
111 | 112 | $attachment = array( |
@@ -268,15 +269,17 @@ discard block |
||
268 | 269 | function create_object( $args ) { |
269 | 270 | $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
270 | 271 | $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
271 | - if ( is_wp_error( $term_id_pair ) ) |
|
272 | - return $term_id_pair; |
|
272 | + if ( is_wp_error( $term_id_pair ) ) { |
|
273 | + return $term_id_pair; |
|
274 | + } |
|
273 | 275 | return $term_id_pair['term_id']; |
274 | 276 | } |
275 | 277 | |
276 | 278 | function update_object( $term, $fields ) { |
277 | 279 | $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
278 | - if ( is_object( $term ) ) |
|
279 | - $taxonomy = $term->taxonomy; |
|
280 | + if ( is_object( $term ) ) { |
|
281 | + $taxonomy = $term->taxonomy; |
|
282 | + } |
|
280 | 283 | $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
281 | 284 | return $term_id_pair['term_id']; |
282 | 285 | } |
@@ -318,19 +321,22 @@ discard block |
||
318 | 321 | abstract function update_object( $object, $fields ); |
319 | 322 | |
320 | 323 | function create( $args = array(), $generation_definitions = null ) { |
321 | - if ( is_null( $generation_definitions ) ) |
|
322 | - $generation_definitions = $this->default_generation_definitions; |
|
324 | + if ( is_null( $generation_definitions ) ) { |
|
325 | + $generation_definitions = $this->default_generation_definitions; |
|
326 | + } |
|
323 | 327 | |
324 | 328 | $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
325 | 329 | $created = $this->create_object( $generated_args ); |
326 | - if ( !$created || is_wp_error( $created ) ) |
|
327 | - return $created; |
|
330 | + if ( !$created || is_wp_error( $created ) ) { |
|
331 | + return $created; |
|
332 | + } |
|
328 | 333 | |
329 | 334 | if ( $callbacks ) { |
330 | 335 | $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
331 | 336 | $save_result = $this->update_object( $created, $updated_fields ); |
332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
333 | - return $save_result; |
|
337 | + if ( !$save_result || is_wp_error( $save_result ) ) { |
|
338 | + return $save_result; |
|
339 | + } |
|
334 | 340 | } |
335 | 341 | return $created; |
336 | 342 | } |
@@ -352,20 +358,22 @@ discard block |
||
352 | 358 | |
353 | 359 | function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
354 | 360 | $callbacks = array(); |
355 | - if ( is_null( $generation_definitions ) ) |
|
356 | - $generation_definitions = $this->default_generation_definitions; |
|
361 | + if ( is_null( $generation_definitions ) ) { |
|
362 | + $generation_definitions = $this->default_generation_definitions; |
|
363 | + } |
|
357 | 364 | |
358 | 365 | foreach( array_keys( $generation_definitions ) as $field_name ) { |
359 | 366 | if ( !isset( $args[$field_name] ) ) { |
360 | 367 | $generator = $generation_definitions[$field_name]; |
361 | - if ( is_scalar( $generator ) ) |
|
362 | - $args[$field_name] = $generator; |
|
363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
368 | + if ( is_scalar( $generator ) ) { |
|
369 | + $args[$field_name] = $generator; |
|
370 | + } elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
364 | 371 | $callbacks[$field_name] = $generator; |
365 | - } elseif ( is_object( $generator ) ) |
|
366 | - $args[$field_name] = $generator->next(); |
|
367 | - else |
|
368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
372 | + } elseif ( is_object( $generator ) ) { |
|
373 | + $args[$field_name] = $generator->next(); |
|
374 | + } else { |
|
375 | + return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
376 | + } |
|
369 | 377 | } |
370 | 378 | } |
371 | 379 | return $args; |
@@ -48,78 +48,78 @@ discard block |
||
48 | 48 | public $network; |
49 | 49 | |
50 | 50 | function __construct() { |
51 | - $this->post = new WP_UnitTest_Factory_For_Post( $this ); |
|
52 | - $this->attachment = new WP_UnitTest_Factory_For_Attachment( $this ); |
|
53 | - $this->comment = new WP_UnitTest_Factory_For_Comment( $this ); |
|
54 | - $this->user = new WP_UnitTest_Factory_For_User( $this ); |
|
55 | - $this->term = new WP_UnitTest_Factory_For_Term( $this ); |
|
56 | - $this->category = new WP_UnitTest_Factory_For_Term( $this, 'category' ); |
|
57 | - $this->tag = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' ); |
|
58 | - if ( is_multisite() ) { |
|
59 | - $this->blog = new WP_UnitTest_Factory_For_Blog( $this ); |
|
60 | - $this->network = new WP_UnitTest_Factory_For_Network( $this ); |
|
51 | + $this->post = new WP_UnitTest_Factory_For_Post($this); |
|
52 | + $this->attachment = new WP_UnitTest_Factory_For_Attachment($this); |
|
53 | + $this->comment = new WP_UnitTest_Factory_For_Comment($this); |
|
54 | + $this->user = new WP_UnitTest_Factory_For_User($this); |
|
55 | + $this->term = new WP_UnitTest_Factory_For_Term($this); |
|
56 | + $this->category = new WP_UnitTest_Factory_For_Term($this, 'category'); |
|
57 | + $this->tag = new WP_UnitTest_Factory_For_Term($this, 'post_tag'); |
|
58 | + if (is_multisite()) { |
|
59 | + $this->blog = new WP_UnitTest_Factory_For_Blog($this); |
|
60 | + $this->network = new WP_UnitTest_Factory_For_Network($this); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | 65 | class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { |
66 | 66 | |
67 | - function __construct( $factory = null ) { |
|
68 | - parent::__construct( $factory ); |
|
67 | + function __construct($factory = null) { |
|
68 | + parent::__construct($factory); |
|
69 | 69 | $this->default_generation_definitions = array( |
70 | 70 | 'post_status' => 'publish', |
71 | - 'post_title' => new WP_UnitTest_Generator_Sequence( 'Post title %s' ), |
|
72 | - 'post_content' => new WP_UnitTest_Generator_Sequence( 'Post content %s' ), |
|
73 | - 'post_excerpt' => new WP_UnitTest_Generator_Sequence( 'Post excerpt %s' ), |
|
71 | + 'post_title' => new WP_UnitTest_Generator_Sequence('Post title %s'), |
|
72 | + 'post_content' => new WP_UnitTest_Generator_Sequence('Post content %s'), |
|
73 | + 'post_excerpt' => new WP_UnitTest_Generator_Sequence('Post excerpt %s'), |
|
74 | 74 | 'post_type' => 'post' |
75 | 75 | ); |
76 | 76 | } |
77 | 77 | |
78 | - function create_object( $args ) { |
|
79 | - return wp_insert_post( $args ); |
|
78 | + function create_object($args) { |
|
79 | + return wp_insert_post($args); |
|
80 | 80 | } |
81 | 81 | |
82 | - function update_object( $post_id, $fields ) { |
|
82 | + function update_object($post_id, $fields) { |
|
83 | 83 | $fields['ID'] = $post_id; |
84 | - return wp_update_post( $fields ); |
|
84 | + return wp_update_post($fields); |
|
85 | 85 | } |
86 | 86 | |
87 | - function get_object_by_id( $post_id ) { |
|
88 | - return get_post( $post_id ); |
|
87 | + function get_object_by_id($post_id) { |
|
88 | + return get_post($post_id); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post { |
93 | 93 | |
94 | - function create_object( $file, $parent = 0, $args = array() ) { |
|
95 | - return wp_insert_attachment( $args, $file, $parent ); |
|
94 | + function create_object($file, $parent = 0, $args = array()) { |
|
95 | + return wp_insert_attachment($args, $file, $parent); |
|
96 | 96 | } |
97 | 97 | |
98 | - function create_upload_object( $file, $parent = 0 ) { |
|
98 | + function create_upload_object($file, $parent = 0) { |
|
99 | 99 | $contents = file_get_contents($file); |
100 | 100 | $upload = wp_upload_bits(basename($file), null, $contents); |
101 | 101 | |
102 | 102 | $type = ''; |
103 | - if ( ! empty($upload['type']) ) { |
|
103 | + if (!empty($upload['type'])) { |
|
104 | 104 | $type = $upload['type']; |
105 | 105 | } else { |
106 | - $mime = wp_check_filetype( $upload['file'] ); |
|
106 | + $mime = wp_check_filetype($upload['file']); |
|
107 | 107 | if ($mime) |
108 | 108 | $type = $mime['type']; |
109 | 109 | } |
110 | 110 | |
111 | 111 | $attachment = array( |
112 | - 'post_title' => basename( $upload['file'] ), |
|
112 | + 'post_title' => basename($upload['file']), |
|
113 | 113 | 'post_content' => '', |
114 | 114 | 'post_type' => 'attachment', |
115 | 115 | 'post_parent' => $parent, |
116 | 116 | 'post_mime_type' => $type, |
117 | - 'guid' => $upload[ 'url' ], |
|
117 | + 'guid' => $upload['url'], |
|
118 | 118 | ); |
119 | 119 | |
120 | 120 | // Save the data |
121 | - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent ); |
|
122 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
|
121 | + $id = wp_insert_attachment($attachment, $upload['file'], $parent); |
|
122 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file'])); |
|
123 | 123 | |
124 | 124 | return $id; |
125 | 125 | } |
@@ -127,126 +127,126 @@ discard block |
||
127 | 127 | |
128 | 128 | class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing { |
129 | 129 | |
130 | - function __construct( $factory = null ) { |
|
131 | - parent::__construct( $factory ); |
|
130 | + function __construct($factory = null) { |
|
131 | + parent::__construct($factory); |
|
132 | 132 | $this->default_generation_definitions = array( |
133 | - 'user_login' => new WP_UnitTest_Generator_Sequence( 'User %s' ), |
|
133 | + 'user_login' => new WP_UnitTest_Generator_Sequence('User %s'), |
|
134 | 134 | 'user_pass' => 'password', |
135 | - 'user_email' => new WP_UnitTest_Generator_Sequence( 'user_%[email protected]' ), |
|
135 | + 'user_email' => new WP_UnitTest_Generator_Sequence('user_%[email protected]'), |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | |
139 | - function create_object( $args ) { |
|
140 | - return wp_insert_user( $args ); |
|
139 | + function create_object($args) { |
|
140 | + return wp_insert_user($args); |
|
141 | 141 | } |
142 | 142 | |
143 | - function update_object( $user_id, $fields ) { |
|
143 | + function update_object($user_id, $fields) { |
|
144 | 144 | $fields['ID'] = $user_id; |
145 | - return wp_update_user( $fields ); |
|
145 | + return wp_update_user($fields); |
|
146 | 146 | } |
147 | 147 | |
148 | - function get_object_by_id( $user_id ) { |
|
149 | - return new WP_User( $user_id ); |
|
148 | + function get_object_by_id($user_id) { |
|
149 | + return new WP_User($user_id); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing { |
154 | 154 | |
155 | - function __construct( $factory = null ) { |
|
156 | - parent::__construct( $factory ); |
|
155 | + function __construct($factory = null) { |
|
156 | + parent::__construct($factory); |
|
157 | 157 | $this->default_generation_definitions = array( |
158 | - 'comment_author' => new WP_UnitTest_Generator_Sequence( 'Commenter %s' ), |
|
159 | - 'comment_author_url' => new WP_UnitTest_Generator_Sequence( 'http://example.com/%s/' ), |
|
158 | + 'comment_author' => new WP_UnitTest_Generator_Sequence('Commenter %s'), |
|
159 | + 'comment_author_url' => new WP_UnitTest_Generator_Sequence('http://example.com/%s/'), |
|
160 | 160 | 'comment_approved' => 1, |
161 | 161 | 'comment_content' => 'This is a comment' |
162 | 162 | ); |
163 | 163 | } |
164 | 164 | |
165 | - function create_object( $args ) { |
|
166 | - return wp_insert_comment( $this->addslashes_deep( $args ) ); |
|
165 | + function create_object($args) { |
|
166 | + return wp_insert_comment($this->addslashes_deep($args)); |
|
167 | 167 | } |
168 | 168 | |
169 | - function update_object( $comment_id, $fields ) { |
|
169 | + function update_object($comment_id, $fields) { |
|
170 | 170 | $fields['comment_ID'] = $comment_id; |
171 | - return wp_update_comment( $this->addslashes_deep( $fields ) ); |
|
171 | + return wp_update_comment($this->addslashes_deep($fields)); |
|
172 | 172 | } |
173 | 173 | |
174 | - function create_post_comments( $post_id, $count = 1, $args = array(), $generation_definitions = null ) { |
|
174 | + function create_post_comments($post_id, $count = 1, $args = array(), $generation_definitions = null) { |
|
175 | 175 | $args['comment_post_ID'] = $post_id; |
176 | - return $this->create_many( $count, $args, $generation_definitions ); |
|
176 | + return $this->create_many($count, $args, $generation_definitions); |
|
177 | 177 | } |
178 | 178 | |
179 | - function get_object_by_id( $comment_id ) { |
|
180 | - return get_comment( $comment_id ); |
|
179 | + function get_object_by_id($comment_id) { |
|
180 | + return get_comment($comment_id); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { |
185 | 185 | |
186 | - function __construct( $factory = null ) { |
|
186 | + function __construct($factory = null) { |
|
187 | 187 | global $current_site, $base; |
188 | - parent::__construct( $factory ); |
|
188 | + parent::__construct($factory); |
|
189 | 189 | $this->default_generation_definitions = array( |
190 | 190 | 'domain' => $current_site->domain, |
191 | - 'path' => new WP_UnitTest_Generator_Sequence( $base . 'testpath%s' ), |
|
192 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Site %s' ), |
|
191 | + 'path' => new WP_UnitTest_Generator_Sequence($base.'testpath%s'), |
|
192 | + 'title' => new WP_UnitTest_Generator_Sequence('Site %s'), |
|
193 | 193 | 'site_id' => $current_site->id, |
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | - function create_object( $args ) { |
|
197 | + function create_object($args) { |
|
198 | 198 | global $wpdb; |
199 | - $meta = isset( $args['meta'] ) ? $args['meta'] : array(); |
|
200 | - $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
199 | + $meta = isset($args['meta']) ? $args['meta'] : array(); |
|
200 | + $user_id = isset($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
201 | 201 | // temp tables will trigger db errors when we attempt to reference them as new temp tables |
202 | 202 | $suppress = $wpdb->suppress_errors(); |
203 | - $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); |
|
204 | - $wpdb->suppress_errors( $suppress ); |
|
203 | + $blog = wpmu_create_blog($args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id']); |
|
204 | + $wpdb->suppress_errors($suppress); |
|
205 | 205 | |
206 | 206 | // Tell WP we're done installing. |
207 | - wp_installing( false ); |
|
207 | + wp_installing(false); |
|
208 | 208 | |
209 | 209 | return $blog; |
210 | 210 | } |
211 | 211 | |
212 | - function update_object( $blog_id, $fields ) {} |
|
212 | + function update_object($blog_id, $fields) {} |
|
213 | 213 | |
214 | - function get_object_by_id( $blog_id ) { |
|
215 | - return get_blog_details( $blog_id, false ); |
|
214 | + function get_object_by_id($blog_id) { |
|
215 | + return get_blog_details($blog_id, false); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | 219 | |
220 | 220 | class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing { |
221 | 221 | |
222 | - function __construct( $factory = null ) { |
|
223 | - parent::__construct( $factory ); |
|
222 | + function __construct($factory = null) { |
|
223 | + parent::__construct($factory); |
|
224 | 224 | $this->default_generation_definitions = array( |
225 | 225 | 'domain' => WP_TESTS_DOMAIN, |
226 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Network %s' ), |
|
227 | - 'path' => new WP_UnitTest_Generator_Sequence( '/testpath%s/' ), |
|
228 | - 'network_id' => new WP_UnitTest_Generator_Sequence( '%s', 2 ), |
|
226 | + 'title' => new WP_UnitTest_Generator_Sequence('Network %s'), |
|
227 | + 'path' => new WP_UnitTest_Generator_Sequence('/testpath%s/'), |
|
228 | + 'network_id' => new WP_UnitTest_Generator_Sequence('%s', 2), |
|
229 | 229 | 'subdomain_install' => false, |
230 | 230 | ); |
231 | 231 | } |
232 | 232 | |
233 | - function create_object( $args ) { |
|
234 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
233 | + function create_object($args) { |
|
234 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
235 | 235 | |
236 | - if ( ! isset( $args['user'] ) ) { |
|
236 | + if (!isset($args['user'])) { |
|
237 | 237 | $email = WP_TESTS_EMAIL; |
238 | 238 | } else { |
239 | - $email = get_userdata( $args['user'] )->user_email; |
|
239 | + $email = get_userdata($args['user'])->user_email; |
|
240 | 240 | } |
241 | 241 | |
242 | - populate_network( $args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install'] ); |
|
242 | + populate_network($args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install']); |
|
243 | 243 | return $args['network_id']; |
244 | 244 | } |
245 | 245 | |
246 | - function update_object( $network_id, $fields ) {} |
|
246 | + function update_object($network_id, $fields) {} |
|
247 | 247 | |
248 | - function get_object_by_id( $network_id ) { |
|
249 | - return wp_get_network( $network_id ); |
|
248 | + function get_object_by_id($network_id) { |
|
249 | + return wp_get_network($network_id); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -255,44 +255,44 @@ discard block |
||
255 | 255 | private $taxonomy; |
256 | 256 | const DEFAULT_TAXONOMY = 'post_tag'; |
257 | 257 | |
258 | - function __construct( $factory = null, $taxonomy = null ) { |
|
259 | - parent::__construct( $factory ); |
|
258 | + function __construct($factory = null, $taxonomy = null) { |
|
259 | + parent::__construct($factory); |
|
260 | 260 | $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; |
261 | 261 | $this->default_generation_definitions = array( |
262 | - 'name' => new WP_UnitTest_Generator_Sequence( 'Term %s' ), |
|
262 | + 'name' => new WP_UnitTest_Generator_Sequence('Term %s'), |
|
263 | 263 | 'taxonomy' => $this->taxonomy, |
264 | - 'description' => new WP_UnitTest_Generator_Sequence( 'Term description %s' ), |
|
264 | + 'description' => new WP_UnitTest_Generator_Sequence('Term description %s'), |
|
265 | 265 | ); |
266 | 266 | } |
267 | 267 | |
268 | - function create_object( $args ) { |
|
269 | - $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
|
270 | - $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
|
271 | - if ( is_wp_error( $term_id_pair ) ) |
|
268 | + function create_object($args) { |
|
269 | + $args = array_merge(array('taxonomy' => $this->taxonomy), $args); |
|
270 | + $term_id_pair = wp_insert_term($args['name'], $args['taxonomy'], $args); |
|
271 | + if (is_wp_error($term_id_pair)) |
|
272 | 272 | return $term_id_pair; |
273 | 273 | return $term_id_pair['term_id']; |
274 | 274 | } |
275 | 275 | |
276 | - function update_object( $term, $fields ) { |
|
277 | - $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
|
278 | - if ( is_object( $term ) ) |
|
276 | + function update_object($term, $fields) { |
|
277 | + $fields = array_merge(array('taxonomy' => $this->taxonomy), $fields); |
|
278 | + if (is_object($term)) |
|
279 | 279 | $taxonomy = $term->taxonomy; |
280 | - $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
|
280 | + $term_id_pair = wp_update_term($term, $taxonomy, $fields); |
|
281 | 281 | return $term_id_pair['term_id']; |
282 | 282 | } |
283 | 283 | |
284 | - function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) { |
|
285 | - return wp_set_post_terms( $post_id, $terms, $taxonomy, $append ); |
|
284 | + function add_post_terms($post_id, $terms, $taxonomy, $append = true) { |
|
285 | + return wp_set_post_terms($post_id, $terms, $taxonomy, $append); |
|
286 | 286 | } |
287 | 287 | |
288 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
289 | - $term_id = $this->create( $args, $generation_definitions ); |
|
290 | - $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy; |
|
291 | - return get_term( $term_id, $taxonomy ); |
|
288 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
289 | + $term_id = $this->create($args, $generation_definitions); |
|
290 | + $taxonomy = isset($args['taxonomy']) ? $args['taxonomy'] : $this->taxonomy; |
|
291 | + return get_term($term_id, $taxonomy); |
|
292 | 292 | } |
293 | 293 | |
294 | - function get_object_by_id( $term_id ) { |
|
295 | - return get_term( $term_id, $this->taxonomy ); |
|
294 | + function get_object_by_id($term_id) { |
|
295 | + return get_term($term_id, $this->taxonomy); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
@@ -309,90 +309,90 @@ discard block |
||
309 | 309 | * can be generators -- an object with next() method. There are some default generators: {@link WP_UnitTest_Generator_Sequence}, |
310 | 310 | * {@link WP_UnitTest_Generator_Locale_Name}, {@link WP_UnitTest_Factory_Callback_After_Create}. |
311 | 311 | */ |
312 | - function __construct( $factory, $default_generation_definitions = array() ) { |
|
312 | + function __construct($factory, $default_generation_definitions = array()) { |
|
313 | 313 | $this->factory = $factory; |
314 | 314 | $this->default_generation_definitions = $default_generation_definitions; |
315 | 315 | } |
316 | 316 | |
317 | - abstract function create_object( $args ); |
|
318 | - abstract function update_object( $object, $fields ); |
|
317 | + abstract function create_object($args); |
|
318 | + abstract function update_object($object, $fields); |
|
319 | 319 | |
320 | - function create( $args = array(), $generation_definitions = null ) { |
|
321 | - if ( is_null( $generation_definitions ) ) |
|
320 | + function create($args = array(), $generation_definitions = null) { |
|
321 | + if (is_null($generation_definitions)) |
|
322 | 322 | $generation_definitions = $this->default_generation_definitions; |
323 | 323 | |
324 | - $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
|
325 | - $created = $this->create_object( $generated_args ); |
|
326 | - if ( !$created || is_wp_error( $created ) ) |
|
324 | + $generated_args = $this->generate_args($args, $generation_definitions, $callbacks); |
|
325 | + $created = $this->create_object($generated_args); |
|
326 | + if (!$created || is_wp_error($created)) |
|
327 | 327 | return $created; |
328 | 328 | |
329 | - if ( $callbacks ) { |
|
330 | - $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
|
331 | - $save_result = $this->update_object( $created, $updated_fields ); |
|
332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
329 | + if ($callbacks) { |
|
330 | + $updated_fields = $this->apply_callbacks($callbacks, $created); |
|
331 | + $save_result = $this->update_object($created, $updated_fields); |
|
332 | + if (!$save_result || is_wp_error($save_result)) |
|
333 | 333 | return $save_result; |
334 | 334 | } |
335 | 335 | return $created; |
336 | 336 | } |
337 | 337 | |
338 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
339 | - $object_id = $this->create( $args, $generation_definitions ); |
|
340 | - return $this->get_object_by_id( $object_id ); |
|
338 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
339 | + $object_id = $this->create($args, $generation_definitions); |
|
340 | + return $this->get_object_by_id($object_id); |
|
341 | 341 | } |
342 | 342 | |
343 | - abstract function get_object_by_id( $object_id ); |
|
343 | + abstract function get_object_by_id($object_id); |
|
344 | 344 | |
345 | - function create_many( $count, $args = array(), $generation_definitions = null ) { |
|
345 | + function create_many($count, $args = array(), $generation_definitions = null) { |
|
346 | 346 | $results = array(); |
347 | - for ( $i = 0; $i < $count; $i++ ) { |
|
348 | - $results[] = $this->create( $args, $generation_definitions ); |
|
347 | + for ($i = 0; $i < $count; $i++) { |
|
348 | + $results[] = $this->create($args, $generation_definitions); |
|
349 | 349 | } |
350 | 350 | return $results; |
351 | 351 | } |
352 | 352 | |
353 | - function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
|
353 | + function generate_args($args = array(), $generation_definitions = null, &$callbacks = null) { |
|
354 | 354 | $callbacks = array(); |
355 | - if ( is_null( $generation_definitions ) ) |
|
355 | + if (is_null($generation_definitions)) |
|
356 | 356 | $generation_definitions = $this->default_generation_definitions; |
357 | 357 | |
358 | - foreach( array_keys( $generation_definitions ) as $field_name ) { |
|
359 | - if ( !isset( $args[$field_name] ) ) { |
|
358 | + foreach (array_keys($generation_definitions) as $field_name) { |
|
359 | + if (!isset($args[$field_name])) { |
|
360 | 360 | $generator = $generation_definitions[$field_name]; |
361 | - if ( is_scalar( $generator ) ) |
|
361 | + if (is_scalar($generator)) |
|
362 | 362 | $args[$field_name] = $generator; |
363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
363 | + elseif (is_object($generator) && method_exists($generator, 'call')) { |
|
364 | 364 | $callbacks[$field_name] = $generator; |
365 | - } elseif ( is_object( $generator ) ) |
|
365 | + } elseif (is_object($generator)) |
|
366 | 366 | $args[$field_name] = $generator->next(); |
367 | 367 | else |
368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
368 | + return new WP_Error('invalid_argument', 'Factory default value should be either a scalar or an generator object.'); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | return $args; |
372 | 372 | } |
373 | 373 | |
374 | - function apply_callbacks( $callbacks, $created ) { |
|
374 | + function apply_callbacks($callbacks, $created) { |
|
375 | 375 | $updated_fields = array(); |
376 | - foreach( $callbacks as $field_name => $generator ) { |
|
377 | - $updated_fields[$field_name] = $generator->call( $created ); |
|
376 | + foreach ($callbacks as $field_name => $generator) { |
|
377 | + $updated_fields[$field_name] = $generator->call($created); |
|
378 | 378 | } |
379 | 379 | return $updated_fields; |
380 | 380 | } |
381 | 381 | |
382 | - function callback( $function ) { |
|
383 | - return new WP_UnitTest_Factory_Callback_After_Create( $function ); |
|
382 | + function callback($function) { |
|
383 | + return new WP_UnitTest_Factory_Callback_After_Create($function); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | function addslashes_deep($value) { |
387 | - if ( is_array( $value ) ) { |
|
388 | - $value = array_map( array( $this, 'addslashes_deep' ), $value ); |
|
389 | - } elseif ( is_object( $value ) ) { |
|
390 | - $vars = get_object_vars( $value ); |
|
387 | + if (is_array($value)) { |
|
388 | + $value = array_map(array($this, 'addslashes_deep'), $value); |
|
389 | + } elseif (is_object($value)) { |
|
390 | + $vars = get_object_vars($value); |
|
391 | 391 | foreach ($vars as $key=>$data) { |
392 | - $value->{$key} = $this->addslashes_deep( $data ); |
|
392 | + $value->{$key} = $this->addslashes_deep($data); |
|
393 | 393 | } |
394 | - } elseif ( is_string( $value ) ) { |
|
395 | - $value = addslashes( $value ); |
|
394 | + } elseif (is_string($value)) { |
|
395 | + $value = addslashes($value); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | return $value; |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | public $next; |
406 | 406 | public $template_string; |
407 | 407 | |
408 | - function __construct( $template_string = '%s', $start = null ) { |
|
409 | - if ( $start ) { |
|
408 | + function __construct($template_string = '%s', $start = null) { |
|
409 | + if ($start) { |
|
410 | 410 | $this->next = $start; |
411 | 411 | } else { |
412 | 412 | self::$incr++; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | function next() { |
419 | - $generated = sprintf( $this->template_string , $this->next ); |
|
419 | + $generated = sprintf($this->template_string, $this->next); |
|
420 | 420 | $this->next++; |
421 | 421 | return $generated; |
422 | 422 | } |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | class WP_UnitTest_Factory_Callback_After_Create { |
426 | 426 | var $callback; |
427 | 427 | |
428 | - function __construct( $callback ) { |
|
428 | + function __construct($callback) { |
|
429 | 429 | $this->callback = $callback; |
430 | 430 | } |
431 | 431 | |
432 | - function call( $object ) { |
|
433 | - return call_user_func( $this->callback, $object ); |
|
432 | + function call($object) { |
|
433 | + return call_user_func($this->callback, $object); |
|
434 | 434 | } |
435 | 435 | } |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | class SearchWithKeyword extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testSearchWithKeyword() |
|
10 | - { |
|
11 | - $_REQUEST['geodir_search'] = 1; |
|
12 | - $query_args = array( |
|
13 | - 'post_status' => 'publish', |
|
14 | - 'post_type' => 'gd_place', |
|
15 | - 'posts_per_page' => 1, |
|
16 | - 's' => 'Longwood Gardens' |
|
17 | - ); |
|
9 | + public function testSearchWithKeyword() |
|
10 | + { |
|
11 | + $_REQUEST['geodir_search'] = 1; |
|
12 | + $query_args = array( |
|
13 | + 'post_status' => 'publish', |
|
14 | + 'post_type' => 'gd_place', |
|
15 | + 'posts_per_page' => 1, |
|
16 | + 's' => 'Longwood Gardens' |
|
17 | + ); |
|
18 | 18 | |
19 | - $all_posts = new WP_Query( $query_args ); |
|
19 | + $all_posts = new WP_Query( $query_args ); |
|
20 | 20 | |
21 | - $total_posts = $all_posts->found_posts; |
|
21 | + $total_posts = $all_posts->found_posts; |
|
22 | 22 | |
23 | - $this->assertTrue(is_int((int) $total_posts)); |
|
23 | + $this->assertTrue(is_int((int) $total_posts)); |
|
24 | 24 | |
25 | - $title = null; |
|
26 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
27 | - $title = get_the_title(); |
|
28 | - endwhile; |
|
25 | + $title = null; |
|
26 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
27 | + $title = get_the_title(); |
|
28 | + endwhile; |
|
29 | 29 | |
30 | - $this->assertEquals($title, 'Longwood Gardens'); |
|
31 | - } |
|
30 | + $this->assertEquals($title, 'Longwood Gardens'); |
|
31 | + } |
|
32 | 32 | |
33 | - public function tearDown() |
|
34 | - { |
|
35 | - parent::tearDown(); |
|
36 | - } |
|
33 | + public function tearDown() |
|
34 | + { |
|
35 | + parent::tearDown(); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | ?> |
39 | 39 | \ No newline at end of file |
@@ -16,14 +16,14 @@ |
||
16 | 16 | 's' => 'Longwood Gardens' |
17 | 17 | ); |
18 | 18 | |
19 | - $all_posts = new WP_Query( $query_args ); |
|
19 | + $all_posts = new WP_Query($query_args); |
|
20 | 20 | |
21 | 21 | $total_posts = $all_posts->found_posts; |
22 | 22 | |
23 | 23 | $this->assertTrue(is_int((int) $total_posts)); |
24 | 24 | |
25 | 25 | $title = null; |
26 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
26 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
27 | 27 | $title = get_the_title(); |
28 | 28 | endwhile; |
29 | 29 |
@@ -1,39 +1,39 @@ |
||
1 | 1 | <?php |
2 | 2 | class AddListing extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - wp_set_current_user(1); |
|
8 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + wp_set_current_user(1); |
|
8 | + } |
|
9 | 9 | |
10 | - public function testAddListing() |
|
11 | - { |
|
12 | - $args = array( |
|
13 | - 'listing_type' => 'gd_place', |
|
14 | - 'post_title' => 'Test Listing Title', |
|
15 | - 'post_desc' => 'Test Desc', |
|
16 | - 'post_tags' => 'test1,test2', |
|
17 | - 'post_address' => 'New York City Hall', |
|
18 | - 'post_zip' => '10007', |
|
19 | - 'post_mapview' => 'ROADMAP', |
|
20 | - 'post_mapzoom' => '10', |
|
21 | - 'geodir_timing' => '10.00 am to 6 pm every day', |
|
22 | - 'geodir_contact' => '1234567890', |
|
23 | - 'geodir_email' => '[email protected]', |
|
24 | - 'geodir_website' => 'http://test.com', |
|
25 | - 'geodir_twitter' => 'http://twitter.com/test', |
|
26 | - 'geodir_facebook' => 'http://facebook.com/test', |
|
27 | - 'geodir_special_offers' => 'Test offer' |
|
28 | - ); |
|
29 | - $post_id = geodir_save_listing($args, true); |
|
10 | + public function testAddListing() |
|
11 | + { |
|
12 | + $args = array( |
|
13 | + 'listing_type' => 'gd_place', |
|
14 | + 'post_title' => 'Test Listing Title', |
|
15 | + 'post_desc' => 'Test Desc', |
|
16 | + 'post_tags' => 'test1,test2', |
|
17 | + 'post_address' => 'New York City Hall', |
|
18 | + 'post_zip' => '10007', |
|
19 | + 'post_mapview' => 'ROADMAP', |
|
20 | + 'post_mapzoom' => '10', |
|
21 | + 'geodir_timing' => '10.00 am to 6 pm every day', |
|
22 | + 'geodir_contact' => '1234567890', |
|
23 | + 'geodir_email' => '[email protected]', |
|
24 | + 'geodir_website' => 'http://test.com', |
|
25 | + 'geodir_twitter' => 'http://twitter.com/test', |
|
26 | + 'geodir_facebook' => 'http://facebook.com/test', |
|
27 | + 'geodir_special_offers' => 'Test offer' |
|
28 | + ); |
|
29 | + $post_id = geodir_save_listing($args, true); |
|
30 | 30 | |
31 | - $this->assertTrue(is_int($post_id)); |
|
32 | - } |
|
31 | + $this->assertTrue(is_int($post_id)); |
|
32 | + } |
|
33 | 33 | |
34 | - public function tearDown() |
|
35 | - { |
|
36 | - parent::tearDown(); |
|
37 | - } |
|
34 | + public function tearDown() |
|
35 | + { |
|
36 | + parent::tearDown(); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | \ No newline at end of file |
@@ -1,57 +1,57 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckLoginBox extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testLoginBoxEmptyPassword() |
|
10 | - { |
|
11 | - global $errors; |
|
12 | - $_POST['testcookie'] = 1; |
|
13 | - $_POST['log'] = 'admin'; |
|
14 | - add_filter('wp_redirect', '__return_false'); |
|
15 | - geodir_user_signup(); |
|
16 | - remove_filter('wp_redirect', '__return_false'); |
|
17 | - $errors = (array) $errors; |
|
18 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | - } |
|
9 | + public function testLoginBoxEmptyPassword() |
|
10 | + { |
|
11 | + global $errors; |
|
12 | + $_POST['testcookie'] = 1; |
|
13 | + $_POST['log'] = 'admin'; |
|
14 | + add_filter('wp_redirect', '__return_false'); |
|
15 | + geodir_user_signup(); |
|
16 | + remove_filter('wp_redirect', '__return_false'); |
|
17 | + $errors = (array) $errors; |
|
18 | + $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | + $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | + } |
|
21 | 21 | |
22 | - public function testLoginBoxIncorrectPassword() |
|
23 | - { |
|
24 | - global $errors; |
|
25 | - $_POST['testcookie'] = 1; |
|
26 | - $_REQUEST['action'] = 'login'; |
|
27 | - $_POST['log'] = 'testuser'; |
|
28 | - $_POST['pwd'] = 'admin'; |
|
29 | - add_filter('wp_redirect', '__return_false'); |
|
30 | - geodir_user_signup(); |
|
31 | - remove_filter('wp_redirect', '__return_false'); |
|
32 | - $errors = (array) $errors; |
|
33 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
35 | - } |
|
22 | + public function testLoginBoxIncorrectPassword() |
|
23 | + { |
|
24 | + global $errors; |
|
25 | + $_POST['testcookie'] = 1; |
|
26 | + $_REQUEST['action'] = 'login'; |
|
27 | + $_POST['log'] = 'testuser'; |
|
28 | + $_POST['pwd'] = 'admin'; |
|
29 | + add_filter('wp_redirect', '__return_false'); |
|
30 | + geodir_user_signup(); |
|
31 | + remove_filter('wp_redirect', '__return_false'); |
|
32 | + $errors = (array) $errors; |
|
33 | + $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | + $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
35 | + } |
|
36 | 36 | |
37 | - public function testLoginBoxInvalidUsername() |
|
38 | - { |
|
39 | - global $errors; |
|
40 | - $_POST['testcookie'] = 1; |
|
41 | - $_REQUEST['action'] = 'login'; |
|
42 | - $_POST['log'] = 'adm##@in'; |
|
43 | - $_POST['pwd'] = 'admin'; |
|
44 | - add_filter('wp_redirect', '__return_false'); |
|
45 | - geodir_user_signup(); |
|
46 | - remove_filter('wp_redirect', '__return_false'); |
|
47 | - $errors = (array) $errors; |
|
48 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
49 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
50 | - } |
|
37 | + public function testLoginBoxInvalidUsername() |
|
38 | + { |
|
39 | + global $errors; |
|
40 | + $_POST['testcookie'] = 1; |
|
41 | + $_REQUEST['action'] = 'login'; |
|
42 | + $_POST['log'] = 'adm##@in'; |
|
43 | + $_POST['pwd'] = 'admin'; |
|
44 | + add_filter('wp_redirect', '__return_false'); |
|
45 | + geodir_user_signup(); |
|
46 | + remove_filter('wp_redirect', '__return_false'); |
|
47 | + $errors = (array) $errors; |
|
48 | + $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
49 | + $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
50 | + } |
|
51 | 51 | |
52 | - public function tearDown() |
|
53 | - { |
|
54 | - parent::tearDown(); |
|
55 | - } |
|
52 | + public function tearDown() |
|
53 | + { |
|
54 | + parent::tearDown(); |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | \ No newline at end of file |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | geodir_user_signup(); |
16 | 16 | remove_filter('wp_redirect', '__return_false'); |
17 | 17 | $errors = (array) $errors; |
18 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
18 | + $this->assertArrayHasKey('empty_password', $errors["errors"]); |
|
19 | + $this->assertContains('The password field is empty', $errors["errors"]["empty_password"][0]); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function testLoginBoxIncorrectPassword() |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | geodir_user_signup(); |
31 | 31 | remove_filter('wp_redirect', '__return_false'); |
32 | 32 | $errors = (array) $errors; |
33 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
33 | + $this->assertArrayHasKey('incorrect_password', $errors["errors"]); |
|
34 | + $this->assertContains('The password you entered for the username', $errors["errors"]["incorrect_password"][0]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function testLoginBoxInvalidUsername() |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | geodir_user_signup(); |
46 | 46 | remove_filter('wp_redirect', '__return_false'); |
47 | 47 | $errors = (array) $errors; |
48 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
49 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
48 | + $this->assertArrayHasKey('invalid_username', $errors["errors"]); |
|
49 | + $this->assertContains('Invalid username', $errors["errors"]["invalid_username"][0]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function tearDown() |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | geodir_user_signup(); |
17 | 17 | remove_filter('wp_redirect', '__return_false'); |
18 | 18 | $errors = (array) $errors; |
19 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
20 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
19 | + $this->assertArrayHasKey('empty_password', $errors["errors"]); |
|
20 | + $this->assertContains('The password field is empty', $errors["errors"]["empty_password"][0]); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function testLoginIncorrectPassword() |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | geodir_user_signup(); |
31 | 31 | remove_filter('wp_redirect', '__return_false'); |
32 | 32 | $errors = (array) $errors; |
33 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
33 | + $this->assertArrayHasKey('incorrect_password', $errors["errors"]); |
|
34 | + $this->assertContains('The password you entered for the username', $errors["errors"]["incorrect_password"][0]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function testLoginInvalidUsername() |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | geodir_user_signup(); |
45 | 45 | remove_filter('wp_redirect', '__return_false'); |
46 | 46 | $errors = (array) $errors; |
47 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
48 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
47 | + $this->assertArrayHasKey('invalid_username', $errors["errors"]); |
|
48 | + $this->assertContains('Invalid username', $errors["errors"]["invalid_username"][0]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // public function testLoginValid() |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | geodir_user_signup(); |
71 | 71 | remove_filter('wp_redirect', '__return_false'); |
72 | 72 | $errors = (array) $errors; |
73 | - $this->assertArrayHasKey( 'empty_username', $errors["errors"] ); |
|
74 | - $this->assertContains( 'Enter a username or e-mail address', $errors["errors"]["empty_username"][0] ); |
|
73 | + $this->assertArrayHasKey('empty_username', $errors["errors"]); |
|
74 | + $this->assertContains('Enter a username or e-mail address', $errors["errors"]["empty_username"][0]); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function testForgotPassInvalidEmail() |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | geodir_user_signup(); |
86 | 86 | remove_filter('wp_redirect', '__return_false'); |
87 | 87 | $errors = (array) $errors; |
88 | - $this->assertArrayHasKey( 'invalid_email', $errors["errors"] ); |
|
89 | - $this->assertContains( 'There is no user registered with that email address', $errors["errors"]["invalid_email"][0] ); |
|
88 | + $this->assertArrayHasKey('invalid_email', $errors["errors"]); |
|
89 | + $this->assertContains('There is no user registered with that email address', $errors["errors"]["invalid_email"][0]); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | public function testForgotPassInvalidUsername() |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | geodir_user_signup(); |
101 | 101 | remove_filter('wp_redirect', '__return_false'); |
102 | 102 | $errors = (array) $errors; |
103 | - $this->assertArrayHasKey( 'invalidcombo', $errors["errors"] ); |
|
104 | - $this->assertContains( 'Invalid username or e-mail', $errors["errors"]["invalidcombo"][0] ); |
|
103 | + $this->assertArrayHasKey('invalidcombo', $errors["errors"]); |
|
104 | + $this->assertContains('Invalid username or e-mail', $errors["errors"]["invalidcombo"][0]); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function tearDown() |
@@ -1,51 +1,51 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class LoginUser extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testLoginEmptyPassword() |
|
10 | - { |
|
11 | - global $errors; |
|
12 | - $_REQUEST['action'] = 'login'; |
|
13 | - $_POST['log'] = 'admin'; |
|
14 | - add_filter('wp_redirect', '__return_false'); |
|
15 | - geodir_user_signup(); |
|
16 | - remove_filter('wp_redirect', '__return_false'); |
|
17 | - $errors = (array) $errors; |
|
18 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | - } |
|
9 | + public function testLoginEmptyPassword() |
|
10 | + { |
|
11 | + global $errors; |
|
12 | + $_REQUEST['action'] = 'login'; |
|
13 | + $_POST['log'] = 'admin'; |
|
14 | + add_filter('wp_redirect', '__return_false'); |
|
15 | + geodir_user_signup(); |
|
16 | + remove_filter('wp_redirect', '__return_false'); |
|
17 | + $errors = (array) $errors; |
|
18 | + $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | + $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | + } |
|
21 | 21 | |
22 | - public function testLoginIncorrectPassword() |
|
23 | - { |
|
24 | - global $errors; |
|
25 | - $_REQUEST['action'] = 'login'; |
|
26 | - $_POST['log'] = 'testuser'; |
|
27 | - $_POST['pwd'] = 'admin'; |
|
28 | - add_filter('wp_redirect', '__return_false'); |
|
29 | - geodir_user_signup(); |
|
30 | - remove_filter('wp_redirect', '__return_false'); |
|
31 | - $errors = (array) $errors; |
|
32 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
33 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
34 | - } |
|
22 | + public function testLoginIncorrectPassword() |
|
23 | + { |
|
24 | + global $errors; |
|
25 | + $_REQUEST['action'] = 'login'; |
|
26 | + $_POST['log'] = 'testuser'; |
|
27 | + $_POST['pwd'] = 'admin'; |
|
28 | + add_filter('wp_redirect', '__return_false'); |
|
29 | + geodir_user_signup(); |
|
30 | + remove_filter('wp_redirect', '__return_false'); |
|
31 | + $errors = (array) $errors; |
|
32 | + $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
33 | + $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
34 | + } |
|
35 | 35 | |
36 | - public function testLoginInvalidUsername() |
|
37 | - { |
|
38 | - global $errors; |
|
39 | - $_REQUEST['action'] = 'login'; |
|
40 | - $_POST['log'] = 'adm##@in'; |
|
41 | - $_POST['pwd'] = 'admin'; |
|
42 | - add_filter('wp_redirect', '__return_false'); |
|
43 | - geodir_user_signup(); |
|
44 | - remove_filter('wp_redirect', '__return_false'); |
|
45 | - $errors = (array) $errors; |
|
46 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
47 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
48 | - } |
|
36 | + public function testLoginInvalidUsername() |
|
37 | + { |
|
38 | + global $errors; |
|
39 | + $_REQUEST['action'] = 'login'; |
|
40 | + $_POST['log'] = 'adm##@in'; |
|
41 | + $_POST['pwd'] = 'admin'; |
|
42 | + add_filter('wp_redirect', '__return_false'); |
|
43 | + geodir_user_signup(); |
|
44 | + remove_filter('wp_redirect', '__return_false'); |
|
45 | + $errors = (array) $errors; |
|
46 | + $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
47 | + $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | // public function testLoginValid() |
51 | 51 | // { |
@@ -58,55 +58,55 @@ discard block |
||
58 | 58 | // remove_filter('wp_redirect', '__return_false'); |
59 | 59 | // } |
60 | 60 | |
61 | - public function testForgotPassEmptyData() |
|
62 | - { |
|
63 | - global $errors; |
|
64 | - $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
65 | - $_REQUEST['action'] = 'retrievepassword'; |
|
66 | - $_POST['user_login'] = ''; |
|
67 | - $_POST['user_email'] = ''; |
|
68 | - add_filter('wp_redirect', '__return_false'); |
|
69 | - geodir_user_signup(); |
|
70 | - remove_filter('wp_redirect', '__return_false'); |
|
71 | - $errors = (array) $errors; |
|
72 | - $this->assertArrayHasKey( 'empty_username', $errors["errors"] ); |
|
73 | - $this->assertContains( 'Enter a username or e-mail address', $errors["errors"]["empty_username"][0] ); |
|
74 | - } |
|
61 | + public function testForgotPassEmptyData() |
|
62 | + { |
|
63 | + global $errors; |
|
64 | + $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
65 | + $_REQUEST['action'] = 'retrievepassword'; |
|
66 | + $_POST['user_login'] = ''; |
|
67 | + $_POST['user_email'] = ''; |
|
68 | + add_filter('wp_redirect', '__return_false'); |
|
69 | + geodir_user_signup(); |
|
70 | + remove_filter('wp_redirect', '__return_false'); |
|
71 | + $errors = (array) $errors; |
|
72 | + $this->assertArrayHasKey( 'empty_username', $errors["errors"] ); |
|
73 | + $this->assertContains( 'Enter a username or e-mail address', $errors["errors"]["empty_username"][0] ); |
|
74 | + } |
|
75 | 75 | |
76 | - public function testForgotPassInvalidEmail() |
|
77 | - { |
|
78 | - global $errors; |
|
79 | - $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
80 | - $_REQUEST['action'] = 'retrievepassword'; |
|
81 | - $_POST['user_login'] = '[email protected]'; |
|
82 | - $_POST['user_email'] = ''; |
|
83 | - add_filter('wp_redirect', '__return_false'); |
|
84 | - geodir_user_signup(); |
|
85 | - remove_filter('wp_redirect', '__return_false'); |
|
86 | - $errors = (array) $errors; |
|
87 | - $this->assertArrayHasKey( 'invalid_email', $errors["errors"] ); |
|
88 | - $this->assertContains( 'There is no user registered with that email address', $errors["errors"]["invalid_email"][0] ); |
|
89 | - } |
|
76 | + public function testForgotPassInvalidEmail() |
|
77 | + { |
|
78 | + global $errors; |
|
79 | + $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
80 | + $_REQUEST['action'] = 'retrievepassword'; |
|
81 | + $_POST['user_login'] = '[email protected]'; |
|
82 | + $_POST['user_email'] = ''; |
|
83 | + add_filter('wp_redirect', '__return_false'); |
|
84 | + geodir_user_signup(); |
|
85 | + remove_filter('wp_redirect', '__return_false'); |
|
86 | + $errors = (array) $errors; |
|
87 | + $this->assertArrayHasKey( 'invalid_email', $errors["errors"] ); |
|
88 | + $this->assertContains( 'There is no user registered with that email address', $errors["errors"]["invalid_email"][0] ); |
|
89 | + } |
|
90 | 90 | |
91 | - public function testForgotPassInvalidUsername() |
|
92 | - { |
|
93 | - global $errors; |
|
94 | - $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
95 | - $_REQUEST['action'] = 'retrievepassword'; |
|
96 | - $_POST['user_login'] = 'holla'; |
|
97 | - $_POST['user_email'] = '[email protected]'; |
|
98 | - add_filter('wp_redirect', '__return_false'); |
|
99 | - geodir_user_signup(); |
|
100 | - remove_filter('wp_redirect', '__return_false'); |
|
101 | - $errors = (array) $errors; |
|
102 | - $this->assertArrayHasKey( 'invalidcombo', $errors["errors"] ); |
|
103 | - $this->assertContains( 'Invalid username or e-mail', $errors["errors"]["invalidcombo"][0] ); |
|
104 | - } |
|
91 | + public function testForgotPassInvalidUsername() |
|
92 | + { |
|
93 | + global $errors; |
|
94 | + $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
95 | + $_REQUEST['action'] = 'retrievepassword'; |
|
96 | + $_POST['user_login'] = 'holla'; |
|
97 | + $_POST['user_email'] = '[email protected]'; |
|
98 | + add_filter('wp_redirect', '__return_false'); |
|
99 | + geodir_user_signup(); |
|
100 | + remove_filter('wp_redirect', '__return_false'); |
|
101 | + $errors = (array) $errors; |
|
102 | + $this->assertArrayHasKey( 'invalidcombo', $errors["errors"] ); |
|
103 | + $this->assertContains( 'Invalid username or e-mail', $errors["errors"]["invalidcombo"][0] ); |
|
104 | + } |
|
105 | 105 | |
106 | - public function tearDown() |
|
107 | - { |
|
108 | - parent::tearDown(); |
|
109 | - } |
|
106 | + public function tearDown() |
|
107 | + { |
|
108 | + parent::tearDown(); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | ?> |
113 | 113 | \ No newline at end of file |
@@ -1,63 +1,63 @@ |
||
1 | 1 | <?php |
2 | 2 | class EditListing extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - wp_set_current_user(1); |
|
8 | - } |
|
9 | - |
|
10 | - public function testEditListing() |
|
11 | - { |
|
12 | - $query_args = array( |
|
13 | - 'post_status' => 'publish', |
|
14 | - 'post_type' => 'gd_place', |
|
15 | - 'posts_per_page' => 1, |
|
16 | - ); |
|
17 | - |
|
18 | - $all_posts = new WP_Query( $query_args ); |
|
19 | - $post_id = null; |
|
20 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
21 | - $post_id = get_the_ID(); |
|
22 | - endwhile; |
|
23 | - |
|
24 | - $this->assertTrue(is_int($post_id)); |
|
25 | - |
|
26 | - $args = array( |
|
27 | - 'pid' => $post_id, |
|
28 | - 'listing_type' => 'gd_place', |
|
29 | - 'post_title' => 'Test Listing Title Modified', |
|
30 | - 'post_desc' => 'Test Desc', |
|
31 | - 'post_tags' => 'test1,test2', |
|
32 | - 'post_address' => 'New York City Hall', |
|
33 | - 'post_zip' => '10007', |
|
34 | - 'post_latitude' => '40.7127837', |
|
35 | - 'post_longitude' => '-74.00594130000002', |
|
36 | - 'post_mapview' => 'ROADMAP', |
|
37 | - 'post_mapzoom' => '10', |
|
38 | - 'geodir_timing' => '10.00 am to 6 pm every day', |
|
39 | - 'geodir_contact' => '1234567890', |
|
40 | - 'geodir_email' => '[email protected]', |
|
41 | - 'geodir_website' => 'http://test.com', |
|
42 | - 'geodir_twitter' => 'http://twitter.com/test', |
|
43 | - 'geodir_facebook' => 'http://facebook.com/test', |
|
44 | - 'geodir_special_offers' => 'Test offer' |
|
45 | - ); |
|
46 | - $saved_post_id = geodir_save_listing($args, true); |
|
47 | - |
|
48 | - $this->assertTrue(is_int($saved_post_id)); |
|
49 | - |
|
50 | - $title = get_the_title($post_id); |
|
51 | - |
|
52 | - $this->assertEquals('Test Listing Title Modified', $title); |
|
53 | - |
|
54 | - |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - public function tearDown() |
|
59 | - { |
|
60 | - parent::tearDown(); |
|
61 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + wp_set_current_user(1); |
|
8 | + } |
|
9 | + |
|
10 | + public function testEditListing() |
|
11 | + { |
|
12 | + $query_args = array( |
|
13 | + 'post_status' => 'publish', |
|
14 | + 'post_type' => 'gd_place', |
|
15 | + 'posts_per_page' => 1, |
|
16 | + ); |
|
17 | + |
|
18 | + $all_posts = new WP_Query( $query_args ); |
|
19 | + $post_id = null; |
|
20 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
21 | + $post_id = get_the_ID(); |
|
22 | + endwhile; |
|
23 | + |
|
24 | + $this->assertTrue(is_int($post_id)); |
|
25 | + |
|
26 | + $args = array( |
|
27 | + 'pid' => $post_id, |
|
28 | + 'listing_type' => 'gd_place', |
|
29 | + 'post_title' => 'Test Listing Title Modified', |
|
30 | + 'post_desc' => 'Test Desc', |
|
31 | + 'post_tags' => 'test1,test2', |
|
32 | + 'post_address' => 'New York City Hall', |
|
33 | + 'post_zip' => '10007', |
|
34 | + 'post_latitude' => '40.7127837', |
|
35 | + 'post_longitude' => '-74.00594130000002', |
|
36 | + 'post_mapview' => 'ROADMAP', |
|
37 | + 'post_mapzoom' => '10', |
|
38 | + 'geodir_timing' => '10.00 am to 6 pm every day', |
|
39 | + 'geodir_contact' => '1234567890', |
|
40 | + 'geodir_email' => '[email protected]', |
|
41 | + 'geodir_website' => 'http://test.com', |
|
42 | + 'geodir_twitter' => 'http://twitter.com/test', |
|
43 | + 'geodir_facebook' => 'http://facebook.com/test', |
|
44 | + 'geodir_special_offers' => 'Test offer' |
|
45 | + ); |
|
46 | + $saved_post_id = geodir_save_listing($args, true); |
|
47 | + |
|
48 | + $this->assertTrue(is_int($saved_post_id)); |
|
49 | + |
|
50 | + $title = get_the_title($post_id); |
|
51 | + |
|
52 | + $this->assertEquals('Test Listing Title Modified', $title); |
|
53 | + |
|
54 | + |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + public function tearDown() |
|
59 | + { |
|
60 | + parent::tearDown(); |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | ?> |
64 | 64 | \ No newline at end of file |
@@ -15,9 +15,9 @@ |
||
15 | 15 | 'posts_per_page' => 1, |
16 | 16 | ); |
17 | 17 | |
18 | - $all_posts = new WP_Query( $query_args ); |
|
18 | + $all_posts = new WP_Query($query_args); |
|
19 | 19 | $post_id = null; |
20 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
20 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
21 | 21 | $post_id = get_the_ID(); |
22 | 22 | endwhile; |
23 | 23 |