@@ -10,6 +10,9 @@ discard block |
||
10 | 10 | return true; |
11 | 11 | } |
12 | 12 | |
13 | +/** |
|
14 | + * @param integer $priority |
|
15 | + */ |
|
13 | 16 | function _test_filter_build_unique_id($tag, $function, $priority) { |
14 | 17 | global $wp_filter; |
15 | 18 | static $filter_id_count = 0; |
@@ -92,6 +95,9 @@ discard block |
||
92 | 95 | return '_wp_die_handler'; |
93 | 96 | } |
94 | 97 | |
98 | +/** |
|
99 | + * @param string $title |
|
100 | + */ |
|
95 | 101 | function _wp_die_handler_txt( $message, $title, $args ) { |
96 | 102 | echo "\nwp_die called\n"; |
97 | 103 | echo "Message : $message\n"; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | global $wp_filter; |
15 | 15 | static $filter_id_count = 0; |
16 | 16 | |
17 | - if ( is_string($function) ) |
|
18 | - return $function; |
|
17 | + if ( is_string($function) ) { |
|
18 | + return $function; |
|
19 | + } |
|
19 | 20 | |
20 | 21 | if ( is_object($function) ) { |
21 | 22 | // Closures are currently implemented as objects |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | |
38 | 39 | $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}"); |
39 | 40 | if ($all_posts) { |
40 | - foreach ($all_posts as $id) |
|
41 | - wp_delete_post( $id, true ); |
|
41 | + foreach ($all_posts as $id) { |
|
42 | + wp_delete_post( $id, true ); |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | } |
44 | 46 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | |
7 | 7 | $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority); |
8 | 8 | $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
9 | - unset( $merged_filters[ $tag ] ); |
|
9 | + unset($merged_filters[$tag]); |
|
10 | 10 | return true; |
11 | 11 | } |
12 | 12 | |
@@ -14,19 +14,19 @@ discard block |
||
14 | 14 | global $wp_filter; |
15 | 15 | static $filter_id_count = 0; |
16 | 16 | |
17 | - if ( is_string($function) ) |
|
17 | + if (is_string($function)) |
|
18 | 18 | return $function; |
19 | 19 | |
20 | - if ( is_object($function) ) { |
|
20 | + if (is_object($function)) { |
|
21 | 21 | // Closures are currently implemented as objects |
22 | - $function = array( $function, '' ); |
|
22 | + $function = array($function, ''); |
|
23 | 23 | } else { |
24 | 24 | $function = (array) $function; |
25 | 25 | } |
26 | 26 | |
27 | - if (is_object($function[0]) ) { |
|
28 | - return spl_object_hash($function[0]) . $function[1]; |
|
29 | - } else if ( is_string($function[0]) ) { |
|
27 | + if (is_object($function[0])) { |
|
28 | + return spl_object_hash($function[0]).$function[1]; |
|
29 | + } else if (is_string($function[0])) { |
|
30 | 30 | // Static Calling |
31 | 31 | return $function[0].$function[1]; |
32 | 32 | } |
@@ -38,31 +38,31 @@ discard block |
||
38 | 38 | $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}"); |
39 | 39 | if ($all_posts) { |
40 | 40 | foreach ($all_posts as $id) |
41 | - wp_delete_post( $id, true ); |
|
41 | + wp_delete_post($id, true); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | class Basic_Object { |
46 | 46 | private $foo = 'bar'; |
47 | 47 | |
48 | - public function __get( $name ) { |
|
48 | + public function __get($name) { |
|
49 | 49 | return $this->{$name}; |
50 | 50 | } |
51 | 51 | |
52 | - public function __set( $name, $value ) { |
|
52 | + public function __set($name, $value) { |
|
53 | 53 | return $this->{$name} = $value; |
54 | 54 | } |
55 | 55 | |
56 | - public function __isset( $name ) { |
|
57 | - return isset( $this->{$name} ); |
|
56 | + public function __isset($name) { |
|
57 | + return isset($this->{$name} ); |
|
58 | 58 | } |
59 | 59 | |
60 | - public function __unset( $name ) { |
|
61 | - unset( $this->{$name} ); |
|
60 | + public function __unset($name) { |
|
61 | + unset($this->{$name} ); |
|
62 | 62 | } |
63 | 63 | |
64 | - public function __call( $name, $arguments ) { |
|
65 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
64 | + public function __call($name, $arguments) { |
|
65 | + return call_user_func_array(array($this, $name), $arguments); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | private function callMe() { |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | class Basic_Subclass extends Basic_Object {} |
74 | 74 | |
75 | -function _wp_die_handler( $message, $title = '', $args = array() ) { |
|
76 | - if ( !$GLOBALS['_wp_die_disabled'] ) { |
|
77 | - _wp_die_handler_txt( $message, $title, $args); |
|
75 | +function _wp_die_handler($message, $title = '', $args = array()) { |
|
76 | + if (!$GLOBALS['_wp_die_disabled']) { |
|
77 | + _wp_die_handler_txt($message, $title, $args); |
|
78 | 78 | } else { |
79 | 79 | //Ignore at our peril |
80 | 80 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | return '_wp_die_handler'; |
93 | 93 | } |
94 | 94 | |
95 | -function _wp_die_handler_txt( $message, $title, $args ) { |
|
95 | +function _wp_die_handler_txt($message, $title, $args) { |
|
96 | 96 | echo "\nwp_die called\n"; |
97 | 97 | echo "Message : $message\n"; |
98 | 98 | echo "Title : $title\n"; |
99 | - if ( ! empty( $args ) ) { |
|
99 | + if (!empty($args)) { |
|
100 | 100 | echo "Args: \n"; |
101 | - foreach( $args as $k => $v ){ |
|
101 | + foreach ($args as $k => $v) { |
|
102 | 102 | echo "\t $k : $v\n"; |
103 | 103 | } |
104 | 104 | } |
@@ -113,5 +113,5 @@ discard block |
||
113 | 113 | * @since 4.2.0 |
114 | 114 | */ |
115 | 115 | function _set_default_permalink_structure_for_tests() { |
116 | - update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' ); |
|
116 | + update_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); |
|
117 | 117 | } |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | /** |
51 | 51 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
52 | + * @param string $paths |
|
52 | 53 | */ |
53 | 54 | function setfs( $paths ) { |
54 | 55 | if ( ! is_array($paths) ) |
@@ -144,6 +145,9 @@ discard block |
||
144 | 145 | return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); |
145 | 146 | } |
146 | 147 | |
148 | + /** |
|
149 | + * @param string $path |
|
150 | + */ |
|
147 | 151 | function is_dir( $path ) { |
148 | 152 | $path = trailingslashit( $path ); |
149 | 153 |
@@ -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 |
@@ -336,8 +336,6 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @since 4.2.0 |
338 | 338 | * |
339 | - * @param string $deprecated Name of the function, method, or class that appears in the first argument of the |
|
340 | - * source `_doing_it_wrong()` call. |
|
341 | 339 | */ |
342 | 340 | public function setExpectedIncorrectUsage( $doing_it_wrong ) { |
343 | 341 | array_push( $this->expected_doing_it_wrong, $doing_it_wrong ); |
@@ -525,7 +523,6 @@ discard block |
||
525 | 523 | * expected to be false. For example, assertQueryTrue('is_single', 'is_feed') means is_single() |
526 | 524 | * and is_feed() must be true and everything else must be false to pass. |
527 | 525 | * |
528 | - * @param string $prop,... Any number of WP_Query properties that are expected to be true for the current request. |
|
529 | 526 | */ |
530 | 527 | function assertQueryTrue(/* ... */) { |
531 | 528 | global $wp_query; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | function __get( $name ) { |
22 | 22 | if ( 'factory' === $name ) { |
23 | 23 | return self::factory(); |
24 | - } |
|
24 | + } |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | protected static function factory() { |
@@ -256,14 +256,16 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | function _create_temporary_tables( $query ) { |
259 | - if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) |
|
260 | - return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); |
|
259 | + if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) { |
|
260 | + return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); |
|
261 | + } |
|
261 | 262 | return $query; |
262 | 263 | } |
263 | 264 | |
264 | 265 | function _drop_temporary_tables( $query ) { |
265 | - if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) |
|
266 | - return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); |
|
266 | + if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) { |
|
267 | + return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); |
|
268 | + } |
|
267 | 269 | return $query; |
268 | 270 | } |
269 | 271 | |
@@ -278,10 +280,12 @@ discard block |
||
278 | 280 | function expectDeprecated() { |
279 | 281 | $annotations = $this->getAnnotations(); |
280 | 282 | foreach ( array( 'class', 'method' ) as $depth ) { |
281 | - if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) |
|
282 | - $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); |
|
283 | - if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) |
|
284 | - $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); |
|
283 | + if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) { |
|
284 | + $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); |
|
285 | + } |
|
286 | + if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) { |
|
287 | + $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); |
|
288 | + } |
|
285 | 289 | } |
286 | 290 | add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); |
287 | 291 | add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) ); |
@@ -344,13 +348,15 @@ discard block |
||
344 | 348 | } |
345 | 349 | |
346 | 350 | function deprecated_function_run( $function ) { |
347 | - if ( ! in_array( $function, $this->caught_deprecated ) ) |
|
348 | - $this->caught_deprecated[] = $function; |
|
351 | + if ( ! in_array( $function, $this->caught_deprecated ) ) { |
|
352 | + $this->caught_deprecated[] = $function; |
|
353 | + } |
|
349 | 354 | } |
350 | 355 | |
351 | 356 | function doing_it_wrong_run( $function ) { |
352 | - if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) |
|
353 | - $this->caught_doing_it_wrong[] = $function; |
|
357 | + if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) { |
|
358 | + $this->caught_doing_it_wrong[] = $function; |
|
359 | + } |
|
354 | 360 | } |
355 | 361 | |
356 | 362 | function assertWPError( $actual, $message = '' ) { |
@@ -394,7 +400,9 @@ discard block |
||
394 | 400 | // to run them more than once without very carefully clearing everything |
395 | 401 | $_GET = $_POST = array(); |
396 | 402 | foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) { |
397 | - if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] ); |
|
403 | + if ( isset( $GLOBALS[$v] ) ) { |
|
404 | + unset( $GLOBALS[$v] ); |
|
405 | + } |
|
398 | 406 | } |
399 | 407 | $parts = parse_url($url); |
400 | 408 | if (isset($parts['scheme'])) { |
@@ -439,20 +447,23 @@ discard block |
||
439 | 447 | return; |
440 | 448 | } |
441 | 449 | |
442 | - if ( WP_TESTS_FORCE_KNOWN_BUGS ) |
|
443 | - return; |
|
450 | + if ( WP_TESTS_FORCE_KNOWN_BUGS ) { |
|
451 | + return; |
|
452 | + } |
|
444 | 453 | $tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) ); |
445 | 454 | foreach ( $tickets as $ticket ) { |
446 | 455 | if ( is_numeric( $ticket ) ) { |
447 | 456 | $this->knownWPBug( $ticket ); |
448 | 457 | } elseif ( 'UT' == substr( $ticket, 0, 2 ) ) { |
449 | 458 | $ticket = substr( $ticket, 2 ); |
450 | - if ( $ticket && is_numeric( $ticket ) ) |
|
451 | - $this->knownUTBug( $ticket ); |
|
459 | + if ( $ticket && is_numeric( $ticket ) ) { |
|
460 | + $this->knownUTBug( $ticket ); |
|
461 | + } |
|
452 | 462 | } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) { |
453 | 463 | $ticket = substr( $ticket, 6 ); |
454 | - if ( $ticket && is_numeric( $ticket ) ) |
|
455 | - $this->knownPluginBug( $ticket ); |
|
464 | + if ( $ticket && is_numeric( $ticket ) ) { |
|
465 | + $this->knownPluginBug( $ticket ); |
|
466 | + } |
|
456 | 467 | } |
457 | 468 | } |
458 | 469 | } |
@@ -461,30 +472,36 @@ discard block |
||
461 | 472 | * Skips the current test if there is an open WordPress ticket with id $ticket_id |
462 | 473 | */ |
463 | 474 | function knownWPBug( $ticket_id ) { |
464 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) |
|
465 | - return; |
|
466 | - if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) |
|
467 | - $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) ); |
|
475 | + if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) { |
|
476 | + return; |
|
477 | + } |
|
478 | + if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) { |
|
479 | + $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) ); |
|
480 | + } |
|
468 | 481 | } |
469 | 482 | |
470 | 483 | /** |
471 | 484 | * Skips the current test if there is an open unit tests ticket with id $ticket_id |
472 | 485 | */ |
473 | 486 | function knownUTBug( $ticket_id ) { |
474 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) |
|
475 | - return; |
|
476 | - if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) |
|
477 | - $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) ); |
|
487 | + if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) { |
|
488 | + return; |
|
489 | + } |
|
490 | + if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) { |
|
491 | + $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) ); |
|
492 | + } |
|
478 | 493 | } |
479 | 494 | |
480 | 495 | /** |
481 | 496 | * Skips the current test if there is an open plugin ticket with id $ticket_id |
482 | 497 | */ |
483 | 498 | function knownPluginBug( $ticket_id ) { |
484 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) |
|
485 | - return; |
|
486 | - if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) |
|
487 | - $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) ); |
|
499 | + if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) { |
|
500 | + return; |
|
501 | + } |
|
502 | + if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) { |
|
503 | + $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) ); |
|
504 | + } |
|
488 | 505 | } |
489 | 506 | |
490 | 507 | public static function forceTicket( $ticket ) { |
@@ -506,9 +523,10 @@ discard block |
||
506 | 523 | function temp_filename() { |
507 | 524 | $tmp_dir = ''; |
508 | 525 | $dirs = array( 'TMP', 'TMPDIR', 'TEMP' ); |
509 | - foreach( $dirs as $dir ) |
|
510 | - if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) { |
|
526 | + foreach( $dirs as $dir ) { |
|
527 | + if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) { |
|
511 | 528 | $tmp_dir = $dir; |
529 | + } |
|
512 | 530 | break; |
513 | 531 | } |
514 | 532 | if ( empty( $tmp_dir ) ) { |
@@ -579,10 +597,12 @@ discard block |
||
579 | 597 | } |
580 | 598 | |
581 | 599 | $message = ''; |
582 | - if ( count($not_true) ) |
|
583 | - $message .= implode( $not_true, ', ' ) . ' is expected to be true. '; |
|
584 | - if ( count($not_false) ) |
|
585 | - $message .= implode( $not_false, ', ' ) . ' is expected to be false.'; |
|
600 | + if ( count($not_true) ) { |
|
601 | + $message .= implode( $not_true, ', ' ) . ' is expected to be true. '; |
|
602 | + } |
|
603 | + if ( count($not_false) ) { |
|
604 | + $message .= implode( $not_false, ', ' ) . ' is expected to be false.'; |
|
605 | + } |
|
586 | 606 | $this->assertTrue( $passed, $message ); |
587 | 607 | } |
588 | 608 | |
@@ -702,8 +722,9 @@ discard block |
||
702 | 722 | $type = $upload['type']; |
703 | 723 | } else { |
704 | 724 | $mime = wp_check_filetype( $upload['file'] ); |
705 | - if ($mime) |
|
706 | - $type = $mime['type']; |
|
725 | + if ($mime) { |
|
726 | + $type = $mime['type']; |
|
727 | + } |
|
707 | 728 | } |
708 | 729 | |
709 | 730 | $attachment = array( |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once dirname( __FILE__ ) . '/factory.php'; |
|
4 | -require_once dirname( __FILE__ ) . '/trac.php'; |
|
3 | +require_once dirname(__FILE__).'/factory.php'; |
|
4 | +require_once dirname(__FILE__).'/trac.php'; |
|
5 | 5 | |
6 | 6 | class WP_UnitTestCase extends PHPUnit_Framework_TestCase { |
7 | 7 | |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | protected static $hooks_saved = array(); |
15 | 15 | protected static $ignore_files; |
16 | 16 | |
17 | - function __isset( $name ) { |
|
17 | + function __isset($name) { |
|
18 | 18 | return 'factory' === $name; |
19 | 19 | } |
20 | 20 | |
21 | - function __get( $name ) { |
|
22 | - if ( 'factory' === $name ) { |
|
21 | + function __get($name) { |
|
22 | + if ('factory' === $name) { |
|
23 | 23 | return self::factory(); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | protected static function factory() { |
28 | 28 | static $factory = null; |
29 | - if ( ! $factory ) { |
|
29 | + if (!$factory) { |
|
30 | 30 | $factory = new WP_UnitTest_Factory(); |
31 | 31 | } |
32 | 32 | return $factory; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function get_called_class() { |
36 | - if ( function_exists( 'get_called_class' ) ) { |
|
36 | + if (function_exists('get_called_class')) { |
|
37 | 37 | return get_called_class(); |
38 | 38 | } |
39 | 39 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $backtrace = debug_backtrace(); |
42 | 42 | // [0] WP_UnitTestCase::get_called_class() |
43 | 43 | // [1] WP_UnitTestCase::setUpBeforeClass() |
44 | - if ( 'call_user_func' === $backtrace[2]['function'] ) { |
|
44 | + if ('call_user_func' === $backtrace[2]['function']) { |
|
45 | 45 | return $backtrace[2]['args'][0][0]; |
46 | 46 | } |
47 | 47 | return $backtrace[2]['class']; |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | parent::setUpBeforeClass(); |
52 | 52 | |
53 | 53 | $c = self::get_called_class(); |
54 | - if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { |
|
54 | + if (!method_exists($c, 'wpSetUpBeforeClass')) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - call_user_func( array( $c, 'wpSetUpBeforeClass' ), self::factory() ); |
|
58 | + call_user_func(array($c, 'wpSetUpBeforeClass'), self::factory()); |
|
59 | 59 | |
60 | 60 | self::commit_transaction(); |
61 | 61 | } |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | parent::tearDownAfterClass(); |
65 | 65 | |
66 | 66 | $c = self::get_called_class(); |
67 | - if ( ! method_exists( $c, 'wpTearDownAfterClass' ) ) { |
|
67 | + if (!method_exists($c, 'wpTearDownAfterClass')) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | - call_user_func( array( $c, 'wpTearDownAfterClass' ) ); |
|
71 | + call_user_func(array($c, 'wpTearDownAfterClass')); |
|
72 | 72 | |
73 | 73 | self::commit_transaction(); |
74 | 74 | } |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | function setUp() { |
77 | 77 | set_time_limit(0); |
78 | 78 | |
79 | - if ( ! self::$ignore_files ) { |
|
79 | + if (!self::$ignore_files) { |
|
80 | 80 | self::$ignore_files = $this->scan_user_uploads(); |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! self::$hooks_saved ) { |
|
83 | + if (!self::$hooks_saved) { |
|
84 | 84 | $this->_backup_hooks(); |
85 | 85 | } |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $wpdb->suppress_errors = false; |
89 | 89 | $wpdb->show_errors = true; |
90 | 90 | $wpdb->db_connect(); |
91 | - ini_set('display_errors', 1 ); |
|
91 | + ini_set('display_errors', 1); |
|
92 | 92 | $this->clean_up_global_scope(); |
93 | 93 | |
94 | 94 | /* |
@@ -97,19 +97,19 @@ discard block |
||
97 | 97 | * given the large number of plugins that register post types and |
98 | 98 | * taxonomies at 'init'. |
99 | 99 | */ |
100 | - if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { |
|
100 | + if (defined('WP_RUN_CORE_TESTS') && WP_RUN_CORE_TESTS) { |
|
101 | 101 | $this->reset_post_types(); |
102 | 102 | $this->reset_taxonomies(); |
103 | 103 | $this->reset_post_statuses(); |
104 | 104 | |
105 | - if ( $wp_rewrite->permalink_structure ) { |
|
106 | - $this->set_permalink_structure( '' ); |
|
105 | + if ($wp_rewrite->permalink_structure) { |
|
106 | + $this->set_permalink_structure(''); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | $this->start_transaction(); |
111 | 111 | $this->expectDeprecated(); |
112 | - add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); |
|
112 | + add_filter('wp_die_handler', array($this, 'get_wp_die_handler')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -125,21 +125,21 @@ discard block |
||
125 | 125 | |
126 | 126 | function tearDown() { |
127 | 127 | global $wpdb, $wp_query, $wp, $post; |
128 | - $wpdb->query( 'ROLLBACK' ); |
|
129 | - if ( is_multisite() ) { |
|
130 | - while ( ms_is_switched() ) { |
|
128 | + $wpdb->query('ROLLBACK'); |
|
129 | + if (is_multisite()) { |
|
130 | + while (ms_is_switched()) { |
|
131 | 131 | restore_current_blog(); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | $wp_query = new WP_Query(); |
135 | 135 | $wp = new WP(); |
136 | 136 | $post = null; |
137 | - remove_theme_support( 'html5' ); |
|
138 | - remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); |
|
139 | - remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); |
|
140 | - remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); |
|
137 | + remove_theme_support('html5'); |
|
138 | + remove_filter('query', array($this, '_create_temporary_tables')); |
|
139 | + remove_filter('query', array($this, '_drop_temporary_tables')); |
|
140 | + remove_filter('wp_die_handler', array($this, 'get_wp_die_handler')); |
|
141 | 141 | $this->_restore_hooks(); |
142 | - wp_set_current_user( 0 ); |
|
142 | + wp_set_current_user(0); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | function clean_up_global_scope() { |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * it has a chance to do so. |
157 | 157 | */ |
158 | 158 | protected function reset_post_types() { |
159 | - foreach ( get_post_types() as $pt ) { |
|
160 | - _unregister_post_type( $pt ); |
|
159 | + foreach (get_post_types() as $pt) { |
|
160 | + _unregister_post_type($pt); |
|
161 | 161 | } |
162 | 162 | create_initial_post_types(); |
163 | 163 | } |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * it has a chance to do so. |
171 | 171 | */ |
172 | 172 | protected function reset_taxonomies() { |
173 | - foreach ( get_taxonomies() as $tax ) { |
|
174 | - _unregister_taxonomy( $tax ); |
|
173 | + foreach (get_taxonomies() as $tax) { |
|
174 | + _unregister_taxonomy($tax); |
|
175 | 175 | } |
176 | 176 | create_initial_taxonomies(); |
177 | 177 | } |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | * Unregister non-built-in post statuses. |
181 | 181 | */ |
182 | 182 | protected function reset_post_statuses() { |
183 | - foreach ( get_post_stati( array( '_builtin' => false ) ) as $post_status ) { |
|
184 | - _unregister_post_status( $post_status ); |
|
183 | + foreach (get_post_stati(array('_builtin' => false)) as $post_status) { |
|
184 | + _unregister_post_status($post_status); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | * @return void |
199 | 199 | */ |
200 | 200 | protected function _backup_hooks() { |
201 | - $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); |
|
202 | - foreach ( $globals as $key ) { |
|
203 | - self::$hooks_saved[ $key ] = $GLOBALS[ $key ]; |
|
201 | + $globals = array('merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter'); |
|
202 | + foreach ($globals as $key) { |
|
203 | + self::$hooks_saved[$key] = $GLOBALS[$key]; |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | * @return void |
216 | 216 | */ |
217 | 217 | protected function _restore_hooks() { |
218 | - $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); |
|
219 | - foreach ( $globals as $key ) { |
|
220 | - if ( isset( self::$hooks_saved[ $key ] ) ) { |
|
221 | - $GLOBALS[ $key ] = self::$hooks_saved[ $key ]; |
|
218 | + $globals = array('merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter'); |
|
219 | + foreach ($globals as $key) { |
|
220 | + if (isset(self::$hooks_saved[$key])) { |
|
221 | + $GLOBALS[$key] = self::$hooks_saved[$key]; |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
@@ -229,20 +229,20 @@ discard block |
||
229 | 229 | $wp_object_cache->stats = array(); |
230 | 230 | $wp_object_cache->memcache_debug = array(); |
231 | 231 | $wp_object_cache->cache = array(); |
232 | - if ( method_exists( $wp_object_cache, '__remoteset' ) ) { |
|
232 | + if (method_exists($wp_object_cache, '__remoteset')) { |
|
233 | 233 | $wp_object_cache->__remoteset(); |
234 | 234 | } |
235 | 235 | wp_cache_flush(); |
236 | - wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache' ) ); |
|
237 | - wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) ); |
|
236 | + wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache')); |
|
237 | + wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins')); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | function start_transaction() { |
241 | 241 | global $wpdb; |
242 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
243 | - $wpdb->query( 'START TRANSACTION;' ); |
|
244 | - add_filter( 'query', array( $this, '_create_temporary_tables' ) ); |
|
245 | - add_filter( 'query', array( $this, '_drop_temporary_tables' ) ); |
|
242 | + $wpdb->query('SET autocommit = 0;'); |
|
243 | + $wpdb->query('START TRANSACTION;'); |
|
244 | + add_filter('query', array($this, '_create_temporary_tables')); |
|
245 | + add_filter('query', array($this, '_drop_temporary_tables')); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -252,70 +252,70 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public static function commit_transaction() { |
254 | 254 | global $wpdb; |
255 | - $wpdb->query( 'COMMIT;' ); |
|
255 | + $wpdb->query('COMMIT;'); |
|
256 | 256 | } |
257 | 257 | |
258 | - function _create_temporary_tables( $query ) { |
|
259 | - if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) |
|
260 | - return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); |
|
258 | + function _create_temporary_tables($query) { |
|
259 | + if ('CREATE TABLE' === substr(trim($query), 0, 12)) |
|
260 | + return substr_replace(trim($query), 'CREATE TEMPORARY TABLE', 0, 12); |
|
261 | 261 | return $query; |
262 | 262 | } |
263 | 263 | |
264 | - function _drop_temporary_tables( $query ) { |
|
265 | - if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) |
|
266 | - return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); |
|
264 | + function _drop_temporary_tables($query) { |
|
265 | + if ('DROP TABLE' === substr(trim($query), 0, 10)) |
|
266 | + return substr_replace(trim($query), 'DROP TEMPORARY TABLE', 0, 10); |
|
267 | 267 | return $query; |
268 | 268 | } |
269 | 269 | |
270 | - function get_wp_die_handler( $handler ) { |
|
271 | - return array( $this, 'wp_die_handler' ); |
|
270 | + function get_wp_die_handler($handler) { |
|
271 | + return array($this, 'wp_die_handler'); |
|
272 | 272 | } |
273 | 273 | |
274 | - function wp_die_handler( $message ) { |
|
275 | - throw new WPDieException( $message ); |
|
274 | + function wp_die_handler($message) { |
|
275 | + throw new WPDieException($message); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function expectDeprecated() { |
279 | 279 | $annotations = $this->getAnnotations(); |
280 | - foreach ( array( 'class', 'method' ) as $depth ) { |
|
281 | - if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) |
|
282 | - $this->expected_deprecated = array_merge( $this->expected_deprecated, $annotations[ $depth ]['expectedDeprecated'] ); |
|
283 | - if ( ! empty( $annotations[ $depth ]['expectedIncorrectUsage'] ) ) |
|
284 | - $this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $annotations[ $depth ]['expectedIncorrectUsage'] ); |
|
280 | + foreach (array('class', 'method') as $depth) { |
|
281 | + if (!empty($annotations[$depth]['expectedDeprecated'])) |
|
282 | + $this->expected_deprecated = array_merge($this->expected_deprecated, $annotations[$depth]['expectedDeprecated']); |
|
283 | + if (!empty($annotations[$depth]['expectedIncorrectUsage'])) |
|
284 | + $this->expected_doing_it_wrong = array_merge($this->expected_doing_it_wrong, $annotations[$depth]['expectedIncorrectUsage']); |
|
285 | 285 | } |
286 | - add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); |
|
287 | - add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ) ); |
|
288 | - add_action( 'doing_it_wrong_run', array( $this, 'doing_it_wrong_run' ) ); |
|
289 | - add_action( 'deprecated_function_trigger_error', '__return_false' ); |
|
290 | - add_action( 'deprecated_argument_trigger_error', '__return_false' ); |
|
291 | - add_action( 'doing_it_wrong_trigger_error', '__return_false' ); |
|
286 | + add_action('deprecated_function_run', array($this, 'deprecated_function_run')); |
|
287 | + add_action('deprecated_argument_run', array($this, 'deprecated_function_run')); |
|
288 | + add_action('doing_it_wrong_run', array($this, 'doing_it_wrong_run')); |
|
289 | + add_action('deprecated_function_trigger_error', '__return_false'); |
|
290 | + add_action('deprecated_argument_trigger_error', '__return_false'); |
|
291 | + add_action('doing_it_wrong_trigger_error', '__return_false'); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | function expectedDeprecated() { |
295 | 295 | $errors = array(); |
296 | 296 | |
297 | - $not_caught_deprecated = array_diff( $this->expected_deprecated, $this->caught_deprecated ); |
|
298 | - foreach ( $not_caught_deprecated as $not_caught ) { |
|
297 | + $not_caught_deprecated = array_diff($this->expected_deprecated, $this->caught_deprecated); |
|
298 | + foreach ($not_caught_deprecated as $not_caught) { |
|
299 | 299 | $errors[] = "Failed to assert that $not_caught triggered a deprecated notice"; |
300 | 300 | } |
301 | 301 | |
302 | - $unexpected_deprecated = array_diff( $this->caught_deprecated, $this->expected_deprecated ); |
|
303 | - foreach ( $unexpected_deprecated as $unexpected ) { |
|
302 | + $unexpected_deprecated = array_diff($this->caught_deprecated, $this->expected_deprecated); |
|
303 | + foreach ($unexpected_deprecated as $unexpected) { |
|
304 | 304 | $errors[] = "Unexpected deprecated notice for $unexpected"; |
305 | 305 | } |
306 | 306 | |
307 | - $not_caught_doing_it_wrong = array_diff( $this->expected_doing_it_wrong, $this->caught_doing_it_wrong ); |
|
308 | - foreach ( $not_caught_doing_it_wrong as $not_caught ) { |
|
307 | + $not_caught_doing_it_wrong = array_diff($this->expected_doing_it_wrong, $this->caught_doing_it_wrong); |
|
308 | + foreach ($not_caught_doing_it_wrong as $not_caught) { |
|
309 | 309 | $errors[] = "Failed to assert that $not_caught triggered an incorrect usage notice"; |
310 | 310 | } |
311 | 311 | |
312 | - $unexpected_doing_it_wrong = array_diff( $this->caught_doing_it_wrong, $this->expected_doing_it_wrong ); |
|
313 | - foreach ( $unexpected_doing_it_wrong as $unexpected ) { |
|
312 | + $unexpected_doing_it_wrong = array_diff($this->caught_doing_it_wrong, $this->expected_doing_it_wrong); |
|
313 | + foreach ($unexpected_doing_it_wrong as $unexpected) { |
|
314 | 314 | $errors[] = "Unexpected incorrect usage notice for $unexpected"; |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! empty( $errors ) ) { |
|
318 | - $this->fail( implode( "\n", $errors ) ); |
|
317 | + if (!empty($errors)) { |
|
318 | + $this->fail(implode("\n", $errors)); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param string $deprecated Name of the function, method, class, or argument that is deprecated. Must match |
328 | 328 | * first parameter of the `_deprecated_function()` or `_deprecated_argument()` call. |
329 | 329 | */ |
330 | - public function setExpectedDeprecated( $deprecated ) { |
|
331 | - array_push( $this->expected_deprecated, $deprecated ); |
|
330 | + public function setExpectedDeprecated($deprecated) { |
|
331 | + array_push($this->expected_deprecated, $deprecated); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -339,75 +339,75 @@ discard block |
||
339 | 339 | * @param string $deprecated Name of the function, method, or class that appears in the first argument of the |
340 | 340 | * source `_doing_it_wrong()` call. |
341 | 341 | */ |
342 | - public function setExpectedIncorrectUsage( $doing_it_wrong ) { |
|
343 | - array_push( $this->expected_doing_it_wrong, $doing_it_wrong ); |
|
342 | + public function setExpectedIncorrectUsage($doing_it_wrong) { |
|
343 | + array_push($this->expected_doing_it_wrong, $doing_it_wrong); |
|
344 | 344 | } |
345 | 345 | |
346 | - function deprecated_function_run( $function ) { |
|
347 | - if ( ! in_array( $function, $this->caught_deprecated ) ) |
|
346 | + function deprecated_function_run($function) { |
|
347 | + if (!in_array($function, $this->caught_deprecated)) |
|
348 | 348 | $this->caught_deprecated[] = $function; |
349 | 349 | } |
350 | 350 | |
351 | - function doing_it_wrong_run( $function ) { |
|
352 | - if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) |
|
351 | + function doing_it_wrong_run($function) { |
|
352 | + if (!in_array($function, $this->caught_doing_it_wrong)) |
|
353 | 353 | $this->caught_doing_it_wrong[] = $function; |
354 | 354 | } |
355 | 355 | |
356 | - function assertWPError( $actual, $message = '' ) { |
|
357 | - $this->assertInstanceOf( 'WP_Error', $actual, $message ); |
|
356 | + function assertWPError($actual, $message = '') { |
|
357 | + $this->assertInstanceOf('WP_Error', $actual, $message); |
|
358 | 358 | } |
359 | 359 | |
360 | - function assertNotWPError( $actual, $message = '' ) { |
|
361 | - if ( is_wp_error( $actual ) && '' === $message ) { |
|
360 | + function assertNotWPError($actual, $message = '') { |
|
361 | + if (is_wp_error($actual) && '' === $message) { |
|
362 | 362 | $message = $actual->get_error_message(); |
363 | 363 | } |
364 | - $this->assertNotInstanceOf( 'WP_Error', $actual, $message ); |
|
364 | + $this->assertNotInstanceOf('WP_Error', $actual, $message); |
|
365 | 365 | } |
366 | 366 | |
367 | - function assertEqualFields( $object, $fields ) { |
|
368 | - foreach( $fields as $field_name => $field_value ) { |
|
369 | - if ( $object->{$field_name} != $field_value ) { |
|
367 | + function assertEqualFields($object, $fields) { |
|
368 | + foreach ($fields as $field_name => $field_value) { |
|
369 | + if ($object->{$field_name} != $field_value) { |
|
370 | 370 | $this->fail(); |
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - function assertDiscardWhitespace( $expected, $actual ) { |
|
376 | - $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) ); |
|
375 | + function assertDiscardWhitespace($expected, $actual) { |
|
376 | + $this->assertEquals(preg_replace('/\s*/', '', $expected), preg_replace('/\s*/', '', $actual)); |
|
377 | 377 | } |
378 | 378 | |
379 | - function assertEqualSets( $expected, $actual ) { |
|
380 | - sort( $expected ); |
|
381 | - sort( $actual ); |
|
382 | - $this->assertEquals( $expected, $actual ); |
|
379 | + function assertEqualSets($expected, $actual) { |
|
380 | + sort($expected); |
|
381 | + sort($actual); |
|
382 | + $this->assertEquals($expected, $actual); |
|
383 | 383 | } |
384 | 384 | |
385 | - function assertEqualSetsWithIndex( $expected, $actual ) { |
|
386 | - ksort( $expected ); |
|
387 | - ksort( $actual ); |
|
388 | - $this->assertEquals( $expected, $actual ); |
|
385 | + function assertEqualSetsWithIndex($expected, $actual) { |
|
386 | + ksort($expected); |
|
387 | + ksort($actual); |
|
388 | + $this->assertEquals($expected, $actual); |
|
389 | 389 | } |
390 | 390 | |
391 | - function go_to( $url ) { |
|
391 | + function go_to($url) { |
|
392 | 392 | // note: the WP and WP_Query classes like to silently fetch parameters |
393 | 393 | // from all over the place (globals, GET, etc), which makes it tricky |
394 | 394 | // to run them more than once without very carefully clearing everything |
395 | 395 | $_GET = $_POST = array(); |
396 | 396 | foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) { |
397 | - if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] ); |
|
397 | + if (isset($GLOBALS[$v])) unset($GLOBALS[$v]); |
|
398 | 398 | } |
399 | 399 | $parts = parse_url($url); |
400 | 400 | if (isset($parts['scheme'])) { |
401 | - $req = isset( $parts['path'] ) ? $parts['path'] : ''; |
|
401 | + $req = isset($parts['path']) ? $parts['path'] : ''; |
|
402 | 402 | if (isset($parts['query'])) { |
403 | - $req .= '?' . $parts['query']; |
|
403 | + $req .= '?'.$parts['query']; |
|
404 | 404 | // parse the url query vars into $_GET |
405 | 405 | parse_str($parts['query'], $_GET); |
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | $req = $url; |
409 | 409 | } |
410 | - if ( ! isset( $parts['query'] ) ) { |
|
410 | + if (!isset($parts['query'])) { |
|
411 | 411 | $parts['query'] = ''; |
412 | 412 | } |
413 | 413 | |
@@ -435,24 +435,24 @@ discard block |
||
435 | 435 | parent::checkRequirements(); |
436 | 436 | |
437 | 437 | // Core tests no longer check against open Trac tickets, but others using WP_UnitTestCase may do so. |
438 | - if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { |
|
438 | + if (defined('WP_RUN_CORE_TESTS') && WP_RUN_CORE_TESTS) { |
|
439 | 439 | return; |
440 | 440 | } |
441 | 441 | |
442 | - if ( WP_TESTS_FORCE_KNOWN_BUGS ) |
|
442 | + if (WP_TESTS_FORCE_KNOWN_BUGS) |
|
443 | 443 | return; |
444 | - $tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) ); |
|
445 | - foreach ( $tickets as $ticket ) { |
|
446 | - if ( is_numeric( $ticket ) ) { |
|
447 | - $this->knownWPBug( $ticket ); |
|
448 | - } elseif ( 'UT' == substr( $ticket, 0, 2 ) ) { |
|
449 | - $ticket = substr( $ticket, 2 ); |
|
450 | - if ( $ticket && is_numeric( $ticket ) ) |
|
451 | - $this->knownUTBug( $ticket ); |
|
452 | - } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) { |
|
453 | - $ticket = substr( $ticket, 6 ); |
|
454 | - if ( $ticket && is_numeric( $ticket ) ) |
|
455 | - $this->knownPluginBug( $ticket ); |
|
444 | + $tickets = PHPUnit_Util_Test::getTickets(get_class($this), $this->getName(false)); |
|
445 | + foreach ($tickets as $ticket) { |
|
446 | + if (is_numeric($ticket)) { |
|
447 | + $this->knownWPBug($ticket); |
|
448 | + } elseif ('UT' == substr($ticket, 0, 2)) { |
|
449 | + $ticket = substr($ticket, 2); |
|
450 | + if ($ticket && is_numeric($ticket)) |
|
451 | + $this->knownUTBug($ticket); |
|
452 | + } elseif ('Plugin' == substr($ticket, 0, 6)) { |
|
453 | + $ticket = substr($ticket, 6); |
|
454 | + if ($ticket && is_numeric($ticket)) |
|
455 | + $this->knownPluginBug($ticket); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
@@ -460,44 +460,44 @@ discard block |
||
460 | 460 | /** |
461 | 461 | * Skips the current test if there is an open WordPress ticket with id $ticket_id |
462 | 462 | */ |
463 | - function knownWPBug( $ticket_id ) { |
|
464 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) |
|
463 | + function knownWPBug($ticket_id) { |
|
464 | + if (WP_TESTS_FORCE_KNOWN_BUGS || in_array($ticket_id, self::$forced_tickets)) |
|
465 | 465 | return; |
466 | - if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) |
|
467 | - $this->markTestSkipped( sprintf( 'WordPress Ticket #%d is not fixed', $ticket_id ) ); |
|
466 | + if (!TracTickets::isTracTicketClosed('https://core.trac.wordpress.org', $ticket_id)) |
|
467 | + $this->markTestSkipped(sprintf('WordPress Ticket #%d is not fixed', $ticket_id)); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | 471 | * Skips the current test if there is an open unit tests ticket with id $ticket_id |
472 | 472 | */ |
473 | - function knownUTBug( $ticket_id ) { |
|
474 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'UT' . $ticket_id, self::$forced_tickets ) ) |
|
473 | + function knownUTBug($ticket_id) { |
|
474 | + if (WP_TESTS_FORCE_KNOWN_BUGS || in_array('UT'.$ticket_id, self::$forced_tickets)) |
|
475 | 475 | return; |
476 | - if ( ! TracTickets::isTracTicketClosed( 'https://unit-tests.trac.wordpress.org', $ticket_id ) ) |
|
477 | - $this->markTestSkipped( sprintf( 'Unit Tests Ticket #%d is not fixed', $ticket_id ) ); |
|
476 | + if (!TracTickets::isTracTicketClosed('https://unit-tests.trac.wordpress.org', $ticket_id)) |
|
477 | + $this->markTestSkipped(sprintf('Unit Tests Ticket #%d is not fixed', $ticket_id)); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Skips the current test if there is an open plugin ticket with id $ticket_id |
482 | 482 | */ |
483 | - function knownPluginBug( $ticket_id ) { |
|
484 | - if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) |
|
483 | + function knownPluginBug($ticket_id) { |
|
484 | + if (WP_TESTS_FORCE_KNOWN_BUGS || in_array('Plugin'.$ticket_id, self::$forced_tickets)) |
|
485 | 485 | return; |
486 | - if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) |
|
487 | - $this->markTestSkipped( sprintf( 'WordPress Plugin Ticket #%d is not fixed', $ticket_id ) ); |
|
486 | + if (!TracTickets::isTracTicketClosed('https://plugins.trac.wordpress.org', $ticket_id)) |
|
487 | + $this->markTestSkipped(sprintf('WordPress Plugin Ticket #%d is not fixed', $ticket_id)); |
|
488 | 488 | } |
489 | 489 | |
490 | - public static function forceTicket( $ticket ) { |
|
490 | + public static function forceTicket($ticket) { |
|
491 | 491 | self::$forced_tickets[] = $ticket; |
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
495 | 495 | * Define constants after including files. |
496 | 496 | */ |
497 | - function prepareTemplate( Text_Template $template ) { |
|
498 | - $template->setVar( array( 'constants' => '' ) ); |
|
499 | - $template->setVar( array( 'wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString() ) ); |
|
500 | - parent::prepareTemplate( $template ); |
|
497 | + function prepareTemplate(Text_Template $template) { |
|
498 | + $template->setVar(array('constants' => '')); |
|
499 | + $template->setVar(array('wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString())); |
|
500 | + parent::prepareTemplate($template); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -505,17 +505,17 @@ discard block |
||
505 | 505 | */ |
506 | 506 | function temp_filename() { |
507 | 507 | $tmp_dir = ''; |
508 | - $dirs = array( 'TMP', 'TMPDIR', 'TEMP' ); |
|
509 | - foreach( $dirs as $dir ) |
|
510 | - if ( isset( $_ENV[$dir] ) && !empty( $_ENV[$dir] ) ) { |
|
508 | + $dirs = array('TMP', 'TMPDIR', 'TEMP'); |
|
509 | + foreach ($dirs as $dir) |
|
510 | + if (isset($_ENV[$dir]) && !empty($_ENV[$dir])) { |
|
511 | 511 | $tmp_dir = $dir; |
512 | 512 | break; |
513 | 513 | } |
514 | - if ( empty( $tmp_dir ) ) { |
|
514 | + if (empty($tmp_dir)) { |
|
515 | 515 | $tmp_dir = '/tmp'; |
516 | 516 | } |
517 | - $tmp_dir = realpath( $tmp_dir ); |
|
518 | - return tempnam( $tmp_dir, 'wpunit' ); |
|
517 | + $tmp_dir = realpath($tmp_dir); |
|
518 | + return tempnam($tmp_dir, 'wpunit'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -564,43 +564,43 @@ discard block |
||
564 | 564 | $passed = true; |
565 | 565 | $not_false = $not_true = array(); // properties that were not set to expected values |
566 | 566 | |
567 | - foreach ( $all as $query_thing ) { |
|
568 | - $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->{$query_thing}; |
|
567 | + foreach ($all as $query_thing) { |
|
568 | + $result = is_callable($query_thing) ? call_user_func($query_thing) : $wp_query->{$query_thing}; |
|
569 | 569 | |
570 | - if ( in_array( $query_thing, $true ) ) { |
|
571 | - if ( ! $result ) { |
|
572 | - array_push( $not_true, $query_thing ); |
|
570 | + if (in_array($query_thing, $true)) { |
|
571 | + if (!$result) { |
|
572 | + array_push($not_true, $query_thing); |
|
573 | 573 | $passed = false; |
574 | 574 | } |
575 | - } else if ( $result ) { |
|
576 | - array_push( $not_false, $query_thing ); |
|
575 | + } else if ($result) { |
|
576 | + array_push($not_false, $query_thing); |
|
577 | 577 | $passed = false; |
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
581 | 581 | $message = ''; |
582 | - if ( count($not_true) ) |
|
583 | - $message .= implode( $not_true, ', ' ) . ' is expected to be true. '; |
|
584 | - if ( count($not_false) ) |
|
585 | - $message .= implode( $not_false, ', ' ) . ' is expected to be false.'; |
|
586 | - $this->assertTrue( $passed, $message ); |
|
582 | + if (count($not_true)) |
|
583 | + $message .= implode($not_true, ', ').' is expected to be true. '; |
|
584 | + if (count($not_false)) |
|
585 | + $message .= implode($not_false, ', ').' is expected to be false.'; |
|
586 | + $this->assertTrue($passed, $message); |
|
587 | 587 | } |
588 | 588 | |
589 | - function unlink( $file ) { |
|
590 | - $exists = is_file( $file ); |
|
591 | - if ( $exists && ! in_array( $file, self::$ignore_files ) ) { |
|
589 | + function unlink($file) { |
|
590 | + $exists = is_file($file); |
|
591 | + if ($exists && !in_array($file, self::$ignore_files)) { |
|
592 | 592 | //error_log( $file ); |
593 | - unlink( $file ); |
|
594 | - } elseif ( ! $exists ) { |
|
595 | - $this->fail( "Trying to delete a file that doesn't exist: $file" ); |
|
593 | + unlink($file); |
|
594 | + } elseif (!$exists) { |
|
595 | + $this->fail("Trying to delete a file that doesn't exist: $file"); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | - function rmdir( $path ) { |
|
600 | - $files = $this->files_in_dir( $path ); |
|
601 | - foreach ( $files as $file ) { |
|
602 | - if ( ! in_array( $file, self::$ignore_files ) ) { |
|
603 | - $this->unlink( $file ); |
|
599 | + function rmdir($path) { |
|
600 | + $files = $this->files_in_dir($path); |
|
601 | + foreach ($files as $file) { |
|
602 | + if (!in_array($file, self::$ignore_files)) { |
|
603 | + $this->unlink($file); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | } |
@@ -608,16 +608,16 @@ discard block |
||
608 | 608 | function remove_added_uploads() { |
609 | 609 | // Remove all uploads. |
610 | 610 | $uploads = wp_upload_dir(); |
611 | - $this->rmdir( $uploads['basedir'] ); |
|
611 | + $this->rmdir($uploads['basedir']); |
|
612 | 612 | } |
613 | 613 | |
614 | - function files_in_dir( $dir ) { |
|
614 | + function files_in_dir($dir) { |
|
615 | 615 | $files = array(); |
616 | 616 | |
617 | - $iterator = new RecursiveDirectoryIterator( $dir ); |
|
618 | - $objects = new RecursiveIteratorIterator( $iterator ); |
|
619 | - foreach ( $objects as $name => $object ) { |
|
620 | - if ( is_file( $name ) ) { |
|
617 | + $iterator = new RecursiveDirectoryIterator($dir); |
|
618 | + $objects = new RecursiveIteratorIterator($iterator); |
|
619 | + foreach ($objects as $name => $object) { |
|
620 | + if (is_file($name)) { |
|
621 | 621 | $files[] = $name; |
622 | 622 | } |
623 | 623 | } |
@@ -627,33 +627,33 @@ discard block |
||
627 | 627 | |
628 | 628 | function scan_user_uploads() { |
629 | 629 | static $files = array(); |
630 | - if ( ! empty( $files ) ) { |
|
630 | + if (!empty($files)) { |
|
631 | 631 | return $files; |
632 | 632 | } |
633 | 633 | |
634 | 634 | $uploads = wp_upload_dir(); |
635 | - $files = $this->files_in_dir( $uploads['basedir'] ); |
|
635 | + $files = $this->files_in_dir($uploads['basedir']); |
|
636 | 636 | return $files; |
637 | 637 | } |
638 | 638 | |
639 | - function delete_folders( $path ) { |
|
639 | + function delete_folders($path) { |
|
640 | 640 | $this->matched_dirs = array(); |
641 | - if ( ! is_dir( $path ) ) { |
|
641 | + if (!is_dir($path)) { |
|
642 | 642 | return; |
643 | 643 | } |
644 | 644 | |
645 | - $this->scandir( $path ); |
|
646 | - foreach ( array_reverse( $this->matched_dirs ) as $dir ) { |
|
647 | - rmdir( $dir ); |
|
645 | + $this->scandir($path); |
|
646 | + foreach (array_reverse($this->matched_dirs) as $dir) { |
|
647 | + rmdir($dir); |
|
648 | 648 | } |
649 | - rmdir( $path ); |
|
649 | + rmdir($path); |
|
650 | 650 | } |
651 | 651 | |
652 | - function scandir( $dir ) { |
|
653 | - foreach ( scandir( $dir ) as $path ) { |
|
654 | - if ( 0 !== strpos( $path, '.' ) && is_dir( $dir . '/' . $path ) ) { |
|
655 | - $this->matched_dirs[] = $dir . '/' . $path; |
|
656 | - $this->scandir( $dir . '/' . $path ); |
|
652 | + function scandir($dir) { |
|
653 | + foreach (scandir($dir) as $path) { |
|
654 | + if (0 !== strpos($path, '.') && is_dir($dir.'/'.$path)) { |
|
655 | + $this->matched_dirs[] = $dir.'/'.$path; |
|
656 | + $this->scandir($dir.'/'.$path); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | } |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | /** |
662 | 662 | * Helper to Convert a microtime string into a float |
663 | 663 | */ |
664 | - protected function _microtime_to_float($microtime ){ |
|
665 | - $time_array = explode( ' ', $microtime ); |
|
666 | - return array_sum( $time_array ); |
|
664 | + protected function _microtime_to_float($microtime) { |
|
665 | + $time_array = explode(' ', $microtime); |
|
666 | + return array_sum($time_array); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -671,11 +671,11 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @since 4.3.0 |
673 | 673 | */ |
674 | - public static function delete_user( $user_id ) { |
|
675 | - if ( is_multisite() ) { |
|
676 | - return wpmu_delete_user( $user_id ); |
|
674 | + public static function delete_user($user_id) { |
|
675 | + if (is_multisite()) { |
|
676 | + return wpmu_delete_user($user_id); |
|
677 | 677 | } else { |
678 | - return wp_delete_user( $user_id ); |
|
678 | + return wp_delete_user($user_id); |
|
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
@@ -688,36 +688,36 @@ discard block |
||
688 | 688 | * |
689 | 689 | * @param string $structure Optional. Permalink structure to set. Default empty. |
690 | 690 | */ |
691 | - public function set_permalink_structure( $structure = '' ) { |
|
691 | + public function set_permalink_structure($structure = '') { |
|
692 | 692 | global $wp_rewrite; |
693 | 693 | |
694 | 694 | $wp_rewrite->init(); |
695 | - $wp_rewrite->set_permalink_structure( $structure ); |
|
695 | + $wp_rewrite->set_permalink_structure($structure); |
|
696 | 696 | $wp_rewrite->flush_rules(); |
697 | 697 | } |
698 | 698 | |
699 | 699 | function _make_attachment($upload, $parent_post_id = 0) { |
700 | 700 | $type = ''; |
701 | - if ( !empty($upload['type']) ) { |
|
701 | + if (!empty($upload['type'])) { |
|
702 | 702 | $type = $upload['type']; |
703 | 703 | } else { |
704 | - $mime = wp_check_filetype( $upload['file'] ); |
|
704 | + $mime = wp_check_filetype($upload['file']); |
|
705 | 705 | if ($mime) |
706 | 706 | $type = $mime['type']; |
707 | 707 | } |
708 | 708 | |
709 | 709 | $attachment = array( |
710 | - 'post_title' => basename( $upload['file'] ), |
|
710 | + 'post_title' => basename($upload['file']), |
|
711 | 711 | 'post_content' => '', |
712 | 712 | 'post_type' => 'attachment', |
713 | 713 | 'post_parent' => $parent_post_id, |
714 | 714 | 'post_mime_type' => $type, |
715 | - 'guid' => $upload[ 'url' ], |
|
715 | + 'guid' => $upload['url'], |
|
716 | 716 | ); |
717 | 717 | |
718 | 718 | // Save the data |
719 | - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent_post_id ); |
|
720 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
|
719 | + $id = wp_insert_attachment($attachment, $upload['file'], $parent_post_id); |
|
720 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file'])); |
|
721 | 721 | return $id; |
722 | 722 | } |
723 | 723 | } |
@@ -1,69 +1,69 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckMaps 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 testCheckHomeMap() |
|
10 | - { |
|
11 | - $output = do_shortcode('[gd_homepage_map width=100% height=300 scrollwheel=false]'); |
|
12 | - $this->assertContains( 'geodir-map-home-page', $output ); |
|
13 | - } |
|
9 | + public function testCheckHomeMap() |
|
10 | + { |
|
11 | + $output = do_shortcode('[gd_homepage_map width=100% height=300 scrollwheel=false]'); |
|
12 | + $this->assertContains( 'geodir-map-home-page', $output ); |
|
13 | + } |
|
14 | 14 | |
15 | - public function testListingsPageMap() |
|
16 | - { |
|
17 | - $output = do_shortcode('[gd_listing_map width=100% height=300 scrollwheel=false sticky=true]'); |
|
18 | - $this->assertContains( 'geodir-map-listing-page', $output ); |
|
19 | - } |
|
15 | + public function testListingsPageMap() |
|
16 | + { |
|
17 | + $output = do_shortcode('[gd_listing_map width=100% height=300 scrollwheel=false sticky=true]'); |
|
18 | + $this->assertContains( 'geodir-map-listing-page', $output ); |
|
19 | + } |
|
20 | 20 | |
21 | - public function testDetailPageMap() |
|
22 | - { |
|
21 | + public function testDetailPageMap() |
|
22 | + { |
|
23 | 23 | |
24 | - $query_args = array( |
|
25 | - 'post_status' => 'publish', |
|
26 | - 'post_type' => 'gd_place', |
|
27 | - 'posts_per_page' => 1, |
|
28 | - ); |
|
24 | + $query_args = array( |
|
25 | + 'post_status' => 'publish', |
|
26 | + 'post_type' => 'gd_place', |
|
27 | + 'posts_per_page' => 1, |
|
28 | + ); |
|
29 | 29 | |
30 | - $all_posts = new WP_Query( $query_args ); |
|
31 | - $post_id = null; |
|
32 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
33 | - $post_id = get_the_ID(); |
|
34 | - global $post; |
|
35 | - $post = geodir_get_post_info($post_id); |
|
36 | - setup_postdata($post); |
|
30 | + $all_posts = new WP_Query( $query_args ); |
|
31 | + $post_id = null; |
|
32 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
33 | + $post_id = get_the_ID(); |
|
34 | + global $post; |
|
35 | + $post = geodir_get_post_info($post_id); |
|
36 | + setup_postdata($post); |
|
37 | 37 | |
38 | - $map_args = array(); |
|
39 | - $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
|
40 | - $map_args['width'] = '600'; |
|
41 | - $map_args['height'] = '300'; |
|
42 | - if ($post->post_mapzoom) { |
|
43 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
44 | - } |
|
45 | - $map_args['autozoom'] = false; |
|
46 | - $map_args['child_collapse'] = '0'; |
|
47 | - $map_args['enable_cat_filters'] = false; |
|
48 | - $map_args['enable_text_search'] = false; |
|
49 | - $map_args['enable_post_type_filters'] = false; |
|
50 | - $map_args['enable_location_filters'] = false; |
|
51 | - $map_args['enable_jason_on_load'] = true; |
|
52 | - $map_args['enable_map_direction'] = true; |
|
53 | - $map_args['map_class_name'] = 'geodir-map-detail-page'; |
|
54 | - $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
55 | - ob_start(); |
|
56 | - geodir_draw_map($map_args); |
|
57 | - $output = ob_get_clean(); |
|
58 | - $this->assertContains( 'geodir-map-detail-page', $output ); |
|
59 | - endwhile; |
|
38 | + $map_args = array(); |
|
39 | + $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
|
40 | + $map_args['width'] = '600'; |
|
41 | + $map_args['height'] = '300'; |
|
42 | + if ($post->post_mapzoom) { |
|
43 | + $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
44 | + } |
|
45 | + $map_args['autozoom'] = false; |
|
46 | + $map_args['child_collapse'] = '0'; |
|
47 | + $map_args['enable_cat_filters'] = false; |
|
48 | + $map_args['enable_text_search'] = false; |
|
49 | + $map_args['enable_post_type_filters'] = false; |
|
50 | + $map_args['enable_location_filters'] = false; |
|
51 | + $map_args['enable_jason_on_load'] = true; |
|
52 | + $map_args['enable_map_direction'] = true; |
|
53 | + $map_args['map_class_name'] = 'geodir-map-detail-page'; |
|
54 | + $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
55 | + ob_start(); |
|
56 | + geodir_draw_map($map_args); |
|
57 | + $output = ob_get_clean(); |
|
58 | + $this->assertContains( 'geodir-map-detail-page', $output ); |
|
59 | + endwhile; |
|
60 | 60 | |
61 | 61 | |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | - public function tearDown() |
|
65 | - { |
|
66 | - parent::tearDown(); |
|
67 | - } |
|
64 | + public function tearDown() |
|
65 | + { |
|
66 | + parent::tearDown(); |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | ?> |
70 | 70 | \ No newline at end of file |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | public function testCheckHomeMap() |
10 | 10 | { |
11 | 11 | $output = do_shortcode('[gd_homepage_map width=100% height=300 scrollwheel=false]'); |
12 | - $this->assertContains( 'geodir-map-home-page', $output ); |
|
12 | + $this->assertContains('geodir-map-home-page', $output); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public function testListingsPageMap() |
16 | 16 | { |
17 | 17 | $output = do_shortcode('[gd_listing_map width=100% height=300 scrollwheel=false sticky=true]'); |
18 | - $this->assertContains( 'geodir-map-listing-page', $output ); |
|
18 | + $this->assertContains('geodir-map-listing-page', $output); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function testDetailPageMap() |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | 'posts_per_page' => 1, |
28 | 28 | ); |
29 | 29 | |
30 | - $all_posts = new WP_Query( $query_args ); |
|
30 | + $all_posts = new WP_Query($query_args); |
|
31 | 31 | $post_id = null; |
32 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
32 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
33 | 33 | $post_id = get_the_ID(); |
34 | 34 | global $post; |
35 | - $post = geodir_get_post_info($post_id); |
|
35 | + $post = geodir_get_post_info($post_id); |
|
36 | 36 | setup_postdata($post); |
37 | 37 | |
38 | 38 | $map_args = array(); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $map_args['width'] = '600'; |
41 | 41 | $map_args['height'] = '300'; |
42 | 42 | if ($post->post_mapzoom) { |
43 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
43 | + $map_args['zoom'] = ''.$post->post_mapzoom.''; |
|
44 | 44 | } |
45 | 45 | $map_args['autozoom'] = false; |
46 | 46 | $map_args['child_collapse'] = '0'; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ob_start(); |
56 | 56 | geodir_draw_map($map_args); |
57 | 57 | $output = ob_get_clean(); |
58 | - $this->assertContains( 'geodir-map-detail-page', $output ); |
|
58 | + $this->assertContains('geodir-map-detail-page', $output); |
|
59 | 59 | endwhile; |
60 | 60 | |
61 | 61 |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckPinpoint 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 testCheckPinpoint() |
|
10 | - { |
|
9 | + public function testCheckPinpoint() |
|
10 | + { |
|
11 | 11 | |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - public function tearDown() |
|
15 | - { |
|
16 | - parent::tearDown(); |
|
17 | - } |
|
14 | + public function tearDown() |
|
15 | + { |
|
16 | + parent::tearDown(); |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | ?> |
20 | 20 | \ No newline at end of file |
@@ -1,63 +1,63 @@ |
||
1 | 1 | <?php |
2 | 2 | class AddReview 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 testAddReview() |
|
11 | - { |
|
12 | - $time = current_time('mysql'); |
|
10 | + public function testAddReview() |
|
11 | + { |
|
12 | + $time = current_time('mysql'); |
|
13 | 13 | |
14 | - $args = array( |
|
15 | - 'listing_type' => 'gd_place', |
|
16 | - 'post_title' => 'Test Listing Title', |
|
17 | - 'post_desc' => 'Test Desc', |
|
18 | - 'post_tags' => 'test1,test2', |
|
19 | - 'post_address' => 'New York City Hall', |
|
20 | - 'post_zip' => '10007', |
|
21 | - 'post_latitude' => '40.7127837', |
|
22 | - 'post_longitude' => '-74.00594130000002', |
|
23 | - 'post_mapview' => 'ROADMAP', |
|
24 | - 'post_mapzoom' => '10', |
|
25 | - 'geodir_timing' => '10.00 am to 6 pm every day', |
|
26 | - 'geodir_contact' => '1234567890', |
|
27 | - 'geodir_email' => '[email protected]', |
|
28 | - 'geodir_website' => 'http://test.com', |
|
29 | - 'geodir_twitter' => 'http://twitter.com/test', |
|
30 | - 'geodir_facebook' => 'http://facebook.com/test', |
|
31 | - 'geodir_special_offers' => 'Test offer' |
|
32 | - ); |
|
33 | - $post_id = geodir_save_listing($args, true); |
|
14 | + $args = array( |
|
15 | + 'listing_type' => 'gd_place', |
|
16 | + 'post_title' => 'Test Listing Title', |
|
17 | + 'post_desc' => 'Test Desc', |
|
18 | + 'post_tags' => 'test1,test2', |
|
19 | + 'post_address' => 'New York City Hall', |
|
20 | + 'post_zip' => '10007', |
|
21 | + 'post_latitude' => '40.7127837', |
|
22 | + 'post_longitude' => '-74.00594130000002', |
|
23 | + 'post_mapview' => 'ROADMAP', |
|
24 | + 'post_mapzoom' => '10', |
|
25 | + 'geodir_timing' => '10.00 am to 6 pm every day', |
|
26 | + 'geodir_contact' => '1234567890', |
|
27 | + 'geodir_email' => '[email protected]', |
|
28 | + 'geodir_website' => 'http://test.com', |
|
29 | + 'geodir_twitter' => 'http://twitter.com/test', |
|
30 | + 'geodir_facebook' => 'http://facebook.com/test', |
|
31 | + 'geodir_special_offers' => 'Test offer' |
|
32 | + ); |
|
33 | + $post_id = geodir_save_listing($args, true); |
|
34 | 34 | |
35 | - $data = array( |
|
36 | - 'comment_post_ID' => $post_id, |
|
37 | - 'comment_author' => 'admin', |
|
38 | - 'comment_author_email' => '[email protected]', |
|
39 | - 'comment_author_url' => 'http://wpgeodirectory.com', |
|
40 | - 'comment_content' => 'content here', |
|
41 | - 'comment_type' => '', |
|
42 | - 'comment_parent' => 0, |
|
43 | - 'user_id' => 1, |
|
44 | - 'comment_author_IP' => '127.0.0.1', |
|
45 | - 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', |
|
46 | - 'comment_date' => $time, |
|
47 | - 'comment_approved' => 1, |
|
48 | - ); |
|
35 | + $data = array( |
|
36 | + 'comment_post_ID' => $post_id, |
|
37 | + 'comment_author' => 'admin', |
|
38 | + 'comment_author_email' => '[email protected]', |
|
39 | + 'comment_author_url' => 'http://wpgeodirectory.com', |
|
40 | + 'comment_content' => 'content here', |
|
41 | + 'comment_type' => '', |
|
42 | + 'comment_parent' => 0, |
|
43 | + 'user_id' => 1, |
|
44 | + 'comment_author_IP' => '127.0.0.1', |
|
45 | + 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', |
|
46 | + 'comment_date' => $time, |
|
47 | + 'comment_approved' => 1, |
|
48 | + ); |
|
49 | 49 | |
50 | - $comment_id = wp_insert_comment($data); |
|
50 | + $comment_id = wp_insert_comment($data); |
|
51 | 51 | |
52 | - $_REQUEST['geodir_overallrating'] = 5.0; |
|
53 | - geodir_save_rating($comment_id); |
|
52 | + $_REQUEST['geodir_overallrating'] = 5.0; |
|
53 | + geodir_save_rating($comment_id); |
|
54 | 54 | |
55 | - $this->assertTrue(is_int($comment_id)); |
|
56 | - } |
|
55 | + $this->assertTrue(is_int($comment_id)); |
|
56 | + } |
|
57 | 57 | |
58 | - public function tearDown() |
|
59 | - { |
|
60 | - parent::tearDown(); |
|
61 | - } |
|
58 | + public function tearDown() |
|
59 | + { |
|
60 | + parent::tearDown(); |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | ?> |
64 | 64 | \ No newline at end of file |
@@ -1,116 +1,116 @@ |
||
1 | 1 | <?php |
2 | 2 | class SendEnquiry extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
8 | - |
|
9 | - public function testSendEnquiry() |
|
10 | - { |
|
11 | - $query_args = array( |
|
12 | - 'post_status' => 'publish', |
|
13 | - 'post_type' => 'gd_place', |
|
14 | - 'posts_per_page' => 1, |
|
15 | - ); |
|
16 | - |
|
17 | - $all_posts = new WP_Query( $query_args ); |
|
18 | - $post_id = null; |
|
19 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
20 | - $post_id = get_the_ID(); |
|
21 | - endwhile; |
|
22 | - |
|
23 | - $this->assertTrue(is_int($post_id)); |
|
24 | - |
|
25 | - $data = array( |
|
26 | - 'sendact' => 'send_inqury', |
|
27 | - 'pid' => (string) $post_id, |
|
28 | - 'inq_name' => 'Test User', |
|
29 | - 'inq_email' => '[email protected]', |
|
30 | - 'inq_phone' => 'Test', |
|
31 | - 'inq_msg' => 'Hi there, I would like to enquire about this place. I would like to ask more info about...', |
|
32 | - 'Send' => 'Send' |
|
33 | - ); |
|
34 | - |
|
35 | - add_filter('wp_redirect', '__return_false'); |
|
36 | - geodir_send_inquiry($data); |
|
37 | - remove_filter('wp_redirect', '__return_false'); |
|
38 | - } |
|
39 | - |
|
40 | - public function testSendToFriend() |
|
41 | - { |
|
42 | - $query_args = array( |
|
43 | - 'post_status' => 'publish', |
|
44 | - 'post_type' => 'gd_place', |
|
45 | - 'posts_per_page' => 1, |
|
46 | - ); |
|
47 | - |
|
48 | - $all_posts = new WP_Query( $query_args ); |
|
49 | - $post_id = null; |
|
50 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
51 | - $post_id = get_the_ID(); |
|
52 | - endwhile; |
|
53 | - |
|
54 | - $this->assertTrue(is_int($post_id)); |
|
55 | - |
|
56 | - $data = array( |
|
57 | - 'sendact' => 'email_frnd', |
|
58 | - 'pid' => (string) $post_id, |
|
59 | - 'yourname' => 'Test User', |
|
60 | - 'youremail' => '[email protected]', |
|
61 | - 'frnd_subject' => 'Test', |
|
62 | - 'frnd_comments' => 'Hi there, This is a comment', |
|
63 | - 'to_email' => '[email protected]', |
|
64 | - 'to_name' => 'Test User 2', |
|
65 | - 'Send' => 'Send' |
|
66 | - ); |
|
67 | - |
|
68 | - add_filter('wp_redirect', '__return_false'); |
|
69 | - geodir_send_friend($data); |
|
70 | - remove_filter('wp_redirect', '__return_false'); |
|
71 | - } |
|
72 | - |
|
73 | - public function texstSendToFriendFailure() |
|
74 | - { |
|
75 | - $query_args = array( |
|
76 | - 'post_status' => 'publish', |
|
77 | - 'post_type' => 'gd_place', |
|
78 | - 'posts_per_page' => 1, |
|
79 | - ); |
|
80 | - |
|
81 | - $all_posts = new WP_Query( $query_args ); |
|
82 | - $post_id = null; |
|
83 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
84 | - $post_id = get_the_ID(); |
|
85 | - endwhile; |
|
86 | - |
|
87 | - $this->assertTrue(is_int($post_id)); |
|
88 | - |
|
89 | - $data = array( |
|
90 | - 'sendact' => 'email_frnd', |
|
91 | - 'pid' => (string) $post_id, |
|
92 | - 'yourname' => 'Test User', |
|
93 | - 'youremail' => '[email protected]', |
|
94 | - 'frnd_subject' => 'Test', |
|
95 | - 'frnd_comments' => 'Hi there, This is a comment', |
|
96 | - 'to_email' => 'Test User 2', //incorrect email |
|
97 | - 'to_name' => '[email protected]', |
|
98 | - 'Send' => 'Send' |
|
99 | - ); |
|
100 | - |
|
101 | - add_filter('wp_redirect', '__return_false'); |
|
102 | - add_filter('wp_mail', 'print_mail'); |
|
103 | - ob_start(); |
|
104 | - geodir_send_friend($data); |
|
105 | - $output = ob_get_clean(); |
|
106 | - $this->assertContains( 'Email from GeoDirectory failed to send', $output ); |
|
107 | - remove_filter('wp_mail', 'print_mail'); |
|
108 | - remove_filter('wp_redirect', '__return_false'); |
|
109 | - } |
|
110 | - |
|
111 | - public function tearDown() |
|
112 | - { |
|
113 | - parent::tearDown(); |
|
114 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | + |
|
9 | + public function testSendEnquiry() |
|
10 | + { |
|
11 | + $query_args = array( |
|
12 | + 'post_status' => 'publish', |
|
13 | + 'post_type' => 'gd_place', |
|
14 | + 'posts_per_page' => 1, |
|
15 | + ); |
|
16 | + |
|
17 | + $all_posts = new WP_Query( $query_args ); |
|
18 | + $post_id = null; |
|
19 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
20 | + $post_id = get_the_ID(); |
|
21 | + endwhile; |
|
22 | + |
|
23 | + $this->assertTrue(is_int($post_id)); |
|
24 | + |
|
25 | + $data = array( |
|
26 | + 'sendact' => 'send_inqury', |
|
27 | + 'pid' => (string) $post_id, |
|
28 | + 'inq_name' => 'Test User', |
|
29 | + 'inq_email' => '[email protected]', |
|
30 | + 'inq_phone' => 'Test', |
|
31 | + 'inq_msg' => 'Hi there, I would like to enquire about this place. I would like to ask more info about...', |
|
32 | + 'Send' => 'Send' |
|
33 | + ); |
|
34 | + |
|
35 | + add_filter('wp_redirect', '__return_false'); |
|
36 | + geodir_send_inquiry($data); |
|
37 | + remove_filter('wp_redirect', '__return_false'); |
|
38 | + } |
|
39 | + |
|
40 | + public function testSendToFriend() |
|
41 | + { |
|
42 | + $query_args = array( |
|
43 | + 'post_status' => 'publish', |
|
44 | + 'post_type' => 'gd_place', |
|
45 | + 'posts_per_page' => 1, |
|
46 | + ); |
|
47 | + |
|
48 | + $all_posts = new WP_Query( $query_args ); |
|
49 | + $post_id = null; |
|
50 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
51 | + $post_id = get_the_ID(); |
|
52 | + endwhile; |
|
53 | + |
|
54 | + $this->assertTrue(is_int($post_id)); |
|
55 | + |
|
56 | + $data = array( |
|
57 | + 'sendact' => 'email_frnd', |
|
58 | + 'pid' => (string) $post_id, |
|
59 | + 'yourname' => 'Test User', |
|
60 | + 'youremail' => '[email protected]', |
|
61 | + 'frnd_subject' => 'Test', |
|
62 | + 'frnd_comments' => 'Hi there, This is a comment', |
|
63 | + 'to_email' => '[email protected]', |
|
64 | + 'to_name' => 'Test User 2', |
|
65 | + 'Send' => 'Send' |
|
66 | + ); |
|
67 | + |
|
68 | + add_filter('wp_redirect', '__return_false'); |
|
69 | + geodir_send_friend($data); |
|
70 | + remove_filter('wp_redirect', '__return_false'); |
|
71 | + } |
|
72 | + |
|
73 | + public function texstSendToFriendFailure() |
|
74 | + { |
|
75 | + $query_args = array( |
|
76 | + 'post_status' => 'publish', |
|
77 | + 'post_type' => 'gd_place', |
|
78 | + 'posts_per_page' => 1, |
|
79 | + ); |
|
80 | + |
|
81 | + $all_posts = new WP_Query( $query_args ); |
|
82 | + $post_id = null; |
|
83 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
84 | + $post_id = get_the_ID(); |
|
85 | + endwhile; |
|
86 | + |
|
87 | + $this->assertTrue(is_int($post_id)); |
|
88 | + |
|
89 | + $data = array( |
|
90 | + 'sendact' => 'email_frnd', |
|
91 | + 'pid' => (string) $post_id, |
|
92 | + 'yourname' => 'Test User', |
|
93 | + 'youremail' => '[email protected]', |
|
94 | + 'frnd_subject' => 'Test', |
|
95 | + 'frnd_comments' => 'Hi there, This is a comment', |
|
96 | + 'to_email' => 'Test User 2', //incorrect email |
|
97 | + 'to_name' => '[email protected]', |
|
98 | + 'Send' => 'Send' |
|
99 | + ); |
|
100 | + |
|
101 | + add_filter('wp_redirect', '__return_false'); |
|
102 | + add_filter('wp_mail', 'print_mail'); |
|
103 | + ob_start(); |
|
104 | + geodir_send_friend($data); |
|
105 | + $output = ob_get_clean(); |
|
106 | + $this->assertContains( 'Email from GeoDirectory failed to send', $output ); |
|
107 | + remove_filter('wp_mail', 'print_mail'); |
|
108 | + remove_filter('wp_redirect', '__return_false'); |
|
109 | + } |
|
110 | + |
|
111 | + public function tearDown() |
|
112 | + { |
|
113 | + parent::tearDown(); |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | ?> |
117 | 117 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | 'posts_per_page' => 1, |
15 | 15 | ); |
16 | 16 | |
17 | - $all_posts = new WP_Query( $query_args ); |
|
17 | + $all_posts = new WP_Query($query_args); |
|
18 | 18 | $post_id = null; |
19 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
19 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
20 | 20 | $post_id = get_the_ID(); |
21 | 21 | endwhile; |
22 | 22 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | 'posts_per_page' => 1, |
46 | 46 | ); |
47 | 47 | |
48 | - $all_posts = new WP_Query( $query_args ); |
|
48 | + $all_posts = new WP_Query($query_args); |
|
49 | 49 | $post_id = null; |
50 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
50 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
51 | 51 | $post_id = get_the_ID(); |
52 | 52 | endwhile; |
53 | 53 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | 'posts_per_page' => 1, |
79 | 79 | ); |
80 | 80 | |
81 | - $all_posts = new WP_Query( $query_args ); |
|
81 | + $all_posts = new WP_Query($query_args); |
|
82 | 82 | $post_id = null; |
83 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
83 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
84 | 84 | $post_id = get_the_ID(); |
85 | 85 | endwhile; |
86 | 86 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ob_start(); |
104 | 104 | geodir_send_friend($data); |
105 | 105 | $output = ob_get_clean(); |
106 | - $this->assertContains( 'Email from GeoDirectory failed to send', $output ); |
|
106 | + $this->assertContains('Email from GeoDirectory failed to send', $output); |
|
107 | 107 | remove_filter('wp_mail', 'print_mail'); |
108 | 108 | remove_filter('wp_redirect', '__return_false'); |
109 | 109 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | // reset the wpdb queries log, storing it on the profile stack if necessary |
41 | 41 | global $wpdb; |
42 | 42 | if ($this->stack) { |
43 | - $this->stack[count($this->stack)-1]['queries'] = $wpdb->queries; |
|
43 | + $this->stack[count($this->stack) - 1]['queries'] = $wpdb->queries; |
|
44 | 44 | } |
45 | 45 | $wpdb->queries = array(); |
46 | 46 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | |
75 | 75 | if (isset($this->profile[$name])) { |
76 | 76 | $this->profile[$name]['time'] += $time; |
77 | - $this->profile[$name]['calls'] ++; |
|
77 | + $this->profile[$name]['calls']++; |
|
78 | 78 | $this->profile[$name]['cache_cold_hits'] += ($wp_object_cache->cold_cache_hits - $item['cache_cold_hits']); |
79 | 79 | $this->profile[$name]['cache_warm_hits'] += ($wp_object_cache->warm_cache_hits - $item['cache_warm_hits']); |
80 | 80 | $this->profile[$name]['cache_misses'] += ($wp_object_cache->cache_misses - $item['cache_misses']); |
81 | - $this->profile[$name]['cache_dirty_objects'] = array_add( $this->profile[$name]['cache_dirty_objects'], $cache_dirty_delta) ; |
|
82 | - $this->profile[$name]['actions'] = array_add( $this->profile[$name]['actions'], $item['actions'] ); |
|
83 | - $this->profile[$name]['filters'] = array_add( $this->profile[$name]['filters'], $item['filters'] ); |
|
84 | - $this->profile[$name]['queries'] = array_add( $this->profile[$name]['queries'], $item['queries'] ); |
|
81 | + $this->profile[$name]['cache_dirty_objects'] = array_add($this->profile[$name]['cache_dirty_objects'], $cache_dirty_delta); |
|
82 | + $this->profile[$name]['actions'] = array_add($this->profile[$name]['actions'], $item['actions']); |
|
83 | + $this->profile[$name]['filters'] = array_add($this->profile[$name]['filters'], $item['filters']); |
|
84 | + $this->profile[$name]['queries'] = array_add($this->profile[$name]['queries'], $item['queries']); |
|
85 | 85 | #$this->_query_summary($item['queries'], $this->profile[$name]['queries']); |
86 | 86 | |
87 | 87 | } |
@@ -109,28 +109,28 @@ discard block |
||
109 | 109 | |
110 | 110 | function microtime($since = 0.0) { |
111 | 111 | list($usec, $sec) = explode(' ', microtime()); |
112 | - return (float)$sec + (float)$usec - $since; |
|
112 | + return (float) $sec + (float) $usec - $since; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | function log_filter($tag) { |
116 | 116 | if ($this->stack) { |
117 | 117 | global $wp_actions; |
118 | 118 | if ($tag == end($wp_actions)) |
119 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
119 | + @$this->stack[count($this->stack) - 1]['actions'][$tag]++; |
|
120 | 120 | else |
121 | - @$this->stack[count($this->stack)-1]['filters'][$tag] ++; |
|
121 | + @$this->stack[count($this->stack) - 1]['filters'][$tag]++; |
|
122 | 122 | } |
123 | 123 | return $arg; |
124 | 124 | } |
125 | 125 | |
126 | 126 | function log_action($tag) { |
127 | 127 | if ($this->stack) |
128 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
128 | + @$this->stack[count($this->stack) - 1]['actions'][$tag]++; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | function _current_action() { |
132 | 132 | global $wp_actions; |
133 | - return $wp_actions[count($wp_actions)-1]; |
|
133 | + return $wp_actions[count($wp_actions) - 1]; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function results() { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $sql = preg_replace('/(WHERE \w+ =) \d+/', '$1 x', $sql); |
144 | 144 | $sql = preg_replace('/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql); |
145 | 145 | |
146 | - @$out[$sql] ++; |
|
146 | + @$out[$sql]++; |
|
147 | 147 | } |
148 | 148 | asort($out); |
149 | 149 | return; |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | $out = array(); |
155 | 155 | foreach ($queries as $q) { |
156 | 156 | if (empty($q[2])) |
157 | - @$out['unknown'] ++; |
|
157 | + @$out['unknown']++; |
|
158 | 158 | else |
159 | - @$out[$q[2]] ++; |
|
159 | + @$out[$q[2]]++; |
|
160 | 160 | } |
161 | 161 | return $out; |
162 | 162 | } |
@@ -84,8 +84,7 @@ discard block |
||
84 | 84 | $this->profile[$name]['queries'] = array_add( $this->profile[$name]['queries'], $item['queries'] ); |
85 | 85 | #$this->_query_summary($item['queries'], $this->profile[$name]['queries']); |
86 | 86 | |
87 | - } |
|
88 | - else { |
|
87 | + } else { |
|
89 | 88 | $queries = array(); |
90 | 89 | $this->_query_summary($item['queries'], $queries); |
91 | 90 | $this->profile[$name] = array( |
@@ -115,17 +114,19 @@ discard block |
||
115 | 114 | function log_filter($tag) { |
116 | 115 | if ($this->stack) { |
117 | 116 | global $wp_actions; |
118 | - if ($tag == end($wp_actions)) |
|
119 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
120 | - else |
|
121 | - @$this->stack[count($this->stack)-1]['filters'][$tag] ++; |
|
117 | + if ($tag == end($wp_actions)) { |
|
118 | + @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
119 | + } else { |
|
120 | + @$this->stack[count($this->stack)-1]['filters'][$tag] ++; |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | return $arg; |
124 | 124 | } |
125 | 125 | |
126 | 126 | function log_action($tag) { |
127 | - if ($this->stack) |
|
128 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
127 | + if ($this->stack) { |
|
128 | + @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
129 | + } |
|
129 | 130 | } |
130 | 131 | |
131 | 132 | function _current_action() { |
@@ -153,36 +154,41 @@ discard block |
||
153 | 154 | // this requires the savequeries patch at https://core.trac.wordpress.org/ticket/5218 |
154 | 155 | $out = array(); |
155 | 156 | foreach ($queries as $q) { |
156 | - if (empty($q[2])) |
|
157 | - @$out['unknown'] ++; |
|
158 | - else |
|
159 | - @$out[$q[2]] ++; |
|
157 | + if (empty($q[2])) { |
|
158 | + @$out['unknown'] ++; |
|
159 | + } else { |
|
160 | + @$out[$q[2]] ++; |
|
161 | + } |
|
160 | 162 | } |
161 | 163 | return $out; |
162 | 164 | } |
163 | 165 | |
164 | 166 | function _dirty_objects_count($dirty_objects) { |
165 | 167 | $out = array(); |
166 | - foreach (array_keys($dirty_objects) as $group) |
|
167 | - $out[$group] = count($dirty_objects[$group]); |
|
168 | + foreach (array_keys($dirty_objects) as $group) { |
|
169 | + $out[$group] = count($dirty_objects[$group]); |
|
170 | + } |
|
168 | 171 | return $out; |
169 | 172 | } |
170 | 173 | |
171 | 174 | function array_add($a, $b) { |
172 | 175 | $out = $a; |
173 | - foreach (array_keys($b) as $key) |
|
174 | - if (array_key_exists($key, $out)) |
|
176 | + foreach (array_keys($b) as $key) { |
|
177 | + if (array_key_exists($key, $out)) |
|
175 | 178 | $out[$key] += $b[$key]; |
176 | - else |
|
177 | - $out[$key] = $b[$key]; |
|
179 | + } |
|
180 | + else { |
|
181 | + $out[$key] = $b[$key]; |
|
182 | + } |
|
178 | 183 | return $out; |
179 | 184 | } |
180 | 185 | |
181 | 186 | function array_sub($a, $b) { |
182 | 187 | $out = $a; |
183 | - foreach (array_keys($b) as $key) |
|
184 | - if (array_key_exists($key, $b)) |
|
188 | + foreach (array_keys($b) as $key) { |
|
189 | + if (array_key_exists($key, $b)) |
|
185 | 190 | $out[$key] -= $b[$key]; |
191 | + } |
|
186 | 192 | return $out; |
187 | 193 | } |
188 | 194 |
@@ -6,321 +6,321 @@ |
||
6 | 6 | */ |
7 | 7 | class SpeedTrapListener implements PHPUnit_Framework_TestListener |
8 | 8 | { |
9 | - /** |
|
10 | - * Internal tracking for test suites. |
|
11 | - * |
|
12 | - * Increments as more suites are run, then decremented as they finish. All |
|
13 | - * suites have been run when returns to 0. |
|
14 | - * |
|
15 | - * @var integer |
|
16 | - */ |
|
17 | - protected $suites = 0; |
|
18 | - |
|
19 | - /** |
|
20 | - * Time in milliseconds at which a test will be considered "slow" and be |
|
21 | - * reported by this listener. |
|
22 | - * |
|
23 | - * @var int |
|
24 | - */ |
|
25 | - protected $slowThreshold; |
|
26 | - |
|
27 | - /** |
|
28 | - * Number of tests to report on for slowness. |
|
29 | - * |
|
30 | - * @var int |
|
31 | - */ |
|
32 | - protected $reportLength; |
|
33 | - |
|
34 | - /** |
|
35 | - * Collection of slow tests. |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $slow = array(); |
|
40 | - |
|
41 | - /** |
|
42 | - * Construct a new instance. |
|
43 | - * |
|
44 | - * @param array $options |
|
45 | - */ |
|
46 | - public function __construct(array $options = array()) |
|
47 | - { |
|
48 | - $this->loadOptions($options); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * An error occurred. |
|
53 | - * |
|
54 | - * @param PHPUnit_Framework_Test $test |
|
55 | - * @param Exception $e |
|
56 | - * @param float $time |
|
57 | - */ |
|
58 | - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
59 | - { |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * A warning occurred. |
|
64 | - * |
|
65 | - * @param PHPUnit_Framework_Test $test |
|
66 | - * @param PHPUnit_Framework_Warning $e |
|
67 | - * @param float $time |
|
68 | - * @since Method available since Release 5.1.0 |
|
69 | - */ |
|
70 | - public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) |
|
71 | - { |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * A failure occurred. |
|
76 | - * |
|
77 | - * @param PHPUnit_Framework_Test $test |
|
78 | - * @param PHPUnit_Framework_AssertionFailedError $e |
|
79 | - * @param float $time |
|
80 | - */ |
|
81 | - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
82 | - { |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Incomplete test. |
|
87 | - * |
|
88 | - * @param PHPUnit_Framework_Test $test |
|
89 | - * @param Exception $e |
|
90 | - * @param float $time |
|
91 | - */ |
|
92 | - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
93 | - { |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Risky test. |
|
98 | - * |
|
99 | - * @param PHPUnit_Framework_Test $test |
|
100 | - * @param Exception $e |
|
101 | - * @param float $time |
|
102 | - * @since Method available since Release 4.0.0 |
|
103 | - */ |
|
104 | - public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
105 | - { |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Skipped test. |
|
110 | - * |
|
111 | - * @param PHPUnit_Framework_Test $test |
|
112 | - * @param Exception $e |
|
113 | - * @param float $time |
|
114 | - */ |
|
115 | - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
116 | - { |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * A test started. |
|
121 | - * |
|
122 | - * @param PHPUnit_Framework_Test $test |
|
123 | - */ |
|
124 | - public function startTest(PHPUnit_Framework_Test $test) |
|
125 | - { |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * A test ended. |
|
130 | - * |
|
131 | - * @param PHPUnit_Framework_Test $test |
|
132 | - * @param float $time |
|
133 | - */ |
|
134 | - public function endTest(PHPUnit_Framework_Test $test, $time) |
|
135 | - { |
|
136 | - if (!$test instanceof PHPUnit_Framework_TestCase) return; |
|
137 | - |
|
138 | - $time = $this->toMilliseconds($time); |
|
139 | - $threshold = $this->getSlowThreshold($test); |
|
140 | - |
|
141 | - if ($this->isSlow($time, $threshold)) { |
|
142 | - $this->addSlowTest($test, $time); |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * A test suite started. |
|
148 | - * |
|
149 | - * @param PHPUnit_Framework_TestSuite $suite |
|
150 | - */ |
|
151 | - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
152 | - { |
|
153 | - $this->suites++; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * A test suite ended. |
|
158 | - * |
|
159 | - * @param PHPUnit_Framework_TestSuite $suite |
|
160 | - */ |
|
161 | - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
162 | - { |
|
163 | - $this->suites--; |
|
164 | - |
|
165 | - if (0 === $this->suites && $this->hasSlowTests()) { |
|
166 | - arsort($this->slow); // Sort longest running tests to the top |
|
167 | - |
|
168 | - $this->renderHeader(); |
|
169 | - $this->renderBody(); |
|
170 | - $this->renderFooter(); |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Whether the given test execution time is considered slow. |
|
176 | - * |
|
177 | - * @param int $time Test execution time in milliseconds |
|
178 | - * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds) |
|
179 | - * @return bool |
|
180 | - */ |
|
181 | - protected function isSlow($time, $slowThreshold) |
|
182 | - { |
|
183 | - return $time >= $slowThreshold; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Stores a test as slow. |
|
188 | - * |
|
189 | - * @param PHPUnit_Framework_TestCase $test |
|
190 | - * @param int $time Test execution time in milliseconds |
|
191 | - */ |
|
192 | - protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time) |
|
193 | - { |
|
194 | - $label = $this->makeLabel($test); |
|
195 | - |
|
196 | - $this->slow[$label] = $time; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Whether at least one test has been considered slow. |
|
201 | - * |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - protected function hasSlowTests() |
|
205 | - { |
|
206 | - return !empty($this->slow); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Convert PHPUnit's reported test time (microseconds) to milliseconds. |
|
211 | - * |
|
212 | - * @param float $time |
|
213 | - * @return int |
|
214 | - */ |
|
215 | - protected function toMilliseconds($time) |
|
216 | - { |
|
217 | - return (int) round($time * 1000); |
|
218 | - } |
|
219 | - |
|
220 | - /** |
|
221 | - * Label for describing a test. |
|
222 | - * |
|
223 | - * @param PHPUnit_Framework_TestCase $test |
|
224 | - * @return string |
|
225 | - */ |
|
226 | - protected function makeLabel(PHPUnit_Framework_TestCase $test) |
|
227 | - { |
|
228 | - return sprintf('%s:%s', get_class($test), $test->getName()); |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Calculate number of slow tests to report about. |
|
233 | - * |
|
234 | - * @return int |
|
235 | - */ |
|
236 | - protected function getReportLength() |
|
237 | - { |
|
238 | - return min(count($this->slow), $this->reportLength); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Find how many slow tests occurred that won't be shown due to list length. |
|
243 | - * |
|
244 | - * @return int Number of hidden slow tests |
|
245 | - */ |
|
246 | - protected function getHiddenCount() |
|
247 | - { |
|
248 | - $total = count($this->slow); |
|
249 | - $showing = $this->getReportLength($this->slow); |
|
250 | - |
|
251 | - $hidden = 0; |
|
252 | - if ($total > $showing) { |
|
253 | - $hidden = $total - $showing; |
|
254 | - } |
|
255 | - |
|
256 | - return $hidden; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Renders slow test report header. |
|
261 | - */ |
|
262 | - protected function renderHeader() |
|
263 | - { |
|
264 | - echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold); |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * Renders slow test report body. |
|
269 | - */ |
|
270 | - protected function renderBody() |
|
271 | - { |
|
272 | - $slowTests = $this->slow; |
|
273 | - |
|
274 | - $length = $this->getReportLength($slowTests); |
|
275 | - for ($i = 1; $i <= $length; ++$i) { |
|
276 | - $label = key($slowTests); |
|
277 | - $time = array_shift($slowTests); |
|
278 | - |
|
279 | - echo sprintf(" %s. %sms to run %s\n", $i, $time, $label); |
|
280 | - } |
|
281 | - } |
|
282 | - |
|
283 | - /** |
|
284 | - * Renders slow test report footer. |
|
285 | - */ |
|
286 | - protected function renderFooter() |
|
287 | - { |
|
288 | - if ($hidden = $this->getHiddenCount($this->slow)) { |
|
289 | - echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden); |
|
290 | - } |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Populate options into class internals. |
|
295 | - * |
|
296 | - * @param array $options |
|
297 | - */ |
|
298 | - protected function loadOptions(array $options) |
|
299 | - { |
|
300 | - $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500; |
|
301 | - $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10; |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Get slow test threshold for given test. A TestCase can override the |
|
306 | - * suite-wide slow threshold by using the annotation @slowThreshold with |
|
307 | - * the threshold value in milliseconds. |
|
308 | - * |
|
309 | - * The following test will only be considered slow when its execution time |
|
310 | - * reaches 5000ms (5 seconds): |
|
311 | - * |
|
312 | - * <code> |
|
313 | - * @slowThreshold 5000 |
|
314 | - * public function testLongRunningProcess() {} |
|
315 | - * </code> |
|
316 | - * |
|
317 | - * @param PHPUnit_Framework_TestCase $test |
|
318 | - * @return int |
|
319 | - */ |
|
320 | - protected function getSlowThreshold(PHPUnit_Framework_TestCase $test) |
|
321 | - { |
|
322 | - $ann = $test->getAnnotations(); |
|
323 | - |
|
324 | - return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold; |
|
325 | - } |
|
9 | + /** |
|
10 | + * Internal tracking for test suites. |
|
11 | + * |
|
12 | + * Increments as more suites are run, then decremented as they finish. All |
|
13 | + * suites have been run when returns to 0. |
|
14 | + * |
|
15 | + * @var integer |
|
16 | + */ |
|
17 | + protected $suites = 0; |
|
18 | + |
|
19 | + /** |
|
20 | + * Time in milliseconds at which a test will be considered "slow" and be |
|
21 | + * reported by this listener. |
|
22 | + * |
|
23 | + * @var int |
|
24 | + */ |
|
25 | + protected $slowThreshold; |
|
26 | + |
|
27 | + /** |
|
28 | + * Number of tests to report on for slowness. |
|
29 | + * |
|
30 | + * @var int |
|
31 | + */ |
|
32 | + protected $reportLength; |
|
33 | + |
|
34 | + /** |
|
35 | + * Collection of slow tests. |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $slow = array(); |
|
40 | + |
|
41 | + /** |
|
42 | + * Construct a new instance. |
|
43 | + * |
|
44 | + * @param array $options |
|
45 | + */ |
|
46 | + public function __construct(array $options = array()) |
|
47 | + { |
|
48 | + $this->loadOptions($options); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * An error occurred. |
|
53 | + * |
|
54 | + * @param PHPUnit_Framework_Test $test |
|
55 | + * @param Exception $e |
|
56 | + * @param float $time |
|
57 | + */ |
|
58 | + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
59 | + { |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * A warning occurred. |
|
64 | + * |
|
65 | + * @param PHPUnit_Framework_Test $test |
|
66 | + * @param PHPUnit_Framework_Warning $e |
|
67 | + * @param float $time |
|
68 | + * @since Method available since Release 5.1.0 |
|
69 | + */ |
|
70 | + public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) |
|
71 | + { |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * A failure occurred. |
|
76 | + * |
|
77 | + * @param PHPUnit_Framework_Test $test |
|
78 | + * @param PHPUnit_Framework_AssertionFailedError $e |
|
79 | + * @param float $time |
|
80 | + */ |
|
81 | + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
82 | + { |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Incomplete test. |
|
87 | + * |
|
88 | + * @param PHPUnit_Framework_Test $test |
|
89 | + * @param Exception $e |
|
90 | + * @param float $time |
|
91 | + */ |
|
92 | + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
93 | + { |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Risky test. |
|
98 | + * |
|
99 | + * @param PHPUnit_Framework_Test $test |
|
100 | + * @param Exception $e |
|
101 | + * @param float $time |
|
102 | + * @since Method available since Release 4.0.0 |
|
103 | + */ |
|
104 | + public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
105 | + { |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Skipped test. |
|
110 | + * |
|
111 | + * @param PHPUnit_Framework_Test $test |
|
112 | + * @param Exception $e |
|
113 | + * @param float $time |
|
114 | + */ |
|
115 | + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
116 | + { |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * A test started. |
|
121 | + * |
|
122 | + * @param PHPUnit_Framework_Test $test |
|
123 | + */ |
|
124 | + public function startTest(PHPUnit_Framework_Test $test) |
|
125 | + { |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * A test ended. |
|
130 | + * |
|
131 | + * @param PHPUnit_Framework_Test $test |
|
132 | + * @param float $time |
|
133 | + */ |
|
134 | + public function endTest(PHPUnit_Framework_Test $test, $time) |
|
135 | + { |
|
136 | + if (!$test instanceof PHPUnit_Framework_TestCase) return; |
|
137 | + |
|
138 | + $time = $this->toMilliseconds($time); |
|
139 | + $threshold = $this->getSlowThreshold($test); |
|
140 | + |
|
141 | + if ($this->isSlow($time, $threshold)) { |
|
142 | + $this->addSlowTest($test, $time); |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * A test suite started. |
|
148 | + * |
|
149 | + * @param PHPUnit_Framework_TestSuite $suite |
|
150 | + */ |
|
151 | + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
152 | + { |
|
153 | + $this->suites++; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * A test suite ended. |
|
158 | + * |
|
159 | + * @param PHPUnit_Framework_TestSuite $suite |
|
160 | + */ |
|
161 | + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
162 | + { |
|
163 | + $this->suites--; |
|
164 | + |
|
165 | + if (0 === $this->suites && $this->hasSlowTests()) { |
|
166 | + arsort($this->slow); // Sort longest running tests to the top |
|
167 | + |
|
168 | + $this->renderHeader(); |
|
169 | + $this->renderBody(); |
|
170 | + $this->renderFooter(); |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Whether the given test execution time is considered slow. |
|
176 | + * |
|
177 | + * @param int $time Test execution time in milliseconds |
|
178 | + * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds) |
|
179 | + * @return bool |
|
180 | + */ |
|
181 | + protected function isSlow($time, $slowThreshold) |
|
182 | + { |
|
183 | + return $time >= $slowThreshold; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Stores a test as slow. |
|
188 | + * |
|
189 | + * @param PHPUnit_Framework_TestCase $test |
|
190 | + * @param int $time Test execution time in milliseconds |
|
191 | + */ |
|
192 | + protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time) |
|
193 | + { |
|
194 | + $label = $this->makeLabel($test); |
|
195 | + |
|
196 | + $this->slow[$label] = $time; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Whether at least one test has been considered slow. |
|
201 | + * |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + protected function hasSlowTests() |
|
205 | + { |
|
206 | + return !empty($this->slow); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Convert PHPUnit's reported test time (microseconds) to milliseconds. |
|
211 | + * |
|
212 | + * @param float $time |
|
213 | + * @return int |
|
214 | + */ |
|
215 | + protected function toMilliseconds($time) |
|
216 | + { |
|
217 | + return (int) round($time * 1000); |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * Label for describing a test. |
|
222 | + * |
|
223 | + * @param PHPUnit_Framework_TestCase $test |
|
224 | + * @return string |
|
225 | + */ |
|
226 | + protected function makeLabel(PHPUnit_Framework_TestCase $test) |
|
227 | + { |
|
228 | + return sprintf('%s:%s', get_class($test), $test->getName()); |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Calculate number of slow tests to report about. |
|
233 | + * |
|
234 | + * @return int |
|
235 | + */ |
|
236 | + protected function getReportLength() |
|
237 | + { |
|
238 | + return min(count($this->slow), $this->reportLength); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Find how many slow tests occurred that won't be shown due to list length. |
|
243 | + * |
|
244 | + * @return int Number of hidden slow tests |
|
245 | + */ |
|
246 | + protected function getHiddenCount() |
|
247 | + { |
|
248 | + $total = count($this->slow); |
|
249 | + $showing = $this->getReportLength($this->slow); |
|
250 | + |
|
251 | + $hidden = 0; |
|
252 | + if ($total > $showing) { |
|
253 | + $hidden = $total - $showing; |
|
254 | + } |
|
255 | + |
|
256 | + return $hidden; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Renders slow test report header. |
|
261 | + */ |
|
262 | + protected function renderHeader() |
|
263 | + { |
|
264 | + echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold); |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * Renders slow test report body. |
|
269 | + */ |
|
270 | + protected function renderBody() |
|
271 | + { |
|
272 | + $slowTests = $this->slow; |
|
273 | + |
|
274 | + $length = $this->getReportLength($slowTests); |
|
275 | + for ($i = 1; $i <= $length; ++$i) { |
|
276 | + $label = key($slowTests); |
|
277 | + $time = array_shift($slowTests); |
|
278 | + |
|
279 | + echo sprintf(" %s. %sms to run %s\n", $i, $time, $label); |
|
280 | + } |
|
281 | + } |
|
282 | + |
|
283 | + /** |
|
284 | + * Renders slow test report footer. |
|
285 | + */ |
|
286 | + protected function renderFooter() |
|
287 | + { |
|
288 | + if ($hidden = $this->getHiddenCount($this->slow)) { |
|
289 | + echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden); |
|
290 | + } |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * Populate options into class internals. |
|
295 | + * |
|
296 | + * @param array $options |
|
297 | + */ |
|
298 | + protected function loadOptions(array $options) |
|
299 | + { |
|
300 | + $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500; |
|
301 | + $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10; |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Get slow test threshold for given test. A TestCase can override the |
|
306 | + * suite-wide slow threshold by using the annotation @slowThreshold with |
|
307 | + * the threshold value in milliseconds. |
|
308 | + * |
|
309 | + * The following test will only be considered slow when its execution time |
|
310 | + * reaches 5000ms (5 seconds): |
|
311 | + * |
|
312 | + * <code> |
|
313 | + * @slowThreshold 5000 |
|
314 | + * public function testLongRunningProcess() {} |
|
315 | + * </code> |
|
316 | + * |
|
317 | + * @param PHPUnit_Framework_TestCase $test |
|
318 | + * @return int |
|
319 | + */ |
|
320 | + protected function getSlowThreshold(PHPUnit_Framework_TestCase $test) |
|
321 | + { |
|
322 | + $ann = $test->getAnnotations(); |
|
323 | + |
|
324 | + return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold; |
|
325 | + } |
|
326 | 326 | } |
@@ -133,7 +133,9 @@ |
||
133 | 133 | */ |
134 | 134 | public function endTest(PHPUnit_Framework_Test $test, $time) |
135 | 135 | { |
136 | - if (!$test instanceof PHPUnit_Framework_TestCase) return; |
|
136 | + if (!$test instanceof PHPUnit_Framework_TestCase) { |
|
137 | + return; |
|
138 | + } |
|
137 | 139 | |
138 | 140 | $time = $this->toMilliseconds($time); |
139 | 141 | $threshold = $this->getSlowThreshold($test); |