@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | $type = $upload['type']; |
105 | 105 | } else { |
106 | 106 | $mime = wp_check_filetype( $upload['file'] ); |
107 | - if ($mime) |
|
108 | - $type = $mime['type']; |
|
107 | + if ($mime) { |
|
108 | + $type = $mime['type']; |
|
109 | + } |
|
109 | 110 | } |
110 | 111 | |
111 | 112 | $attachment = array( |
@@ -268,15 +269,17 @@ discard block |
||
268 | 269 | function create_object( $args ) { |
269 | 270 | $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
270 | 271 | $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
271 | - if ( is_wp_error( $term_id_pair ) ) |
|
272 | - return $term_id_pair; |
|
272 | + if ( is_wp_error( $term_id_pair ) ) { |
|
273 | + return $term_id_pair; |
|
274 | + } |
|
273 | 275 | return $term_id_pair['term_id']; |
274 | 276 | } |
275 | 277 | |
276 | 278 | function update_object( $term, $fields ) { |
277 | 279 | $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
278 | - if ( is_object( $term ) ) |
|
279 | - $taxonomy = $term->taxonomy; |
|
280 | + if ( is_object( $term ) ) { |
|
281 | + $taxonomy = $term->taxonomy; |
|
282 | + } |
|
280 | 283 | $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
281 | 284 | return $term_id_pair['term_id']; |
282 | 285 | } |
@@ -318,19 +321,22 @@ discard block |
||
318 | 321 | abstract function update_object( $object, $fields ); |
319 | 322 | |
320 | 323 | function create( $args = array(), $generation_definitions = null ) { |
321 | - if ( is_null( $generation_definitions ) ) |
|
322 | - $generation_definitions = $this->default_generation_definitions; |
|
324 | + if ( is_null( $generation_definitions ) ) { |
|
325 | + $generation_definitions = $this->default_generation_definitions; |
|
326 | + } |
|
323 | 327 | |
324 | 328 | $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
325 | 329 | $created = $this->create_object( $generated_args ); |
326 | - if ( !$created || is_wp_error( $created ) ) |
|
327 | - return $created; |
|
330 | + if ( !$created || is_wp_error( $created ) ) { |
|
331 | + return $created; |
|
332 | + } |
|
328 | 333 | |
329 | 334 | if ( $callbacks ) { |
330 | 335 | $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
331 | 336 | $save_result = $this->update_object( $created, $updated_fields ); |
332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
333 | - return $save_result; |
|
337 | + if ( !$save_result || is_wp_error( $save_result ) ) { |
|
338 | + return $save_result; |
|
339 | + } |
|
334 | 340 | } |
335 | 341 | return $created; |
336 | 342 | } |
@@ -352,20 +358,22 @@ discard block |
||
352 | 358 | |
353 | 359 | function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
354 | 360 | $callbacks = array(); |
355 | - if ( is_null( $generation_definitions ) ) |
|
356 | - $generation_definitions = $this->default_generation_definitions; |
|
361 | + if ( is_null( $generation_definitions ) ) { |
|
362 | + $generation_definitions = $this->default_generation_definitions; |
|
363 | + } |
|
357 | 364 | |
358 | 365 | foreach( array_keys( $generation_definitions ) as $field_name ) { |
359 | 366 | if ( !isset( $args[$field_name] ) ) { |
360 | 367 | $generator = $generation_definitions[$field_name]; |
361 | - if ( is_scalar( $generator ) ) |
|
362 | - $args[$field_name] = $generator; |
|
363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
368 | + if ( is_scalar( $generator ) ) { |
|
369 | + $args[$field_name] = $generator; |
|
370 | + } elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
364 | 371 | $callbacks[$field_name] = $generator; |
365 | - } elseif ( is_object( $generator ) ) |
|
366 | - $args[$field_name] = $generator->next(); |
|
367 | - else |
|
368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
372 | + } elseif ( is_object( $generator ) ) { |
|
373 | + $args[$field_name] = $generator->next(); |
|
374 | + } else { |
|
375 | + return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
376 | + } |
|
369 | 377 | } |
370 | 378 | } |
371 | 379 | return $args; |
@@ -48,78 +48,78 @@ discard block |
||
48 | 48 | public $network; |
49 | 49 | |
50 | 50 | function __construct() { |
51 | - $this->post = new WP_UnitTest_Factory_For_Post( $this ); |
|
52 | - $this->attachment = new WP_UnitTest_Factory_For_Attachment( $this ); |
|
53 | - $this->comment = new WP_UnitTest_Factory_For_Comment( $this ); |
|
54 | - $this->user = new WP_UnitTest_Factory_For_User( $this ); |
|
55 | - $this->term = new WP_UnitTest_Factory_For_Term( $this ); |
|
56 | - $this->category = new WP_UnitTest_Factory_For_Term( $this, 'category' ); |
|
57 | - $this->tag = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' ); |
|
58 | - if ( is_multisite() ) { |
|
59 | - $this->blog = new WP_UnitTest_Factory_For_Blog( $this ); |
|
60 | - $this->network = new WP_UnitTest_Factory_For_Network( $this ); |
|
51 | + $this->post = new WP_UnitTest_Factory_For_Post($this); |
|
52 | + $this->attachment = new WP_UnitTest_Factory_For_Attachment($this); |
|
53 | + $this->comment = new WP_UnitTest_Factory_For_Comment($this); |
|
54 | + $this->user = new WP_UnitTest_Factory_For_User($this); |
|
55 | + $this->term = new WP_UnitTest_Factory_For_Term($this); |
|
56 | + $this->category = new WP_UnitTest_Factory_For_Term($this, 'category'); |
|
57 | + $this->tag = new WP_UnitTest_Factory_For_Term($this, 'post_tag'); |
|
58 | + if (is_multisite()) { |
|
59 | + $this->blog = new WP_UnitTest_Factory_For_Blog($this); |
|
60 | + $this->network = new WP_UnitTest_Factory_For_Network($this); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | 65 | class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { |
66 | 66 | |
67 | - function __construct( $factory = null ) { |
|
68 | - parent::__construct( $factory ); |
|
67 | + function __construct($factory = null) { |
|
68 | + parent::__construct($factory); |
|
69 | 69 | $this->default_generation_definitions = array( |
70 | 70 | 'post_status' => 'publish', |
71 | - 'post_title' => new WP_UnitTest_Generator_Sequence( 'Post title %s' ), |
|
72 | - 'post_content' => new WP_UnitTest_Generator_Sequence( 'Post content %s' ), |
|
73 | - 'post_excerpt' => new WP_UnitTest_Generator_Sequence( 'Post excerpt %s' ), |
|
71 | + 'post_title' => new WP_UnitTest_Generator_Sequence('Post title %s'), |
|
72 | + 'post_content' => new WP_UnitTest_Generator_Sequence('Post content %s'), |
|
73 | + 'post_excerpt' => new WP_UnitTest_Generator_Sequence('Post excerpt %s'), |
|
74 | 74 | 'post_type' => 'post' |
75 | 75 | ); |
76 | 76 | } |
77 | 77 | |
78 | - function create_object( $args ) { |
|
79 | - return wp_insert_post( $args ); |
|
78 | + function create_object($args) { |
|
79 | + return wp_insert_post($args); |
|
80 | 80 | } |
81 | 81 | |
82 | - function update_object( $post_id, $fields ) { |
|
82 | + function update_object($post_id, $fields) { |
|
83 | 83 | $fields['ID'] = $post_id; |
84 | - return wp_update_post( $fields ); |
|
84 | + return wp_update_post($fields); |
|
85 | 85 | } |
86 | 86 | |
87 | - function get_object_by_id( $post_id ) { |
|
88 | - return get_post( $post_id ); |
|
87 | + function get_object_by_id($post_id) { |
|
88 | + return get_post($post_id); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post { |
93 | 93 | |
94 | - function create_object( $file, $parent = 0, $args = array() ) { |
|
95 | - return wp_insert_attachment( $args, $file, $parent ); |
|
94 | + function create_object($file, $parent = 0, $args = array()) { |
|
95 | + return wp_insert_attachment($args, $file, $parent); |
|
96 | 96 | } |
97 | 97 | |
98 | - function create_upload_object( $file, $parent = 0 ) { |
|
98 | + function create_upload_object($file, $parent = 0) { |
|
99 | 99 | $contents = file_get_contents($file); |
100 | 100 | $upload = wp_upload_bits(basename($file), null, $contents); |
101 | 101 | |
102 | 102 | $type = ''; |
103 | - if ( ! empty($upload['type']) ) { |
|
103 | + if (!empty($upload['type'])) { |
|
104 | 104 | $type = $upload['type']; |
105 | 105 | } else { |
106 | - $mime = wp_check_filetype( $upload['file'] ); |
|
106 | + $mime = wp_check_filetype($upload['file']); |
|
107 | 107 | if ($mime) |
108 | 108 | $type = $mime['type']; |
109 | 109 | } |
110 | 110 | |
111 | 111 | $attachment = array( |
112 | - 'post_title' => basename( $upload['file'] ), |
|
112 | + 'post_title' => basename($upload['file']), |
|
113 | 113 | 'post_content' => '', |
114 | 114 | 'post_type' => 'attachment', |
115 | 115 | 'post_parent' => $parent, |
116 | 116 | 'post_mime_type' => $type, |
117 | - 'guid' => $upload[ 'url' ], |
|
117 | + 'guid' => $upload['url'], |
|
118 | 118 | ); |
119 | 119 | |
120 | 120 | // Save the data |
121 | - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent ); |
|
122 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
|
121 | + $id = wp_insert_attachment($attachment, $upload['file'], $parent); |
|
122 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file'])); |
|
123 | 123 | |
124 | 124 | return $id; |
125 | 125 | } |
@@ -127,126 +127,126 @@ discard block |
||
127 | 127 | |
128 | 128 | class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing { |
129 | 129 | |
130 | - function __construct( $factory = null ) { |
|
131 | - parent::__construct( $factory ); |
|
130 | + function __construct($factory = null) { |
|
131 | + parent::__construct($factory); |
|
132 | 132 | $this->default_generation_definitions = array( |
133 | - 'user_login' => new WP_UnitTest_Generator_Sequence( 'User %s' ), |
|
133 | + 'user_login' => new WP_UnitTest_Generator_Sequence('User %s'), |
|
134 | 134 | 'user_pass' => 'password', |
135 | - 'user_email' => new WP_UnitTest_Generator_Sequence( 'user_%[email protected]' ), |
|
135 | + 'user_email' => new WP_UnitTest_Generator_Sequence('user_%[email protected]'), |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | |
139 | - function create_object( $args ) { |
|
140 | - return wp_insert_user( $args ); |
|
139 | + function create_object($args) { |
|
140 | + return wp_insert_user($args); |
|
141 | 141 | } |
142 | 142 | |
143 | - function update_object( $user_id, $fields ) { |
|
143 | + function update_object($user_id, $fields) { |
|
144 | 144 | $fields['ID'] = $user_id; |
145 | - return wp_update_user( $fields ); |
|
145 | + return wp_update_user($fields); |
|
146 | 146 | } |
147 | 147 | |
148 | - function get_object_by_id( $user_id ) { |
|
149 | - return new WP_User( $user_id ); |
|
148 | + function get_object_by_id($user_id) { |
|
149 | + return new WP_User($user_id); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing { |
154 | 154 | |
155 | - function __construct( $factory = null ) { |
|
156 | - parent::__construct( $factory ); |
|
155 | + function __construct($factory = null) { |
|
156 | + parent::__construct($factory); |
|
157 | 157 | $this->default_generation_definitions = array( |
158 | - 'comment_author' => new WP_UnitTest_Generator_Sequence( 'Commenter %s' ), |
|
159 | - 'comment_author_url' => new WP_UnitTest_Generator_Sequence( 'http://example.com/%s/' ), |
|
158 | + 'comment_author' => new WP_UnitTest_Generator_Sequence('Commenter %s'), |
|
159 | + 'comment_author_url' => new WP_UnitTest_Generator_Sequence('http://example.com/%s/'), |
|
160 | 160 | 'comment_approved' => 1, |
161 | 161 | 'comment_content' => 'This is a comment' |
162 | 162 | ); |
163 | 163 | } |
164 | 164 | |
165 | - function create_object( $args ) { |
|
166 | - return wp_insert_comment( $this->addslashes_deep( $args ) ); |
|
165 | + function create_object($args) { |
|
166 | + return wp_insert_comment($this->addslashes_deep($args)); |
|
167 | 167 | } |
168 | 168 | |
169 | - function update_object( $comment_id, $fields ) { |
|
169 | + function update_object($comment_id, $fields) { |
|
170 | 170 | $fields['comment_ID'] = $comment_id; |
171 | - return wp_update_comment( $this->addslashes_deep( $fields ) ); |
|
171 | + return wp_update_comment($this->addslashes_deep($fields)); |
|
172 | 172 | } |
173 | 173 | |
174 | - function create_post_comments( $post_id, $count = 1, $args = array(), $generation_definitions = null ) { |
|
174 | + function create_post_comments($post_id, $count = 1, $args = array(), $generation_definitions = null) { |
|
175 | 175 | $args['comment_post_ID'] = $post_id; |
176 | - return $this->create_many( $count, $args, $generation_definitions ); |
|
176 | + return $this->create_many($count, $args, $generation_definitions); |
|
177 | 177 | } |
178 | 178 | |
179 | - function get_object_by_id( $comment_id ) { |
|
180 | - return get_comment( $comment_id ); |
|
179 | + function get_object_by_id($comment_id) { |
|
180 | + return get_comment($comment_id); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { |
185 | 185 | |
186 | - function __construct( $factory = null ) { |
|
186 | + function __construct($factory = null) { |
|
187 | 187 | global $current_site, $base; |
188 | - parent::__construct( $factory ); |
|
188 | + parent::__construct($factory); |
|
189 | 189 | $this->default_generation_definitions = array( |
190 | 190 | 'domain' => $current_site->domain, |
191 | - 'path' => new WP_UnitTest_Generator_Sequence( $base . 'testpath%s' ), |
|
192 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Site %s' ), |
|
191 | + 'path' => new WP_UnitTest_Generator_Sequence($base.'testpath%s'), |
|
192 | + 'title' => new WP_UnitTest_Generator_Sequence('Site %s'), |
|
193 | 193 | 'site_id' => $current_site->id, |
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | - function create_object( $args ) { |
|
197 | + function create_object($args) { |
|
198 | 198 | global $wpdb; |
199 | - $meta = isset( $args['meta'] ) ? $args['meta'] : array(); |
|
200 | - $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
199 | + $meta = isset($args['meta']) ? $args['meta'] : array(); |
|
200 | + $user_id = isset($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
201 | 201 | // temp tables will trigger db errors when we attempt to reference them as new temp tables |
202 | 202 | $suppress = $wpdb->suppress_errors(); |
203 | - $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); |
|
204 | - $wpdb->suppress_errors( $suppress ); |
|
203 | + $blog = wpmu_create_blog($args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id']); |
|
204 | + $wpdb->suppress_errors($suppress); |
|
205 | 205 | |
206 | 206 | // Tell WP we're done installing. |
207 | - wp_installing( false ); |
|
207 | + wp_installing(false); |
|
208 | 208 | |
209 | 209 | return $blog; |
210 | 210 | } |
211 | 211 | |
212 | - function update_object( $blog_id, $fields ) {} |
|
212 | + function update_object($blog_id, $fields) {} |
|
213 | 213 | |
214 | - function get_object_by_id( $blog_id ) { |
|
215 | - return get_blog_details( $blog_id, false ); |
|
214 | + function get_object_by_id($blog_id) { |
|
215 | + return get_blog_details($blog_id, false); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | 219 | |
220 | 220 | class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing { |
221 | 221 | |
222 | - function __construct( $factory = null ) { |
|
223 | - parent::__construct( $factory ); |
|
222 | + function __construct($factory = null) { |
|
223 | + parent::__construct($factory); |
|
224 | 224 | $this->default_generation_definitions = array( |
225 | 225 | 'domain' => WP_TESTS_DOMAIN, |
226 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Network %s' ), |
|
227 | - 'path' => new WP_UnitTest_Generator_Sequence( '/testpath%s/' ), |
|
228 | - 'network_id' => new WP_UnitTest_Generator_Sequence( '%s', 2 ), |
|
226 | + 'title' => new WP_UnitTest_Generator_Sequence('Network %s'), |
|
227 | + 'path' => new WP_UnitTest_Generator_Sequence('/testpath%s/'), |
|
228 | + 'network_id' => new WP_UnitTest_Generator_Sequence('%s', 2), |
|
229 | 229 | 'subdomain_install' => false, |
230 | 230 | ); |
231 | 231 | } |
232 | 232 | |
233 | - function create_object( $args ) { |
|
234 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
233 | + function create_object($args) { |
|
234 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
235 | 235 | |
236 | - if ( ! isset( $args['user'] ) ) { |
|
236 | + if (!isset($args['user'])) { |
|
237 | 237 | $email = WP_TESTS_EMAIL; |
238 | 238 | } else { |
239 | - $email = get_userdata( $args['user'] )->user_email; |
|
239 | + $email = get_userdata($args['user'])->user_email; |
|
240 | 240 | } |
241 | 241 | |
242 | - populate_network( $args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install'] ); |
|
242 | + populate_network($args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install']); |
|
243 | 243 | return $args['network_id']; |
244 | 244 | } |
245 | 245 | |
246 | - function update_object( $network_id, $fields ) {} |
|
246 | + function update_object($network_id, $fields) {} |
|
247 | 247 | |
248 | - function get_object_by_id( $network_id ) { |
|
249 | - return wp_get_network( $network_id ); |
|
248 | + function get_object_by_id($network_id) { |
|
249 | + return wp_get_network($network_id); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -255,44 +255,44 @@ discard block |
||
255 | 255 | private $taxonomy; |
256 | 256 | const DEFAULT_TAXONOMY = 'post_tag'; |
257 | 257 | |
258 | - function __construct( $factory = null, $taxonomy = null ) { |
|
259 | - parent::__construct( $factory ); |
|
258 | + function __construct($factory = null, $taxonomy = null) { |
|
259 | + parent::__construct($factory); |
|
260 | 260 | $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; |
261 | 261 | $this->default_generation_definitions = array( |
262 | - 'name' => new WP_UnitTest_Generator_Sequence( 'Term %s' ), |
|
262 | + 'name' => new WP_UnitTest_Generator_Sequence('Term %s'), |
|
263 | 263 | 'taxonomy' => $this->taxonomy, |
264 | - 'description' => new WP_UnitTest_Generator_Sequence( 'Term description %s' ), |
|
264 | + 'description' => new WP_UnitTest_Generator_Sequence('Term description %s'), |
|
265 | 265 | ); |
266 | 266 | } |
267 | 267 | |
268 | - function create_object( $args ) { |
|
269 | - $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
|
270 | - $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
|
271 | - if ( is_wp_error( $term_id_pair ) ) |
|
268 | + function create_object($args) { |
|
269 | + $args = array_merge(array('taxonomy' => $this->taxonomy), $args); |
|
270 | + $term_id_pair = wp_insert_term($args['name'], $args['taxonomy'], $args); |
|
271 | + if (is_wp_error($term_id_pair)) |
|
272 | 272 | return $term_id_pair; |
273 | 273 | return $term_id_pair['term_id']; |
274 | 274 | } |
275 | 275 | |
276 | - function update_object( $term, $fields ) { |
|
277 | - $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
|
278 | - if ( is_object( $term ) ) |
|
276 | + function update_object($term, $fields) { |
|
277 | + $fields = array_merge(array('taxonomy' => $this->taxonomy), $fields); |
|
278 | + if (is_object($term)) |
|
279 | 279 | $taxonomy = $term->taxonomy; |
280 | - $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
|
280 | + $term_id_pair = wp_update_term($term, $taxonomy, $fields); |
|
281 | 281 | return $term_id_pair['term_id']; |
282 | 282 | } |
283 | 283 | |
284 | - function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) { |
|
285 | - return wp_set_post_terms( $post_id, $terms, $taxonomy, $append ); |
|
284 | + function add_post_terms($post_id, $terms, $taxonomy, $append = true) { |
|
285 | + return wp_set_post_terms($post_id, $terms, $taxonomy, $append); |
|
286 | 286 | } |
287 | 287 | |
288 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
289 | - $term_id = $this->create( $args, $generation_definitions ); |
|
290 | - $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy; |
|
291 | - return get_term( $term_id, $taxonomy ); |
|
288 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
289 | + $term_id = $this->create($args, $generation_definitions); |
|
290 | + $taxonomy = isset($args['taxonomy']) ? $args['taxonomy'] : $this->taxonomy; |
|
291 | + return get_term($term_id, $taxonomy); |
|
292 | 292 | } |
293 | 293 | |
294 | - function get_object_by_id( $term_id ) { |
|
295 | - return get_term( $term_id, $this->taxonomy ); |
|
294 | + function get_object_by_id($term_id) { |
|
295 | + return get_term($term_id, $this->taxonomy); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
@@ -309,90 +309,90 @@ discard block |
||
309 | 309 | * can be generators -- an object with next() method. There are some default generators: {@link WP_UnitTest_Generator_Sequence}, |
310 | 310 | * {@link WP_UnitTest_Generator_Locale_Name}, {@link WP_UnitTest_Factory_Callback_After_Create}. |
311 | 311 | */ |
312 | - function __construct( $factory, $default_generation_definitions = array() ) { |
|
312 | + function __construct($factory, $default_generation_definitions = array()) { |
|
313 | 313 | $this->factory = $factory; |
314 | 314 | $this->default_generation_definitions = $default_generation_definitions; |
315 | 315 | } |
316 | 316 | |
317 | - abstract function create_object( $args ); |
|
318 | - abstract function update_object( $object, $fields ); |
|
317 | + abstract function create_object($args); |
|
318 | + abstract function update_object($object, $fields); |
|
319 | 319 | |
320 | - function create( $args = array(), $generation_definitions = null ) { |
|
321 | - if ( is_null( $generation_definitions ) ) |
|
320 | + function create($args = array(), $generation_definitions = null) { |
|
321 | + if (is_null($generation_definitions)) |
|
322 | 322 | $generation_definitions = $this->default_generation_definitions; |
323 | 323 | |
324 | - $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
|
325 | - $created = $this->create_object( $generated_args ); |
|
326 | - if ( !$created || is_wp_error( $created ) ) |
|
324 | + $generated_args = $this->generate_args($args, $generation_definitions, $callbacks); |
|
325 | + $created = $this->create_object($generated_args); |
|
326 | + if (!$created || is_wp_error($created)) |
|
327 | 327 | return $created; |
328 | 328 | |
329 | - if ( $callbacks ) { |
|
330 | - $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
|
331 | - $save_result = $this->update_object( $created, $updated_fields ); |
|
332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
329 | + if ($callbacks) { |
|
330 | + $updated_fields = $this->apply_callbacks($callbacks, $created); |
|
331 | + $save_result = $this->update_object($created, $updated_fields); |
|
332 | + if (!$save_result || is_wp_error($save_result)) |
|
333 | 333 | return $save_result; |
334 | 334 | } |
335 | 335 | return $created; |
336 | 336 | } |
337 | 337 | |
338 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
339 | - $object_id = $this->create( $args, $generation_definitions ); |
|
340 | - return $this->get_object_by_id( $object_id ); |
|
338 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
339 | + $object_id = $this->create($args, $generation_definitions); |
|
340 | + return $this->get_object_by_id($object_id); |
|
341 | 341 | } |
342 | 342 | |
343 | - abstract function get_object_by_id( $object_id ); |
|
343 | + abstract function get_object_by_id($object_id); |
|
344 | 344 | |
345 | - function create_many( $count, $args = array(), $generation_definitions = null ) { |
|
345 | + function create_many($count, $args = array(), $generation_definitions = null) { |
|
346 | 346 | $results = array(); |
347 | - for ( $i = 0; $i < $count; $i++ ) { |
|
348 | - $results[] = $this->create( $args, $generation_definitions ); |
|
347 | + for ($i = 0; $i < $count; $i++) { |
|
348 | + $results[] = $this->create($args, $generation_definitions); |
|
349 | 349 | } |
350 | 350 | return $results; |
351 | 351 | } |
352 | 352 | |
353 | - function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
|
353 | + function generate_args($args = array(), $generation_definitions = null, &$callbacks = null) { |
|
354 | 354 | $callbacks = array(); |
355 | - if ( is_null( $generation_definitions ) ) |
|
355 | + if (is_null($generation_definitions)) |
|
356 | 356 | $generation_definitions = $this->default_generation_definitions; |
357 | 357 | |
358 | - foreach( array_keys( $generation_definitions ) as $field_name ) { |
|
359 | - if ( !isset( $args[$field_name] ) ) { |
|
358 | + foreach (array_keys($generation_definitions) as $field_name) { |
|
359 | + if (!isset($args[$field_name])) { |
|
360 | 360 | $generator = $generation_definitions[$field_name]; |
361 | - if ( is_scalar( $generator ) ) |
|
361 | + if (is_scalar($generator)) |
|
362 | 362 | $args[$field_name] = $generator; |
363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
363 | + elseif (is_object($generator) && method_exists($generator, 'call')) { |
|
364 | 364 | $callbacks[$field_name] = $generator; |
365 | - } elseif ( is_object( $generator ) ) |
|
365 | + } elseif (is_object($generator)) |
|
366 | 366 | $args[$field_name] = $generator->next(); |
367 | 367 | else |
368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
368 | + return new WP_Error('invalid_argument', 'Factory default value should be either a scalar or an generator object.'); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 | return $args; |
372 | 372 | } |
373 | 373 | |
374 | - function apply_callbacks( $callbacks, $created ) { |
|
374 | + function apply_callbacks($callbacks, $created) { |
|
375 | 375 | $updated_fields = array(); |
376 | - foreach( $callbacks as $field_name => $generator ) { |
|
377 | - $updated_fields[$field_name] = $generator->call( $created ); |
|
376 | + foreach ($callbacks as $field_name => $generator) { |
|
377 | + $updated_fields[$field_name] = $generator->call($created); |
|
378 | 378 | } |
379 | 379 | return $updated_fields; |
380 | 380 | } |
381 | 381 | |
382 | - function callback( $function ) { |
|
383 | - return new WP_UnitTest_Factory_Callback_After_Create( $function ); |
|
382 | + function callback($function) { |
|
383 | + return new WP_UnitTest_Factory_Callback_After_Create($function); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | function addslashes_deep($value) { |
387 | - if ( is_array( $value ) ) { |
|
388 | - $value = array_map( array( $this, 'addslashes_deep' ), $value ); |
|
389 | - } elseif ( is_object( $value ) ) { |
|
390 | - $vars = get_object_vars( $value ); |
|
387 | + if (is_array($value)) { |
|
388 | + $value = array_map(array($this, 'addslashes_deep'), $value); |
|
389 | + } elseif (is_object($value)) { |
|
390 | + $vars = get_object_vars($value); |
|
391 | 391 | foreach ($vars as $key=>$data) { |
392 | - $value->{$key} = $this->addslashes_deep( $data ); |
|
392 | + $value->{$key} = $this->addslashes_deep($data); |
|
393 | 393 | } |
394 | - } elseif ( is_string( $value ) ) { |
|
395 | - $value = addslashes( $value ); |
|
394 | + } elseif (is_string($value)) { |
|
395 | + $value = addslashes($value); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | return $value; |
@@ -405,8 +405,8 @@ discard block |
||
405 | 405 | public $next; |
406 | 406 | public $template_string; |
407 | 407 | |
408 | - function __construct( $template_string = '%s', $start = null ) { |
|
409 | - if ( $start ) { |
|
408 | + function __construct($template_string = '%s', $start = null) { |
|
409 | + if ($start) { |
|
410 | 410 | $this->next = $start; |
411 | 411 | } else { |
412 | 412 | self::$incr++; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | function next() { |
419 | - $generated = sprintf( $this->template_string , $this->next ); |
|
419 | + $generated = sprintf($this->template_string, $this->next); |
|
420 | 420 | $this->next++; |
421 | 421 | return $generated; |
422 | 422 | } |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | class WP_UnitTest_Factory_Callback_After_Create { |
426 | 426 | var $callback; |
427 | 427 | |
428 | - function __construct( $callback ) { |
|
428 | + function __construct($callback) { |
|
429 | 429 | $this->callback = $callback; |
430 | 430 | } |
431 | 431 | |
432 | - function call( $object ) { |
|
433 | - return call_user_func( $this->callback, $object ); |
|
432 | + function call($object) { |
|
433 | + return call_user_func($this->callback, $object); |
|
434 | 434 | } |
435 | 435 | } |
@@ -1,38 +1,38 @@ |
||
1 | 1 | <?php |
2 | 2 | class SearchWithKeyword extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testSearchWithKeyword() |
|
10 | - { |
|
11 | - $_REQUEST['geodir_search'] = 1; |
|
12 | - $query_args = array( |
|
13 | - 'post_status' => 'publish', |
|
14 | - 'post_type' => 'gd_place', |
|
15 | - 'posts_per_page' => 1, |
|
16 | - 's' => 'Longwood Gardens' |
|
17 | - ); |
|
9 | + public function testSearchWithKeyword() |
|
10 | + { |
|
11 | + $_REQUEST['geodir_search'] = 1; |
|
12 | + $query_args = array( |
|
13 | + 'post_status' => 'publish', |
|
14 | + 'post_type' => 'gd_place', |
|
15 | + 'posts_per_page' => 1, |
|
16 | + 's' => 'Longwood Gardens' |
|
17 | + ); |
|
18 | 18 | |
19 | - $all_posts = new WP_Query( $query_args ); |
|
19 | + $all_posts = new WP_Query( $query_args ); |
|
20 | 20 | |
21 | - $total_posts = $all_posts->found_posts; |
|
21 | + $total_posts = $all_posts->found_posts; |
|
22 | 22 | |
23 | - $this->assertTrue(is_int((int) $total_posts)); |
|
23 | + $this->assertTrue(is_int((int) $total_posts)); |
|
24 | 24 | |
25 | - $title = null; |
|
26 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
27 | - $title = get_the_title(); |
|
28 | - endwhile; |
|
25 | + $title = null; |
|
26 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
27 | + $title = get_the_title(); |
|
28 | + endwhile; |
|
29 | 29 | |
30 | - $this->assertEquals($title, 'Longwood Gardens'); |
|
31 | - } |
|
30 | + $this->assertEquals($title, 'Longwood Gardens'); |
|
31 | + } |
|
32 | 32 | |
33 | - public function tearDown() |
|
34 | - { |
|
35 | - parent::tearDown(); |
|
36 | - } |
|
33 | + public function tearDown() |
|
34 | + { |
|
35 | + parent::tearDown(); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | ?> |
39 | 39 | \ No newline at end of file |
@@ -16,14 +16,14 @@ |
||
16 | 16 | 's' => 'Longwood Gardens' |
17 | 17 | ); |
18 | 18 | |
19 | - $all_posts = new WP_Query( $query_args ); |
|
19 | + $all_posts = new WP_Query($query_args); |
|
20 | 20 | |
21 | 21 | $total_posts = $all_posts->found_posts; |
22 | 22 | |
23 | 23 | $this->assertTrue(is_int((int) $total_posts)); |
24 | 24 | |
25 | 25 | $title = null; |
26 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
26 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
27 | 27 | $title = get_the_title(); |
28 | 28 | endwhile; |
29 | 29 |
@@ -1,39 +1,39 @@ |
||
1 | 1 | <?php |
2 | 2 | class AddListing extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - wp_set_current_user(1); |
|
8 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + wp_set_current_user(1); |
|
8 | + } |
|
9 | 9 | |
10 | - public function testAddListing() |
|
11 | - { |
|
12 | - $args = array( |
|
13 | - 'listing_type' => 'gd_place', |
|
14 | - 'post_title' => 'Test Listing Title', |
|
15 | - 'post_desc' => 'Test Desc', |
|
16 | - 'post_tags' => 'test1,test2', |
|
17 | - 'post_address' => 'New York City Hall', |
|
18 | - 'post_zip' => '10007', |
|
19 | - 'post_mapview' => 'ROADMAP', |
|
20 | - 'post_mapzoom' => '10', |
|
21 | - 'geodir_timing' => '10.00 am to 6 pm every day', |
|
22 | - 'geodir_contact' => '1234567890', |
|
23 | - 'geodir_email' => '[email protected]', |
|
24 | - 'geodir_website' => 'http://test.com', |
|
25 | - 'geodir_twitter' => 'http://twitter.com/test', |
|
26 | - 'geodir_facebook' => 'http://facebook.com/test', |
|
27 | - 'geodir_special_offers' => 'Test offer' |
|
28 | - ); |
|
29 | - $post_id = geodir_save_listing($args, true); |
|
10 | + public function testAddListing() |
|
11 | + { |
|
12 | + $args = array( |
|
13 | + 'listing_type' => 'gd_place', |
|
14 | + 'post_title' => 'Test Listing Title', |
|
15 | + 'post_desc' => 'Test Desc', |
|
16 | + 'post_tags' => 'test1,test2', |
|
17 | + 'post_address' => 'New York City Hall', |
|
18 | + 'post_zip' => '10007', |
|
19 | + 'post_mapview' => 'ROADMAP', |
|
20 | + 'post_mapzoom' => '10', |
|
21 | + 'geodir_timing' => '10.00 am to 6 pm every day', |
|
22 | + 'geodir_contact' => '1234567890', |
|
23 | + 'geodir_email' => '[email protected]', |
|
24 | + 'geodir_website' => 'http://test.com', |
|
25 | + 'geodir_twitter' => 'http://twitter.com/test', |
|
26 | + 'geodir_facebook' => 'http://facebook.com/test', |
|
27 | + 'geodir_special_offers' => 'Test offer' |
|
28 | + ); |
|
29 | + $post_id = geodir_save_listing($args, true); |
|
30 | 30 | |
31 | - $this->assertTrue(is_int($post_id)); |
|
32 | - } |
|
31 | + $this->assertTrue(is_int($post_id)); |
|
32 | + } |
|
33 | 33 | |
34 | - public function tearDown() |
|
35 | - { |
|
36 | - parent::tearDown(); |
|
37 | - } |
|
34 | + public function tearDown() |
|
35 | + { |
|
36 | + parent::tearDown(); |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | ?> |
40 | 40 | \ No newline at end of file |
@@ -1,57 +1,57 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckLoginBox extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testLoginBoxEmptyPassword() |
|
10 | - { |
|
11 | - global $errors; |
|
12 | - $_POST['testcookie'] = 1; |
|
13 | - $_POST['log'] = 'admin'; |
|
14 | - add_filter('wp_redirect', '__return_false'); |
|
15 | - geodir_user_signup(); |
|
16 | - remove_filter('wp_redirect', '__return_false'); |
|
17 | - $errors = (array) $errors; |
|
18 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | - } |
|
9 | + public function testLoginBoxEmptyPassword() |
|
10 | + { |
|
11 | + global $errors; |
|
12 | + $_POST['testcookie'] = 1; |
|
13 | + $_POST['log'] = 'admin'; |
|
14 | + add_filter('wp_redirect', '__return_false'); |
|
15 | + geodir_user_signup(); |
|
16 | + remove_filter('wp_redirect', '__return_false'); |
|
17 | + $errors = (array) $errors; |
|
18 | + $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | + $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | + } |
|
21 | 21 | |
22 | - public function testLoginBoxIncorrectPassword() |
|
23 | - { |
|
24 | - global $errors; |
|
25 | - $_POST['testcookie'] = 1; |
|
26 | - $_REQUEST['action'] = 'login'; |
|
27 | - $_POST['log'] = 'testuser'; |
|
28 | - $_POST['pwd'] = 'admin'; |
|
29 | - add_filter('wp_redirect', '__return_false'); |
|
30 | - geodir_user_signup(); |
|
31 | - remove_filter('wp_redirect', '__return_false'); |
|
32 | - $errors = (array) $errors; |
|
33 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
35 | - } |
|
22 | + public function testLoginBoxIncorrectPassword() |
|
23 | + { |
|
24 | + global $errors; |
|
25 | + $_POST['testcookie'] = 1; |
|
26 | + $_REQUEST['action'] = 'login'; |
|
27 | + $_POST['log'] = 'testuser'; |
|
28 | + $_POST['pwd'] = 'admin'; |
|
29 | + add_filter('wp_redirect', '__return_false'); |
|
30 | + geodir_user_signup(); |
|
31 | + remove_filter('wp_redirect', '__return_false'); |
|
32 | + $errors = (array) $errors; |
|
33 | + $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | + $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
35 | + } |
|
36 | 36 | |
37 | - public function testLoginBoxInvalidUsername() |
|
38 | - { |
|
39 | - global $errors; |
|
40 | - $_POST['testcookie'] = 1; |
|
41 | - $_REQUEST['action'] = 'login'; |
|
42 | - $_POST['log'] = 'adm##@in'; |
|
43 | - $_POST['pwd'] = 'admin'; |
|
44 | - add_filter('wp_redirect', '__return_false'); |
|
45 | - geodir_user_signup(); |
|
46 | - remove_filter('wp_redirect', '__return_false'); |
|
47 | - $errors = (array) $errors; |
|
48 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
49 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
50 | - } |
|
37 | + public function testLoginBoxInvalidUsername() |
|
38 | + { |
|
39 | + global $errors; |
|
40 | + $_POST['testcookie'] = 1; |
|
41 | + $_REQUEST['action'] = 'login'; |
|
42 | + $_POST['log'] = 'adm##@in'; |
|
43 | + $_POST['pwd'] = 'admin'; |
|
44 | + add_filter('wp_redirect', '__return_false'); |
|
45 | + geodir_user_signup(); |
|
46 | + remove_filter('wp_redirect', '__return_false'); |
|
47 | + $errors = (array) $errors; |
|
48 | + $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
49 | + $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
50 | + } |
|
51 | 51 | |
52 | - public function tearDown() |
|
53 | - { |
|
54 | - parent::tearDown(); |
|
55 | - } |
|
52 | + public function tearDown() |
|
53 | + { |
|
54 | + parent::tearDown(); |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | \ No newline at end of file |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | geodir_user_signup(); |
16 | 16 | remove_filter('wp_redirect', '__return_false'); |
17 | 17 | $errors = (array) $errors; |
18 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
18 | + $this->assertArrayHasKey('empty_password', $errors["errors"]); |
|
19 | + $this->assertContains('The password field is empty', $errors["errors"]["empty_password"][0]); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function testLoginBoxIncorrectPassword() |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | geodir_user_signup(); |
31 | 31 | remove_filter('wp_redirect', '__return_false'); |
32 | 32 | $errors = (array) $errors; |
33 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
33 | + $this->assertArrayHasKey('incorrect_password', $errors["errors"]); |
|
34 | + $this->assertContains('The password you entered for the username', $errors["errors"]["incorrect_password"][0]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function testLoginBoxInvalidUsername() |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | geodir_user_signup(); |
46 | 46 | remove_filter('wp_redirect', '__return_false'); |
47 | 47 | $errors = (array) $errors; |
48 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
49 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
48 | + $this->assertArrayHasKey('invalid_username', $errors["errors"]); |
|
49 | + $this->assertContains('Invalid username', $errors["errors"]["invalid_username"][0]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function tearDown() |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | geodir_user_signup(); |
17 | 17 | remove_filter('wp_redirect', '__return_false'); |
18 | 18 | $errors = (array) $errors; |
19 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
20 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
19 | + $this->assertArrayHasKey('empty_password', $errors["errors"]); |
|
20 | + $this->assertContains('The password field is empty', $errors["errors"]["empty_password"][0]); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function testLoginIncorrectPassword() |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | geodir_user_signup(); |
31 | 31 | remove_filter('wp_redirect', '__return_false'); |
32 | 32 | $errors = (array) $errors; |
33 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
34 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
33 | + $this->assertArrayHasKey('incorrect_password', $errors["errors"]); |
|
34 | + $this->assertContains('The password you entered for the username', $errors["errors"]["incorrect_password"][0]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function testLoginInvalidUsername() |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | geodir_user_signup(); |
45 | 45 | remove_filter('wp_redirect', '__return_false'); |
46 | 46 | $errors = (array) $errors; |
47 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
48 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
47 | + $this->assertArrayHasKey('invalid_username', $errors["errors"]); |
|
48 | + $this->assertContains('Invalid username', $errors["errors"]["invalid_username"][0]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // public function testLoginValid() |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | geodir_user_signup(); |
71 | 71 | remove_filter('wp_redirect', '__return_false'); |
72 | 72 | $errors = (array) $errors; |
73 | - $this->assertArrayHasKey( 'empty_username', $errors["errors"] ); |
|
74 | - $this->assertContains( 'Enter a username or e-mail address', $errors["errors"]["empty_username"][0] ); |
|
73 | + $this->assertArrayHasKey('empty_username', $errors["errors"]); |
|
74 | + $this->assertContains('Enter a username or e-mail address', $errors["errors"]["empty_username"][0]); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function testForgotPassInvalidEmail() |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | geodir_user_signup(); |
86 | 86 | remove_filter('wp_redirect', '__return_false'); |
87 | 87 | $errors = (array) $errors; |
88 | - $this->assertArrayHasKey( 'invalid_email', $errors["errors"] ); |
|
89 | - $this->assertContains( 'There is no user registered with that email address', $errors["errors"]["invalid_email"][0] ); |
|
88 | + $this->assertArrayHasKey('invalid_email', $errors["errors"]); |
|
89 | + $this->assertContains('There is no user registered with that email address', $errors["errors"]["invalid_email"][0]); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | public function testForgotPassInvalidUsername() |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | geodir_user_signup(); |
101 | 101 | remove_filter('wp_redirect', '__return_false'); |
102 | 102 | $errors = (array) $errors; |
103 | - $this->assertArrayHasKey( 'invalidcombo', $errors["errors"] ); |
|
104 | - $this->assertContains( 'Invalid username or e-mail', $errors["errors"]["invalidcombo"][0] ); |
|
103 | + $this->assertArrayHasKey('invalidcombo', $errors["errors"]); |
|
104 | + $this->assertContains('Invalid username or e-mail', $errors["errors"]["invalidcombo"][0]); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | public function tearDown() |
@@ -1,51 +1,51 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class LoginUser extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testLoginEmptyPassword() |
|
10 | - { |
|
11 | - global $errors; |
|
12 | - $_REQUEST['action'] = 'login'; |
|
13 | - $_POST['log'] = 'admin'; |
|
14 | - add_filter('wp_redirect', '__return_false'); |
|
15 | - geodir_user_signup(); |
|
16 | - remove_filter('wp_redirect', '__return_false'); |
|
17 | - $errors = (array) $errors; |
|
18 | - $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | - $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | - } |
|
9 | + public function testLoginEmptyPassword() |
|
10 | + { |
|
11 | + global $errors; |
|
12 | + $_REQUEST['action'] = 'login'; |
|
13 | + $_POST['log'] = 'admin'; |
|
14 | + add_filter('wp_redirect', '__return_false'); |
|
15 | + geodir_user_signup(); |
|
16 | + remove_filter('wp_redirect', '__return_false'); |
|
17 | + $errors = (array) $errors; |
|
18 | + $this->assertArrayHasKey( 'empty_password', $errors["errors"] ); |
|
19 | + $this->assertContains( 'The password field is empty', $errors["errors"]["empty_password"][0] ); |
|
20 | + } |
|
21 | 21 | |
22 | - public function testLoginIncorrectPassword() |
|
23 | - { |
|
24 | - global $errors; |
|
25 | - $_REQUEST['action'] = 'login'; |
|
26 | - $_POST['log'] = 'testuser'; |
|
27 | - $_POST['pwd'] = 'admin'; |
|
28 | - add_filter('wp_redirect', '__return_false'); |
|
29 | - geodir_user_signup(); |
|
30 | - remove_filter('wp_redirect', '__return_false'); |
|
31 | - $errors = (array) $errors; |
|
32 | - $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
33 | - $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
34 | - } |
|
22 | + public function testLoginIncorrectPassword() |
|
23 | + { |
|
24 | + global $errors; |
|
25 | + $_REQUEST['action'] = 'login'; |
|
26 | + $_POST['log'] = 'testuser'; |
|
27 | + $_POST['pwd'] = 'admin'; |
|
28 | + add_filter('wp_redirect', '__return_false'); |
|
29 | + geodir_user_signup(); |
|
30 | + remove_filter('wp_redirect', '__return_false'); |
|
31 | + $errors = (array) $errors; |
|
32 | + $this->assertArrayHasKey( 'incorrect_password', $errors["errors"] ); |
|
33 | + $this->assertContains( 'The password you entered for the username', $errors["errors"]["incorrect_password"][0] ); |
|
34 | + } |
|
35 | 35 | |
36 | - public function testLoginInvalidUsername() |
|
37 | - { |
|
38 | - global $errors; |
|
39 | - $_REQUEST['action'] = 'login'; |
|
40 | - $_POST['log'] = 'adm##@in'; |
|
41 | - $_POST['pwd'] = 'admin'; |
|
42 | - add_filter('wp_redirect', '__return_false'); |
|
43 | - geodir_user_signup(); |
|
44 | - remove_filter('wp_redirect', '__return_false'); |
|
45 | - $errors = (array) $errors; |
|
46 | - $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
47 | - $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
48 | - } |
|
36 | + public function testLoginInvalidUsername() |
|
37 | + { |
|
38 | + global $errors; |
|
39 | + $_REQUEST['action'] = 'login'; |
|
40 | + $_POST['log'] = 'adm##@in'; |
|
41 | + $_POST['pwd'] = 'admin'; |
|
42 | + add_filter('wp_redirect', '__return_false'); |
|
43 | + geodir_user_signup(); |
|
44 | + remove_filter('wp_redirect', '__return_false'); |
|
45 | + $errors = (array) $errors; |
|
46 | + $this->assertArrayHasKey( 'invalid_username', $errors["errors"] ); |
|
47 | + $this->assertContains( 'Invalid username', $errors["errors"]["invalid_username"][0] ); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | // public function testLoginValid() |
51 | 51 | // { |
@@ -58,55 +58,55 @@ discard block |
||
58 | 58 | // remove_filter('wp_redirect', '__return_false'); |
59 | 59 | // } |
60 | 60 | |
61 | - public function testForgotPassEmptyData() |
|
62 | - { |
|
63 | - global $errors; |
|
64 | - $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
65 | - $_REQUEST['action'] = 'retrievepassword'; |
|
66 | - $_POST['user_login'] = ''; |
|
67 | - $_POST['user_email'] = ''; |
|
68 | - add_filter('wp_redirect', '__return_false'); |
|
69 | - geodir_user_signup(); |
|
70 | - remove_filter('wp_redirect', '__return_false'); |
|
71 | - $errors = (array) $errors; |
|
72 | - $this->assertArrayHasKey( 'empty_username', $errors["errors"] ); |
|
73 | - $this->assertContains( 'Enter a username or e-mail address', $errors["errors"]["empty_username"][0] ); |
|
74 | - } |
|
61 | + public function testForgotPassEmptyData() |
|
62 | + { |
|
63 | + global $errors; |
|
64 | + $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
65 | + $_REQUEST['action'] = 'retrievepassword'; |
|
66 | + $_POST['user_login'] = ''; |
|
67 | + $_POST['user_email'] = ''; |
|
68 | + add_filter('wp_redirect', '__return_false'); |
|
69 | + geodir_user_signup(); |
|
70 | + remove_filter('wp_redirect', '__return_false'); |
|
71 | + $errors = (array) $errors; |
|
72 | + $this->assertArrayHasKey( 'empty_username', $errors["errors"] ); |
|
73 | + $this->assertContains( 'Enter a username or e-mail address', $errors["errors"]["empty_username"][0] ); |
|
74 | + } |
|
75 | 75 | |
76 | - public function testForgotPassInvalidEmail() |
|
77 | - { |
|
78 | - global $errors; |
|
79 | - $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
80 | - $_REQUEST['action'] = 'retrievepassword'; |
|
81 | - $_POST['user_login'] = '[email protected]'; |
|
82 | - $_POST['user_email'] = ''; |
|
83 | - add_filter('wp_redirect', '__return_false'); |
|
84 | - geodir_user_signup(); |
|
85 | - remove_filter('wp_redirect', '__return_false'); |
|
86 | - $errors = (array) $errors; |
|
87 | - $this->assertArrayHasKey( 'invalid_email', $errors["errors"] ); |
|
88 | - $this->assertContains( 'There is no user registered with that email address', $errors["errors"]["invalid_email"][0] ); |
|
89 | - } |
|
76 | + public function testForgotPassInvalidEmail() |
|
77 | + { |
|
78 | + global $errors; |
|
79 | + $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
80 | + $_REQUEST['action'] = 'retrievepassword'; |
|
81 | + $_POST['user_login'] = '[email protected]'; |
|
82 | + $_POST['user_email'] = ''; |
|
83 | + add_filter('wp_redirect', '__return_false'); |
|
84 | + geodir_user_signup(); |
|
85 | + remove_filter('wp_redirect', '__return_false'); |
|
86 | + $errors = (array) $errors; |
|
87 | + $this->assertArrayHasKey( 'invalid_email', $errors["errors"] ); |
|
88 | + $this->assertContains( 'There is no user registered with that email address', $errors["errors"]["invalid_email"][0] ); |
|
89 | + } |
|
90 | 90 | |
91 | - public function testForgotPassInvalidUsername() |
|
92 | - { |
|
93 | - global $errors; |
|
94 | - $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
95 | - $_REQUEST['action'] = 'retrievepassword'; |
|
96 | - $_POST['user_login'] = 'holla'; |
|
97 | - $_POST['user_email'] = '[email protected]'; |
|
98 | - add_filter('wp_redirect', '__return_false'); |
|
99 | - geodir_user_signup(); |
|
100 | - remove_filter('wp_redirect', '__return_false'); |
|
101 | - $errors = (array) $errors; |
|
102 | - $this->assertArrayHasKey( 'invalidcombo', $errors["errors"] ); |
|
103 | - $this->assertContains( 'Invalid username or e-mail', $errors["errors"]["invalidcombo"][0] ); |
|
104 | - } |
|
91 | + public function testForgotPassInvalidUsername() |
|
92 | + { |
|
93 | + global $errors; |
|
94 | + $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
95 | + $_REQUEST['action'] = 'retrievepassword'; |
|
96 | + $_POST['user_login'] = 'holla'; |
|
97 | + $_POST['user_email'] = '[email protected]'; |
|
98 | + add_filter('wp_redirect', '__return_false'); |
|
99 | + geodir_user_signup(); |
|
100 | + remove_filter('wp_redirect', '__return_false'); |
|
101 | + $errors = (array) $errors; |
|
102 | + $this->assertArrayHasKey( 'invalidcombo', $errors["errors"] ); |
|
103 | + $this->assertContains( 'Invalid username or e-mail', $errors["errors"]["invalidcombo"][0] ); |
|
104 | + } |
|
105 | 105 | |
106 | - public function tearDown() |
|
107 | - { |
|
108 | - parent::tearDown(); |
|
109 | - } |
|
106 | + public function tearDown() |
|
107 | + { |
|
108 | + parent::tearDown(); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | ?> |
113 | 113 | \ No newline at end of file |
@@ -1,63 +1,63 @@ |
||
1 | 1 | <?php |
2 | 2 | class EditListing extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - wp_set_current_user(1); |
|
8 | - } |
|
9 | - |
|
10 | - public function testEditListing() |
|
11 | - { |
|
12 | - $query_args = array( |
|
13 | - 'post_status' => 'publish', |
|
14 | - 'post_type' => 'gd_place', |
|
15 | - 'posts_per_page' => 1, |
|
16 | - ); |
|
17 | - |
|
18 | - $all_posts = new WP_Query( $query_args ); |
|
19 | - $post_id = null; |
|
20 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
21 | - $post_id = get_the_ID(); |
|
22 | - endwhile; |
|
23 | - |
|
24 | - $this->assertTrue(is_int($post_id)); |
|
25 | - |
|
26 | - $args = array( |
|
27 | - 'pid' => $post_id, |
|
28 | - 'listing_type' => 'gd_place', |
|
29 | - 'post_title' => 'Test Listing Title Modified', |
|
30 | - 'post_desc' => 'Test Desc', |
|
31 | - 'post_tags' => 'test1,test2', |
|
32 | - 'post_address' => 'New York City Hall', |
|
33 | - 'post_zip' => '10007', |
|
34 | - 'post_latitude' => '40.7127837', |
|
35 | - 'post_longitude' => '-74.00594130000002', |
|
36 | - 'post_mapview' => 'ROADMAP', |
|
37 | - 'post_mapzoom' => '10', |
|
38 | - 'geodir_timing' => '10.00 am to 6 pm every day', |
|
39 | - 'geodir_contact' => '1234567890', |
|
40 | - 'geodir_email' => '[email protected]', |
|
41 | - 'geodir_website' => 'http://test.com', |
|
42 | - 'geodir_twitter' => 'http://twitter.com/test', |
|
43 | - 'geodir_facebook' => 'http://facebook.com/test', |
|
44 | - 'geodir_special_offers' => 'Test offer' |
|
45 | - ); |
|
46 | - $saved_post_id = geodir_save_listing($args, true); |
|
47 | - |
|
48 | - $this->assertTrue(is_int($saved_post_id)); |
|
49 | - |
|
50 | - $title = get_the_title($post_id); |
|
51 | - |
|
52 | - $this->assertEquals('Test Listing Title Modified', $title); |
|
53 | - |
|
54 | - |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - public function tearDown() |
|
59 | - { |
|
60 | - parent::tearDown(); |
|
61 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + wp_set_current_user(1); |
|
8 | + } |
|
9 | + |
|
10 | + public function testEditListing() |
|
11 | + { |
|
12 | + $query_args = array( |
|
13 | + 'post_status' => 'publish', |
|
14 | + 'post_type' => 'gd_place', |
|
15 | + 'posts_per_page' => 1, |
|
16 | + ); |
|
17 | + |
|
18 | + $all_posts = new WP_Query( $query_args ); |
|
19 | + $post_id = null; |
|
20 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
21 | + $post_id = get_the_ID(); |
|
22 | + endwhile; |
|
23 | + |
|
24 | + $this->assertTrue(is_int($post_id)); |
|
25 | + |
|
26 | + $args = array( |
|
27 | + 'pid' => $post_id, |
|
28 | + 'listing_type' => 'gd_place', |
|
29 | + 'post_title' => 'Test Listing Title Modified', |
|
30 | + 'post_desc' => 'Test Desc', |
|
31 | + 'post_tags' => 'test1,test2', |
|
32 | + 'post_address' => 'New York City Hall', |
|
33 | + 'post_zip' => '10007', |
|
34 | + 'post_latitude' => '40.7127837', |
|
35 | + 'post_longitude' => '-74.00594130000002', |
|
36 | + 'post_mapview' => 'ROADMAP', |
|
37 | + 'post_mapzoom' => '10', |
|
38 | + 'geodir_timing' => '10.00 am to 6 pm every day', |
|
39 | + 'geodir_contact' => '1234567890', |
|
40 | + 'geodir_email' => '[email protected]', |
|
41 | + 'geodir_website' => 'http://test.com', |
|
42 | + 'geodir_twitter' => 'http://twitter.com/test', |
|
43 | + 'geodir_facebook' => 'http://facebook.com/test', |
|
44 | + 'geodir_special_offers' => 'Test offer' |
|
45 | + ); |
|
46 | + $saved_post_id = geodir_save_listing($args, true); |
|
47 | + |
|
48 | + $this->assertTrue(is_int($saved_post_id)); |
|
49 | + |
|
50 | + $title = get_the_title($post_id); |
|
51 | + |
|
52 | + $this->assertEquals('Test Listing Title Modified', $title); |
|
53 | + |
|
54 | + |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + public function tearDown() |
|
59 | + { |
|
60 | + parent::tearDown(); |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | ?> |
64 | 64 | \ No newline at end of file |
@@ -15,9 +15,9 @@ |
||
15 | 15 | 'posts_per_page' => 1, |
16 | 16 | ); |
17 | 17 | |
18 | - $all_posts = new WP_Query( $query_args ); |
|
18 | + $all_posts = new WP_Query($query_args); |
|
19 | 19 | $post_id = null; |
20 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
20 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
21 | 21 | $post_id = get_the_ID(); |
22 | 22 | endwhile; |
23 | 23 |
@@ -1,92 +1,92 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckNotifications 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 testSendFriendEmail() |
|
10 | - { |
|
11 | - add_filter('wp_mail', 'print_mail'); |
|
12 | - ob_start(); |
|
13 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_friend'); |
|
14 | - $output = ob_get_clean(); |
|
15 | - remove_filter('wp_mail', 'print_mail'); |
|
16 | - $this->assertContains( 'thought you might be interested in', $output ); |
|
17 | - $this->assertContains( 'Your friend has sent you a message from', $output ); |
|
18 | - $this->assertContains( '[email protected]', $output ); |
|
19 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
20 | - } |
|
9 | + public function testSendFriendEmail() |
|
10 | + { |
|
11 | + add_filter('wp_mail', 'print_mail'); |
|
12 | + ob_start(); |
|
13 | + geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_friend'); |
|
14 | + $output = ob_get_clean(); |
|
15 | + remove_filter('wp_mail', 'print_mail'); |
|
16 | + $this->assertContains( 'thought you might be interested in', $output ); |
|
17 | + $this->assertContains( 'Your friend has sent you a message from', $output ); |
|
18 | + $this->assertContains( '[email protected]', $output ); |
|
19 | + $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
20 | + } |
|
21 | 21 | |
22 | - public function testSendEnquiryEmail() |
|
23 | - { |
|
24 | - add_filter('wp_mail', 'print_mail'); |
|
25 | - ob_start(); |
|
26 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_enquiry'); |
|
27 | - $output = ob_get_clean(); |
|
28 | - remove_filter('wp_mail', 'print_mail'); |
|
29 | - $this->assertContains( 'Website Enquiry', $output ); |
|
30 | - $this->assertContains( 'An enquiry has been sent from', $output ); |
|
31 | - $this->assertContains( '[email protected]', $output ); |
|
32 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
33 | - } |
|
22 | + public function testSendEnquiryEmail() |
|
23 | + { |
|
24 | + add_filter('wp_mail', 'print_mail'); |
|
25 | + ob_start(); |
|
26 | + geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_enquiry'); |
|
27 | + $output = ob_get_clean(); |
|
28 | + remove_filter('wp_mail', 'print_mail'); |
|
29 | + $this->assertContains( 'Website Enquiry', $output ); |
|
30 | + $this->assertContains( 'An enquiry has been sent from', $output ); |
|
31 | + $this->assertContains( '[email protected]', $output ); |
|
32 | + $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
33 | + } |
|
34 | 34 | |
35 | - public function testForgotPassEmail() |
|
36 | - { |
|
37 | - add_filter('wp_mail', 'print_mail'); |
|
38 | - ob_start(); |
|
39 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'forgot_password'); |
|
40 | - $output = ob_get_clean(); |
|
41 | - remove_filter('wp_mail', 'print_mail'); |
|
42 | - $this->assertContains( 'Your new password', $output ); |
|
43 | - $this->assertContains( 'You requested a new password for', $output ); |
|
44 | - $this->assertContains( '[email protected]', $output ); |
|
45 | - } |
|
35 | + public function testForgotPassEmail() |
|
36 | + { |
|
37 | + add_filter('wp_mail', 'print_mail'); |
|
38 | + ob_start(); |
|
39 | + geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'forgot_password'); |
|
40 | + $output = ob_get_clean(); |
|
41 | + remove_filter('wp_mail', 'print_mail'); |
|
42 | + $this->assertContains( 'Your new password', $output ); |
|
43 | + $this->assertContains( 'You requested a new password for', $output ); |
|
44 | + $this->assertContains( '[email protected]', $output ); |
|
45 | + } |
|
46 | 46 | |
47 | - public function testRegistrationEmail() |
|
48 | - { |
|
49 | - add_filter('wp_mail', 'print_mail'); |
|
50 | - ob_start(); |
|
51 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'registration'); |
|
52 | - $output = ob_get_clean(); |
|
53 | - remove_filter('wp_mail', 'print_mail'); |
|
54 | - $this->assertContains( 'Your Log In Details', $output ); |
|
55 | - $this->assertContains( 'You can log in with the following information', $output ); |
|
56 | - $this->assertContains( '[email protected]', $output ); |
|
57 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
58 | - } |
|
47 | + public function testRegistrationEmail() |
|
48 | + { |
|
49 | + add_filter('wp_mail', 'print_mail'); |
|
50 | + ob_start(); |
|
51 | + geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'registration'); |
|
52 | + $output = ob_get_clean(); |
|
53 | + remove_filter('wp_mail', 'print_mail'); |
|
54 | + $this->assertContains( 'Your Log In Details', $output ); |
|
55 | + $this->assertContains( 'You can log in with the following information', $output ); |
|
56 | + $this->assertContains( '[email protected]', $output ); |
|
57 | + $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
58 | + } |
|
59 | 59 | |
60 | - public function testPostSubmitEmail() |
|
61 | - { |
|
62 | - add_filter('wp_mail', 'print_mail'); |
|
63 | - ob_start(); |
|
64 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'post_submit'); |
|
65 | - $output = ob_get_clean(); |
|
66 | - remove_filter('wp_mail', 'print_mail'); |
|
67 | - $this->assertContains( 'Post Submitted Successfully', $output ); |
|
68 | - $this->assertContains( 'You submitted the below listing information', $output ); |
|
69 | - $this->assertContains( '[email protected]', $output ); |
|
70 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
71 | - $this->assertContains( 'A new listing has been published', $output ); |
|
72 | - } |
|
60 | + public function testPostSubmitEmail() |
|
61 | + { |
|
62 | + add_filter('wp_mail', 'print_mail'); |
|
63 | + ob_start(); |
|
64 | + geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'post_submit'); |
|
65 | + $output = ob_get_clean(); |
|
66 | + remove_filter('wp_mail', 'print_mail'); |
|
67 | + $this->assertContains( 'Post Submitted Successfully', $output ); |
|
68 | + $this->assertContains( 'You submitted the below listing information', $output ); |
|
69 | + $this->assertContains( '[email protected]', $output ); |
|
70 | + $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
71 | + $this->assertContains( 'A new listing has been published', $output ); |
|
72 | + } |
|
73 | 73 | |
74 | - public function testListingPublishedEmail() |
|
75 | - { |
|
76 | - add_filter('wp_mail', 'print_mail'); |
|
77 | - ob_start(); |
|
78 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'listing_published'); |
|
79 | - $output = ob_get_clean(); |
|
80 | - remove_filter('wp_mail', 'print_mail'); |
|
81 | - $this->assertContains( 'Listing Published Successfully', $output ); |
|
82 | - $this->assertContains( 'Your listing has been published', $output ); |
|
83 | - $this->assertContains( '[email protected]', $output ); |
|
84 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
85 | - } |
|
74 | + public function testListingPublishedEmail() |
|
75 | + { |
|
76 | + add_filter('wp_mail', 'print_mail'); |
|
77 | + ob_start(); |
|
78 | + geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'listing_published'); |
|
79 | + $output = ob_get_clean(); |
|
80 | + remove_filter('wp_mail', 'print_mail'); |
|
81 | + $this->assertContains( 'Listing Published Successfully', $output ); |
|
82 | + $this->assertContains( 'Your listing has been published', $output ); |
|
83 | + $this->assertContains( '[email protected]', $output ); |
|
84 | + $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
85 | + } |
|
86 | 86 | |
87 | - public function tearDown() |
|
88 | - { |
|
89 | - parent::tearDown(); |
|
90 | - } |
|
87 | + public function tearDown() |
|
88 | + { |
|
89 | + parent::tearDown(); |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | \ No newline at end of file |
@@ -10,78 +10,78 @@ |
||
10 | 10 | { |
11 | 11 | add_filter('wp_mail', 'print_mail'); |
12 | 12 | ob_start(); |
13 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_friend'); |
|
13 | + geodir_sendEmail('', '', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_friend'); |
|
14 | 14 | $output = ob_get_clean(); |
15 | 15 | remove_filter('wp_mail', 'print_mail'); |
16 | - $this->assertContains( 'thought you might be interested in', $output ); |
|
17 | - $this->assertContains( 'Your friend has sent you a message from', $output ); |
|
18 | - $this->assertContains( '[email protected]', $output ); |
|
19 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
16 | + $this->assertContains('thought you might be interested in', $output); |
|
17 | + $this->assertContains('Your friend has sent you a message from', $output); |
|
18 | + $this->assertContains('[email protected]', $output); |
|
19 | + $this->assertContains('ADMIN BCC COPY', $output); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function testSendEnquiryEmail() |
23 | 23 | { |
24 | 24 | add_filter('wp_mail', 'print_mail'); |
25 | 25 | ob_start(); |
26 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_enquiry'); |
|
26 | + geodir_sendEmail('', '', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'send_enquiry'); |
|
27 | 27 | $output = ob_get_clean(); |
28 | 28 | remove_filter('wp_mail', 'print_mail'); |
29 | - $this->assertContains( 'Website Enquiry', $output ); |
|
30 | - $this->assertContains( 'An enquiry has been sent from', $output ); |
|
31 | - $this->assertContains( '[email protected]', $output ); |
|
32 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
29 | + $this->assertContains('Website Enquiry', $output); |
|
30 | + $this->assertContains('An enquiry has been sent from', $output); |
|
31 | + $this->assertContains('[email protected]', $output); |
|
32 | + $this->assertContains('ADMIN BCC COPY', $output); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function testForgotPassEmail() |
36 | 36 | { |
37 | 37 | add_filter('wp_mail', 'print_mail'); |
38 | 38 | ob_start(); |
39 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'forgot_password'); |
|
39 | + geodir_sendEmail('', '', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'forgot_password'); |
|
40 | 40 | $output = ob_get_clean(); |
41 | 41 | remove_filter('wp_mail', 'print_mail'); |
42 | - $this->assertContains( 'Your new password', $output ); |
|
43 | - $this->assertContains( 'You requested a new password for', $output ); |
|
44 | - $this->assertContains( '[email protected]', $output ); |
|
42 | + $this->assertContains('Your new password', $output); |
|
43 | + $this->assertContains('You requested a new password for', $output); |
|
44 | + $this->assertContains('[email protected]', $output); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function testRegistrationEmail() |
48 | 48 | { |
49 | 49 | add_filter('wp_mail', 'print_mail'); |
50 | 50 | ob_start(); |
51 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'registration'); |
|
51 | + geodir_sendEmail('', '', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'registration'); |
|
52 | 52 | $output = ob_get_clean(); |
53 | 53 | remove_filter('wp_mail', 'print_mail'); |
54 | - $this->assertContains( 'Your Log In Details', $output ); |
|
55 | - $this->assertContains( 'You can log in with the following information', $output ); |
|
56 | - $this->assertContains( '[email protected]', $output ); |
|
57 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
54 | + $this->assertContains('Your Log In Details', $output); |
|
55 | + $this->assertContains('You can log in with the following information', $output); |
|
56 | + $this->assertContains('[email protected]', $output); |
|
57 | + $this->assertContains('ADMIN BCC COPY', $output); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public function testPostSubmitEmail() |
61 | 61 | { |
62 | 62 | add_filter('wp_mail', 'print_mail'); |
63 | 63 | ob_start(); |
64 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'post_submit'); |
|
64 | + geodir_sendEmail('', '', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'post_submit'); |
|
65 | 65 | $output = ob_get_clean(); |
66 | 66 | remove_filter('wp_mail', 'print_mail'); |
67 | - $this->assertContains( 'Post Submitted Successfully', $output ); |
|
68 | - $this->assertContains( 'You submitted the below listing information', $output ); |
|
69 | - $this->assertContains( '[email protected]', $output ); |
|
70 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
71 | - $this->assertContains( 'A new listing has been published', $output ); |
|
67 | + $this->assertContains('Post Submitted Successfully', $output); |
|
68 | + $this->assertContains('You submitted the below listing information', $output); |
|
69 | + $this->assertContains('[email protected]', $output); |
|
70 | + $this->assertContains('ADMIN BCC COPY', $output); |
|
71 | + $this->assertContains('A new listing has been published', $output); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function testListingPublishedEmail() |
75 | 75 | { |
76 | 76 | add_filter('wp_mail', 'print_mail'); |
77 | 77 | ob_start(); |
78 | - geodir_sendEmail('','', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'listing_published'); |
|
78 | + geodir_sendEmail('', '', '[email protected]', 'Test User', 'Test subject', 'Test message', '', 'listing_published'); |
|
79 | 79 | $output = ob_get_clean(); |
80 | 80 | remove_filter('wp_mail', 'print_mail'); |
81 | - $this->assertContains( 'Listing Published Successfully', $output ); |
|
82 | - $this->assertContains( 'Your listing has been published', $output ); |
|
83 | - $this->assertContains( '[email protected]', $output ); |
|
84 | - $this->assertContains( 'ADMIN BCC COPY', $output ); |
|
81 | + $this->assertContains('Listing Published Successfully', $output); |
|
82 | + $this->assertContains('Your listing has been published', $output); |
|
83 | + $this->assertContains('[email protected]', $output); |
|
84 | + $this->assertContains('ADMIN BCC COPY', $output); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public function tearDown() |
@@ -29,7 +29,7 @@ |
||
29 | 29 | 'post_type' => 'gd_place' |
30 | 30 | ); |
31 | 31 | |
32 | - $all_posts = new WP_Query( $query_args ); |
|
32 | + $all_posts = new WP_Query($query_args); |
|
33 | 33 | |
34 | 34 | $total_posts = $all_posts->found_posts; |
35 | 35 |
@@ -1,50 +1,50 @@ |
||
1 | 1 | <?php |
2 | 2 | class TestDummyData extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - wp_set_current_user(1); |
|
8 | - geodir_delete_dummy_posts(); |
|
9 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + wp_set_current_user(1); |
|
8 | + geodir_delete_dummy_posts(); |
|
9 | + } |
|
10 | 10 | |
11 | - public function testCreatePlaces() |
|
12 | - { |
|
13 | - global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; |
|
11 | + public function testCreatePlaces() |
|
12 | + { |
|
13 | + global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; |
|
14 | 14 | |
15 | - global $geodir_post_custom_fields_cache; |
|
16 | - $geodir_post_custom_fields_cache = array(); |
|
15 | + global $geodir_post_custom_fields_cache; |
|
16 | + $geodir_post_custom_fields_cache = array(); |
|
17 | 17 | |
18 | - $city_bound_lat1 = 40.4960439; |
|
19 | - $city_bound_lng1 = -74.2557349; |
|
20 | - $city_bound_lat2 = 40.91525559999999; |
|
21 | - $city_bound_lng2 = -73.7002721; |
|
18 | + $city_bound_lat1 = 40.4960439; |
|
19 | + $city_bound_lng1 = -74.2557349; |
|
20 | + $city_bound_lat2 = 40.91525559999999; |
|
21 | + $city_bound_lng2 = -73.7002721; |
|
22 | 22 | |
23 | 23 | |
24 | - $dummy_post_index = 30; |
|
25 | - test_create_dummy_posts(30); |
|
24 | + $dummy_post_index = 30; |
|
25 | + test_create_dummy_posts(30); |
|
26 | 26 | |
27 | - $query_args = array( |
|
28 | - 'post_status' => 'publish', |
|
29 | - 'post_type' => 'gd_place' |
|
30 | - ); |
|
27 | + $query_args = array( |
|
28 | + 'post_status' => 'publish', |
|
29 | + 'post_type' => 'gd_place' |
|
30 | + ); |
|
31 | 31 | |
32 | - $all_posts = new WP_Query( $query_args ); |
|
32 | + $all_posts = new WP_Query( $query_args ); |
|
33 | 33 | |
34 | - $total_posts = $all_posts->found_posts; |
|
34 | + $total_posts = $all_posts->found_posts; |
|
35 | 35 | |
36 | - $this->assertTrue((int) $total_posts > 0); |
|
36 | + $this->assertTrue((int) $total_posts > 0); |
|
37 | 37 | |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function testDeletePlaces() |
|
41 | - { |
|
42 | - geodir_delete_dummy_posts(); |
|
43 | - } |
|
40 | + public function testDeletePlaces() |
|
41 | + { |
|
42 | + geodir_delete_dummy_posts(); |
|
43 | + } |
|
44 | 44 | |
45 | - public function tearDown() |
|
46 | - { |
|
47 | - parent::tearDown(); |
|
48 | - } |
|
45 | + public function tearDown() |
|
46 | + { |
|
47 | + parent::tearDown(); |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | ?> |
51 | 51 | \ No newline at end of file |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | class ImportExport 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 testImportExport() |
|
10 | - { |
|
9 | + public function testImportExport() |
|
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 |