Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Tests_Functions often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Tests_Functions, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
6 | class Tests_Functions extends WP_UnitTestCase { |
||
7 | function test_wp_parse_args_object() { |
||
16 | |||
17 | function test_wp_parse_args_array() { |
||
24 | |||
25 | function test_wp_parse_args_defaults() { |
||
35 | |||
36 | function test_wp_parse_args_other() { |
||
44 | |||
45 | /** |
||
46 | * @ticket 30753 |
||
47 | */ |
||
48 | function test_wp_parse_args_boolean_strings() { |
||
53 | |||
54 | /** |
||
55 | * @ticket 35972 |
||
56 | */ |
||
57 | function test_bool_from_yn() { |
||
62 | |||
63 | function test_path_is_absolute() { |
||
79 | |||
80 | function test_path_is_not_absolute() { |
||
96 | |||
97 | /** |
||
98 | * @ticket 33265 |
||
99 | * @ticket 35996 |
||
100 | * |
||
101 | * @dataProvider data_wp_normalize_path |
||
102 | */ |
||
103 | function test_wp_normalize_path( $path, $expected ) { |
||
106 | View Code Duplication | function data_wp_normalize_path() { |
|
107 | return array( |
||
108 | // Windows paths |
||
109 | array( 'C:\\www\\path\\', 'C:/www/path/' ), |
||
110 | array( 'C:\\www\\\\path\\', 'C:/www/path/' ), |
||
111 | array( 'c:/www/path', 'C:/www/path' ), |
||
112 | array( 'c:\\www\\path\\', 'C:/www/path/' ), // uppercase drive letter |
||
113 | array( 'c:\\\\www\\path\\', 'C:/www/path/' ), |
||
114 | array( '\\\\Domain\\DFSRoots\\share\\path\\', '//Domain/DFSRoots/share/path/' ), |
||
115 | array( '\\\\Server\\share\\path', '//Server/share/path' ), |
||
116 | array( '\\\\Server\\share', '//Server/share' ), |
||
117 | |||
118 | // Linux paths |
||
119 | array( '/www/path/', '/www/path/' ), |
||
120 | array( '/www/path/////', '/www/path/' ), |
||
121 | array( '/www/path', '/www/path' ), |
||
122 | ); |
||
123 | } |
||
124 | |||
125 | function test_wp_unique_filename() { |
||
157 | |||
158 | function test_is_serialized() { |
||
183 | |||
184 | /** |
||
185 | * @ticket 17375 |
||
186 | */ |
||
187 | function test_no_new_serializable_types() { |
||
190 | |||
191 | /** |
||
192 | * @dataProvider data_is_serialized_string |
||
193 | */ |
||
194 | public function test_is_serialized_string( $value, $result ) { |
||
197 | |||
198 | View Code Duplication | public function data_is_serialized_string() { |
|
199 | return array( |
||
200 | // Not a string. |
||
201 | array( 0, false ), |
||
202 | |||
203 | // Too short when trimmed. |
||
204 | array( 's:3 ', false ), |
||
205 | |||
206 | // Too short. |
||
207 | array( 's:3', false ), |
||
208 | |||
209 | // No colon in second position. |
||
210 | array( 's!3:"foo";', false ), |
||
211 | |||
212 | // No trailing semicolon. |
||
213 | array( 's:3:"foo"', false ), |
||
214 | |||
215 | // Wrong type. |
||
216 | array( 'a:3:"foo";', false ), |
||
217 | |||
218 | // No closing quote. |
||
219 | array( 'a:3:"foo;', false ), |
||
220 | |||
221 | // Wrong number of characters is close enough for is_serialized_string(). |
||
222 | array( 's:12:"foo";', true ), |
||
223 | |||
224 | // Okay. |
||
225 | array( 's:3:"foo";', true ), |
||
226 | |||
227 | ); |
||
228 | } |
||
229 | |||
230 | /** |
||
231 | * @group add_query_arg |
||
232 | */ |
||
233 | function test_add_query_arg() { |
||
234 | $old_req_uri = $_SERVER['REQUEST_URI']; |
||
235 | |||
236 | $urls = array( |
||
237 | '/', |
||
238 | '/2012/07/30/', |
||
239 | 'edit.php', |
||
240 | admin_url( 'edit.php' ), |
||
241 | admin_url( 'edit.php', 'https' ), |
||
242 | ); |
||
243 | |||
244 | $frag_urls = array( |
||
245 | '/#frag', |
||
246 | '/2012/07/30/#frag', |
||
247 | 'edit.php#frag', |
||
248 | admin_url( 'edit.php#frag' ), |
||
249 | admin_url( 'edit.php#frag', 'https' ), |
||
250 | ); |
||
251 | |||
252 | View Code Duplication | foreach ( $urls as $url ) { |
|
253 | $_SERVER['REQUEST_URI'] = 'nothing'; |
||
254 | |||
255 | $this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1', $url ) ); |
||
256 | $this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ), $url ) ); |
||
257 | $this->assertEquals( "$url?foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $url ) ); |
||
258 | $this->assertEquals( "$url?foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $url ) ); |
||
259 | |||
260 | $_SERVER['REQUEST_URI'] = $url; |
||
261 | |||
262 | $this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1' ) ); |
||
263 | $this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ) ) ); |
||
264 | $this->assertEquals( "$url?foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) ); |
||
265 | $this->assertEquals( "$url?foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) ); |
||
266 | } |
||
267 | |||
268 | foreach ( $frag_urls as $frag_url ) { |
||
269 | $_SERVER['REQUEST_URI'] = 'nothing'; |
||
270 | $url = str_replace( '#frag', '', $frag_url ); |
||
271 | |||
272 | $this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1', $frag_url ) ); |
||
273 | $this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ), $frag_url ) ); |
||
274 | $this->assertEquals( "$url?foo=2#frag", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $frag_url ) ); |
||
275 | $this->assertEquals( "$url?foo=1&bar=2#frag", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $frag_url ) ); |
||
276 | |||
277 | $_SERVER['REQUEST_URI'] = $frag_url; |
||
278 | |||
279 | $this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1' ) ); |
||
280 | $this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ) ) ); |
||
281 | $this->assertEquals( "$url?foo=2#frag", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) ); |
||
282 | $this->assertEquals( "$url?foo=1&bar=2#frag", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) ); |
||
283 | } |
||
284 | |||
285 | $qs_urls = array( |
||
286 | 'baz=1', // #WP4903 |
||
287 | '/?baz', |
||
288 | '/2012/07/30/?baz', |
||
289 | 'edit.php?baz', |
||
290 | admin_url( 'edit.php?baz' ), |
||
291 | admin_url( 'edit.php?baz', 'https' ), |
||
292 | admin_url( 'edit.php?baz&za=1' ), |
||
293 | admin_url( 'edit.php?baz=1&za=1' ), |
||
294 | admin_url( 'edit.php?baz=0&za=0' ), |
||
295 | ); |
||
296 | |||
297 | View Code Duplication | foreach ( $qs_urls as $url ) { |
|
298 | $_SERVER['REQUEST_URI'] = 'nothing'; |
||
299 | |||
300 | $this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1', $url ) ); |
||
301 | $this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ), $url ) ); |
||
302 | $this->assertEquals( "$url&foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $url ) ); |
||
303 | $this->assertEquals( "$url&foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $url ) ); |
||
304 | |||
305 | $_SERVER['REQUEST_URI'] = $url; |
||
306 | |||
307 | $this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1' ) ); |
||
308 | $this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ) ) ); |
||
309 | $this->assertEquals( "$url&foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) ); |
||
310 | $this->assertEquals( "$url&foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) ); |
||
311 | } |
||
312 | |||
313 | $_SERVER['REQUEST_URI'] = $old_req_uri; |
||
314 | } |
||
315 | |||
316 | /** |
||
317 | * @ticket 31306 |
||
318 | */ |
||
319 | function test_add_query_arg_numeric_keys() { |
||
329 | |||
330 | /** |
||
331 | * @ticket 21594 |
||
332 | */ |
||
333 | View Code Duplication | function test_get_allowed_mime_types() { |
|
334 | $mimes = get_allowed_mime_types(); |
||
335 | |||
336 | $this->assertInternalType( 'array', $mimes ); |
||
337 | $this->assertNotEmpty( $mimes ); |
||
338 | |||
339 | add_filter( 'upload_mimes', '__return_empty_array' ); |
||
340 | $mimes = get_allowed_mime_types(); |
||
341 | $this->assertInternalType( 'array', $mimes ); |
||
342 | $this->assertEmpty( $mimes ); |
||
343 | |||
344 | remove_filter( 'upload_mimes', '__return_empty_array' ); |
||
345 | $mimes = get_allowed_mime_types(); |
||
346 | $this->assertInternalType( 'array', $mimes ); |
||
347 | $this->assertNotEmpty( $mimes ); |
||
348 | } |
||
349 | |||
350 | /** |
||
351 | * @ticket 21594 |
||
352 | */ |
||
353 | function test_wp_get_mime_types() { |
||
381 | |||
382 | /** |
||
383 | * @ticket 23688 |
||
384 | */ |
||
385 | View Code Duplication | function test_canonical_charset() { |
|
386 | $orig_blog_charset = get_option( 'blog_charset' ); |
||
387 | |||
388 | update_option( 'blog_charset', 'utf8' ); |
||
389 | $this->assertEquals( 'UTF-8', get_option( 'blog_charset') ); |
||
390 | |||
391 | update_option( 'blog_charset', 'utf-8' ); |
||
392 | $this->assertEquals( 'UTF-8', get_option( 'blog_charset') ); |
||
393 | |||
394 | update_option( 'blog_charset', 'UTF8' ); |
||
395 | $this->assertEquals( 'UTF-8', get_option( 'blog_charset') ); |
||
396 | |||
397 | update_option( 'blog_charset', 'UTF-8' ); |
||
398 | $this->assertEquals( 'UTF-8', get_option( 'blog_charset') ); |
||
399 | |||
400 | update_option( 'blog_charset', 'ISO-8859-1' ); |
||
401 | $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') ); |
||
402 | |||
403 | update_option( 'blog_charset', 'ISO8859-1' ); |
||
404 | $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') ); |
||
405 | |||
406 | update_option( 'blog_charset', 'iso8859-1' ); |
||
407 | $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') ); |
||
408 | |||
409 | update_option( 'blog_charset', 'iso-8859-1' ); |
||
410 | $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') ); |
||
411 | |||
412 | // Arbitrary strings are passed through. |
||
413 | update_option( 'blog_charset', 'foobarbaz' ); |
||
414 | $this->assertEquals( 'foobarbaz', get_option( 'blog_charset') ); |
||
415 | |||
416 | update_option( 'blog_charset', $orig_blog_charset ); |
||
417 | } |
||
418 | |||
419 | /** |
||
420 | * @dataProvider data_wp_parse_id_list |
||
421 | */ |
||
422 | function test_wp_parse_id_list( $expected, $actual ) { |
||
425 | |||
426 | function data_wp_parse_id_list() { |
||
437 | |||
438 | /** |
||
439 | * @dataProvider data_wp_parse_slug_list |
||
440 | */ |
||
441 | function test_wp_parse_slug_list( $expected, $actual ) { |
||
444 | |||
445 | function data_wp_parse_slug_list() { |
||
453 | |||
454 | /** |
||
455 | * @dataProvider data_device_can_upload |
||
456 | */ |
||
457 | function test_device_can_upload( $user_agent, $expected ) { |
||
463 | |||
464 | View Code Duplication | function data_device_can_upload() { |
|
465 | return array( |
||
466 | // iPhone iOS 5.0.1, Safari 5.1 |
||
467 | array( |
||
468 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A406)', |
||
469 | false, |
||
470 | ), |
||
471 | // iPad iOS 3.2, Safari 4.0.4 |
||
472 | array( |
||
473 | 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10', |
||
474 | false, |
||
475 | ), |
||
476 | // iPod iOS 4.3.3, Safari 5.0.2 |
||
477 | array( |
||
478 | 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5', |
||
479 | false, |
||
480 | ), |
||
481 | // iPhone iOS 6.0.0, Safari 6.0 |
||
482 | array( |
||
483 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25', |
||
484 | true, |
||
485 | ), |
||
486 | // iPad iOS 6.0.0, Safari 6.0 |
||
487 | array( |
||
488 | 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25', |
||
489 | true, |
||
490 | ), |
||
491 | // Android 2.2, Android Webkit Browser |
||
492 | array( |
||
493 | 'Mozilla/5.0 (Android 2.2; Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4', |
||
494 | true, |
||
495 | ), |
||
496 | // BlackBerry 9900, BlackBerry browser |
||
497 | array( |
||
498 | 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+', |
||
499 | true, |
||
500 | ), |
||
501 | // Windows Phone 8.0, Internet Explorer 10.0; |
||
502 | array( |
||
503 | 'Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)', |
||
504 | true, |
||
505 | ), |
||
506 | // Ubuntu desktop, Firefox 41.0 |
||
507 | array( |
||
508 | 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0', |
||
509 | true, |
||
510 | ), |
||
511 | ); |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * @ticket 9064 |
||
516 | */ |
||
517 | function test_wp_extract_urls() { |
||
680 | |||
681 | /** |
||
682 | * @ticket 28786 |
||
683 | */ |
||
684 | function test_wp_json_encode() { |
||
687 | |||
688 | /** |
||
689 | * @ticket 28786 |
||
690 | */ |
||
691 | function test_wp_json_encode_utf8() { |
||
694 | |||
695 | /** |
||
696 | * @ticket 28786 |
||
697 | */ |
||
698 | View Code Duplication | function test_wp_json_encode_non_utf8() { |
|
699 | if ( ! function_exists( 'mb_detect_order' ) ) { |
||
700 | $this->markTestSkipped( 'mbstring extension not available.' ); |
||
701 | } |
||
702 | |||
703 | $old_charsets = $charsets = mb_detect_order(); |
||
704 | if ( ! in_array( 'EUC-JP', $charsets ) ) { |
||
705 | $charsets[] = 'EUC-JP'; |
||
706 | mb_detect_order( $charsets ); |
||
707 | } |
||
708 | |||
709 | $eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' ); |
||
710 | $utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' ); |
||
711 | |||
712 | $this->assertEquals( 'aあb', $utf8 ); |
||
713 | |||
714 | $this->assertEquals( '"a\u3042b"', wp_json_encode( $eucjp ) ); |
||
715 | |||
716 | mb_detect_order( $old_charsets ); |
||
717 | } |
||
718 | |||
719 | /** |
||
720 | * @ticket 28786 |
||
721 | */ |
||
722 | View Code Duplication | function test_wp_json_encode_non_utf8_in_array() { |
|
723 | if ( ! function_exists( 'mb_detect_order' ) ) { |
||
724 | $this->markTestSkipped( 'mbstring extension not available.' ); |
||
725 | } |
||
726 | |||
727 | $old_charsets = $charsets = mb_detect_order(); |
||
728 | if ( ! in_array( 'EUC-JP', $charsets ) ) { |
||
729 | $charsets[] = 'EUC-JP'; |
||
730 | mb_detect_order( $charsets ); |
||
731 | } |
||
732 | |||
733 | $eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' ); |
||
734 | $utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' ); |
||
735 | |||
736 | $this->assertEquals( 'aあb', $utf8 ); |
||
737 | |||
738 | $this->assertEquals( '["c","a\u3042b"]', wp_json_encode( array( 'c', $eucjp ) ) ); |
||
739 | |||
740 | mb_detect_order( $old_charsets ); |
||
741 | } |
||
742 | |||
743 | /** |
||
744 | * @ticket 28786 |
||
745 | */ |
||
746 | function test_wp_json_encode_array() { |
||
749 | |||
750 | /** |
||
751 | * @ticket 28786 |
||
752 | */ |
||
753 | function test_wp_json_encode_object() { |
||
758 | |||
759 | /** |
||
760 | * @ticket 28786 |
||
761 | */ |
||
762 | function test_wp_json_encode_depth() { |
||
775 | |||
776 | /** |
||
777 | * @ticket 33750 |
||
778 | */ |
||
779 | function test_the_date() { |
||
813 | |||
814 | /** |
||
815 | * @ticket 36054 |
||
816 | * @dataProvider datetime_provider |
||
817 | */ |
||
818 | function test_mysql_to_rfc3339( $expected, $actual ) { |
||
826 | |||
827 | function datetime_provider() { |
||
836 | |||
837 | /** |
||
838 | * @ticket 35987 |
||
839 | */ |
||
840 | View Code Duplication | public function test_wp_get_ext_types() { |
|
841 | $extensions = wp_get_ext_types(); |
||
842 | |||
843 | $this->assertInternalType( 'array', $extensions ); |
||
844 | $this->assertNotEmpty( $extensions ); |
||
845 | |||
846 | add_filter( 'ext2type', '__return_empty_array' ); |
||
847 | $extensions = wp_get_ext_types(); |
||
848 | $this->assertSame( array(), $extensions ); |
||
849 | |||
850 | remove_filter( 'ext2type', '__return_empty_array' ); |
||
851 | $extensions = wp_get_ext_types(); |
||
852 | $this->assertInternalType( 'array', $extensions ); |
||
853 | $this->assertNotEmpty( $extensions ); |
||
854 | } |
||
855 | |||
856 | /** |
||
857 | * @ticket 35987 |
||
858 | */ |
||
859 | public function test_wp_ext2type() { |
||
871 | |||
872 | /** |
||
873 | * Tests raising the memory limit. |
||
874 | * |
||
875 | * Unfortunately as the default for 'WP_MAX_MEMORY_LIMIT' in the |
||
876 | * test suite is -1, we can not test the memory limit negotiations. |
||
877 | * |
||
878 | * @ticket 32075 |
||
879 | */ |
||
880 | function test_wp_raise_memory_limit() { |
||
893 | |||
894 | /** |
||
895 | * Tests wp_generate_uuid4(). |
||
896 | * |
||
897 | * @covers ::wp_generate_uuid4 |
||
898 | * @ticket 38164 |
||
899 | */ |
||
900 | function test_wp_generate_uuid4() { |
||
911 | |||
912 | /** |
||
913 | * @ticket 40017 |
||
914 | * @dataProvider _wp_get_image_mime |
||
915 | */ |
||
916 | public function test_wp_get_image_mime( $file, $expected ) { |
||
923 | |||
924 | /** |
||
925 | * @ticket 39550 |
||
926 | * @dataProvider _wp_check_filetype_and_ext_data |
||
927 | */ |
||
928 | function test_wp_check_filetype_and_ext( $file, $filename, $expected ) { |
||
935 | |||
936 | /** |
||
937 | * @ticket 39550 |
||
938 | * @group ms-excluded |
||
939 | */ |
||
940 | View Code Duplication | function test_wp_check_filetype_and_ext_with_filtered_svg() { |
|
941 | if ( ! extension_loaded( 'fileinfo' ) ) { |
||
942 | $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); |
||
943 | } |
||
944 | |||
945 | $file = DIR_TESTDATA . '/uploads/video-play.svg'; |
||
946 | $filename = 'video-play.svg'; |
||
947 | |||
948 | $expected = array( |
||
949 | 'ext' => 'svg', |
||
950 | 'type' => 'image/svg+xml', |
||
951 | 'proper_filename' => false, |
||
952 | ); |
||
953 | |||
954 | add_filter( 'upload_mimes', array( $this, '_filter_mime_types_svg' ) ); |
||
955 | $this->assertEquals( $expected, wp_check_filetype_and_ext( $file, $filename ) ); |
||
956 | |||
957 | // Cleanup. |
||
958 | remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_svg' ) ); |
||
959 | } |
||
960 | |||
961 | /** |
||
962 | * @ticket 39550 |
||
963 | * @group ms-excluded |
||
964 | */ |
||
965 | View Code Duplication | function test_wp_check_filetype_and_ext_with_filtered_woff() { |
|
966 | if ( ! extension_loaded( 'fileinfo' ) ) { |
||
967 | $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); |
||
968 | } |
||
969 | |||
970 | $file = DIR_TESTDATA . '/uploads/dashicons.woff'; |
||
971 | $filename = 'dashicons.woff'; |
||
972 | |||
973 | $expected = array( |
||
974 | 'ext' => 'woff', |
||
975 | 'type' => 'application/font-woff', |
||
976 | 'proper_filename' => false, |
||
977 | ); |
||
978 | |||
979 | add_filter( 'upload_mimes', array( $this, '_filter_mime_types_woff' ) ); |
||
980 | $this->assertEquals( $expected, wp_check_filetype_and_ext( $file, $filename ) ); |
||
981 | |||
982 | // Cleanup. |
||
983 | remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_woff' ) ); |
||
984 | } |
||
985 | |||
986 | public function _filter_mime_types_svg( $mimes ) { |
||
990 | |||
991 | public function _filter_mime_types_woff( $mimes ) { |
||
995 | |||
996 | /** |
||
997 | * Data profider for test_wp_get_image_mime(); |
||
998 | */ |
||
999 | public function _wp_get_image_mime() { |
||
1030 | |||
1031 | public function _wp_check_filetype_and_ext_data() { |
||
1113 | } |
||
1114 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.