functions.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <?php
  2. /**
  3. * @group functions.php
  4. */
  5. class Tests_Functions extends WP_UnitTestCase {
  6. function test_wp_parse_args_object() {
  7. $x = new MockClass;
  8. $x->_baba = 5;
  9. $x->yZ = "baba";
  10. $x->a = array(5, 111, 'x');
  11. $this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x));
  12. $y = new MockClass;
  13. $this->assertEquals(array(), wp_parse_args($y));
  14. }
  15. function test_wp_parse_args_array() {
  16. // arrays
  17. $a = array();
  18. $this->assertEquals(array(), wp_parse_args($a));
  19. $b = array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x'));
  20. $this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($b));
  21. }
  22. function test_wp_parse_args_defaults() {
  23. $x = new MockClass;
  24. $x->_baba = 5;
  25. $x->yZ = "baba";
  26. $x->a = array(5, 111, 'x');
  27. $d = array('pu' => 'bu');
  28. $this->assertEquals(array('pu' => 'bu', '_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x, $d));
  29. $e = array('_baba' => 6);
  30. $this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x, $e));
  31. }
  32. function test_wp_parse_args_other() {
  33. $b = true;
  34. wp_parse_str($b, $s);
  35. $this->assertEquals($s, wp_parse_args($b));
  36. $q = 'x=5&_baba=dudu&';
  37. wp_parse_str($q, $ss);
  38. $this->assertEquals($ss, wp_parse_args($q));
  39. }
  40. function test_size_format() {
  41. $kb = 1024;
  42. $mb = $kb*1024;
  43. $gb = $mb*1024;
  44. $tb = $gb*1024;
  45. // test if boundaries are correct
  46. $this->assertEquals('1 GB', size_format($gb, 0));
  47. $this->assertEquals('1 MB', size_format($mb, 0));
  48. $this->assertEquals('1 kB', size_format($kb, 0));
  49. // now some values around
  50. // add some bytes to make sure the result isn't 1.4999999
  51. $this->assertEquals('1.5 TB', size_format($tb + $tb/2 + $mb, 1));
  52. $this->assertEquals('1,023.999 GB', size_format($tb-$mb-$kb, 3));
  53. // edge
  54. $this->assertFalse(size_format(-1));
  55. $this->assertFalse(size_format(0));
  56. $this->assertFalse(size_format('baba'));
  57. $this->assertFalse(size_format(array()));
  58. }
  59. function test_path_is_absolute() {
  60. if ( !is_callable('path_is_absolute') )
  61. $this->markTestSkipped();
  62. $absolute_paths = array(
  63. '/',
  64. '/foo/',
  65. '/foo',
  66. '/FOO/bar',
  67. '/foo/bar/',
  68. '/foo/../bar/',
  69. '\\WINDOWS',
  70. 'C:\\',
  71. 'C:\\WINDOWS',
  72. '\\\\sambashare\\foo',
  73. );
  74. foreach ($absolute_paths as $path)
  75. $this->assertTrue( path_is_absolute($path), "path_is_absolute('$path') should return true" );
  76. }
  77. function test_path_is_not_absolute() {
  78. if ( !is_callable('path_is_absolute') )
  79. $this->markTestSkipped();
  80. $relative_paths = array(
  81. '',
  82. '.',
  83. '..',
  84. '../foo',
  85. '../',
  86. '../foo.bar',
  87. 'foo/bar',
  88. 'foo',
  89. 'FOO',
  90. '..\\WINDOWS',
  91. );
  92. foreach ($relative_paths as $path)
  93. $this->assertFalse( path_is_absolute($path), "path_is_absolute('$path') should return false" );
  94. }
  95. function test_wp_unique_filename() {
  96. $testdir = DIR_TESTDATA . '/images/';
  97. // sanity check
  98. $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcdefg.png' ), 'Sanitiy check failed' );
  99. // check number is appended for file already exists
  100. $this->assertFileExists( $testdir . 'test-image.png', 'Test image does not exist' );
  101. $this->assertEquals( 'test-image1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' );
  102. $this->assertFileNotExists( $testdir . 'test-image1.png' );
  103. // check special chars
  104. $this->assertEquals( 'testtést-imagé.png', wp_unique_filename( $testdir, 'testtést-imagé.png' ), 'Filename with special chars failed' );
  105. // check special chars with potential conflicting name
  106. $this->assertEquals( 'tést-imagé.png', wp_unique_filename( $testdir, 'tést-imagé.png' ), 'Filename with special chars failed' );
  107. // check with single quotes in name (somehow)
  108. $this->assertEquals( "abcdefgh.png", wp_unique_filename( $testdir, "abcdefg'h.png" ), 'File with quote failed' );
  109. // check with single quotes in name (somehow)
  110. $this->assertEquals( "abcdefgh.png", wp_unique_filename( $testdir, 'abcdefg"h.png' ), 'File with quote failed' );
  111. // test crazy name (useful for regression tests)
  112. $this->assertEquals( '12%af34567890@..%^_+qwerty-fghjkl-zx.png', wp_unique_filename( $testdir, '12%af34567890#~!@#$..%^&*()|_+qwerty fgh`jkl zx<>?:"{}[]="\'/?.png' ), 'Failed crazy file name' );
  113. // test slashes in names
  114. $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\fg.png' ), 'Slash not removed' );
  115. $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\fg.png' ), 'Double slashed not removed' );
  116. $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' );
  117. }
  118. /**
  119. * @ticket 9930
  120. */
  121. function test_is_serialized() {
  122. $cases = array(
  123. serialize(null),
  124. serialize(true),
  125. serialize(false),
  126. serialize(-25),
  127. serialize(25),
  128. serialize(1.1),
  129. serialize(2.1E+200),
  130. serialize('this string will be serialized'),
  131. serialize("a\nb"),
  132. serialize(array()),
  133. serialize(array(1,1,2,3,5,8,13)),
  134. serialize( (object)array('test' => true, '3', 4) )
  135. );
  136. foreach ( $cases as $case )
  137. $this->assertTrue( is_serialized($case), "Serialized data: $case" );
  138. $not_serialized = array(
  139. 'a string',
  140. 'garbage:a:0:garbage;',
  141. 'b:4;',
  142. 's:4:test;'
  143. );
  144. foreach ( $not_serialized as $case )
  145. $this->assertFalse( is_serialized($case), "Test data: $case" );
  146. }
  147. /**
  148. * @group add_query_arg
  149. */
  150. function test_add_query_arg() {
  151. $old_req_uri = $_SERVER['REQUEST_URI'];
  152. $urls = array(
  153. '/',
  154. '/2012/07/30/',
  155. 'edit.php',
  156. admin_url( 'edit.php' ),
  157. admin_url( 'edit.php', 'https' ),
  158. );
  159. $frag_urls = array(
  160. '/#frag',
  161. '/2012/07/30/#frag',
  162. 'edit.php#frag',
  163. admin_url( 'edit.php#frag' ),
  164. admin_url( 'edit.php#frag', 'https' ),
  165. );
  166. foreach ( $urls as $url ) {
  167. $_SERVER['REQUEST_URI'] = 'nothing';
  168. $this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1', $url ) );
  169. $this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ), $url ) );
  170. $this->assertEquals( "$url?foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $url ) );
  171. $this->assertEquals( "$url?foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $url ) );
  172. $_SERVER['REQUEST_URI'] = $url;
  173. $this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1' ) );
  174. $this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ) ) );
  175. $this->assertEquals( "$url?foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) );
  176. $this->assertEquals( "$url?foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) );
  177. }
  178. foreach ( $frag_urls as $frag_url ) {
  179. $_SERVER['REQUEST_URI'] = 'nothing';
  180. $url = str_replace( '#frag', '', $frag_url );
  181. $this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1', $frag_url ) );
  182. $this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ), $frag_url ) );
  183. $this->assertEquals( "$url?foo=2#frag", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $frag_url ) );
  184. $this->assertEquals( "$url?foo=1&bar=2#frag", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $frag_url ) );
  185. $_SERVER['REQUEST_URI'] = $frag_url;
  186. $this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1' ) );
  187. $this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ) ) );
  188. $this->assertEquals( "$url?foo=2#frag", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) );
  189. $this->assertEquals( "$url?foo=1&bar=2#frag", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) );
  190. }
  191. $qs_urls = array(
  192. 'baz=1', // #WP4903
  193. '/?baz',
  194. '/2012/07/30/?baz',
  195. 'edit.php?baz',
  196. admin_url( 'edit.php?baz' ),
  197. admin_url( 'edit.php?baz', 'https' ),
  198. admin_url( 'edit.php?baz&za=1' ),
  199. admin_url( 'edit.php?baz=1&za=1' ),
  200. admin_url( 'edit.php?baz=0&za=0' ),
  201. );
  202. foreach ( $qs_urls as $url ) {
  203. $_SERVER['REQUEST_URI'] = 'nothing';
  204. $this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1', $url ) );
  205. $this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ), $url ) );
  206. $this->assertEquals( "$url&foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $url ) );
  207. $this->assertEquals( "$url&foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $url ) );
  208. $_SERVER['REQUEST_URI'] = $url;
  209. $this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1' ) );
  210. $this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ) ) );
  211. $this->assertEquals( "$url&foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) );
  212. $this->assertEquals( "$url&foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) );
  213. }
  214. $_SERVER['REQUEST_URI'] = $old_req_uri;
  215. }
  216. /**
  217. * @ticket 21594
  218. */
  219. function test_get_allowed_mime_types() {
  220. $mimes = get_allowed_mime_types();
  221. $this->assertInternalType( 'array', $mimes );
  222. $this->assertNotEmpty( $mimes );
  223. add_filter( 'upload_mimes', '__return_empty_array' );
  224. $mimes = get_allowed_mime_types();
  225. $this->assertInternalType( 'array', $mimes );
  226. $this->assertEmpty( $mimes );
  227. remove_filter( 'upload_mimes', '__return_empty_array' );
  228. $mimes = get_allowed_mime_types();
  229. $this->assertInternalType( 'array', $mimes );
  230. $this->assertNotEmpty( $mimes );
  231. }
  232. /**
  233. * @ticket 21594
  234. */
  235. function test_wp_get_mime_types() {
  236. $mimes = wp_get_mime_types();
  237. $this->assertInternalType( 'array', $mimes );
  238. $this->assertNotEmpty( $mimes );
  239. add_filter( 'mime_types', '__return_empty_array' );
  240. $mimes = wp_get_mime_types();
  241. $this->assertInternalType( 'array', $mimes );
  242. $this->assertEmpty( $mimes );
  243. remove_filter( 'mime_types', '__return_empty_array' );
  244. $mimes = wp_get_mime_types();
  245. $this->assertInternalType( 'array', $mimes );
  246. $this->assertNotEmpty( $mimes );
  247. // upload_mimes shouldn't affect wp_get_mime_types()
  248. add_filter( 'upload_mimes', '__return_empty_array' );
  249. $mimes = wp_get_mime_types();
  250. $this->assertInternalType( 'array', $mimes );
  251. $this->assertNotEmpty( $mimes );
  252. remove_filter( 'upload_mimes', '__return_empty_array' );
  253. $mimes2 = wp_get_mime_types();
  254. $this->assertInternalType( 'array', $mimes2 );
  255. $this->assertNotEmpty( $mimes2 );
  256. $this->assertEquals( $mimes2, $mimes );
  257. }
  258. /**
  259. * @ticket 23688
  260. */
  261. function test_canonical_charset() {
  262. $orig_blog_charset = get_option( 'blog_charset' );
  263. update_option( 'blog_charset', 'utf8' );
  264. $this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
  265. update_option( 'blog_charset', 'utf-8' );
  266. $this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
  267. update_option( 'blog_charset', 'UTF8' );
  268. $this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
  269. update_option( 'blog_charset', 'UTF-8' );
  270. $this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
  271. update_option( 'blog_charset', 'ISO-8859-1' );
  272. $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
  273. update_option( 'blog_charset', 'ISO8859-1' );
  274. $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
  275. update_option( 'blog_charset', 'iso8859-1' );
  276. $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
  277. update_option( 'blog_charset', 'iso-8859-1' );
  278. $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
  279. // Arbitrary strings are passed through.
  280. update_option( 'blog_charset', 'foobarbaz' );
  281. $this->assertEquals( 'foobarbaz', get_option( 'blog_charset') );
  282. update_option( 'blog_charset', $orig_blog_charset );
  283. }
  284. /**
  285. * @dataProvider data_wp_parse_id_list
  286. */
  287. function test_wp_parse_id_list( $expected, $actual ) {
  288. $this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) );
  289. }
  290. function data_wp_parse_id_list() {
  291. return array(
  292. array( array( 1, 2, 3, 4 ), '1,2,3,4' ),
  293. array( array( 1, 2, 3, 4 ), '1, 2,,3,4' ),
  294. array( array( 1, 2, 3, 4 ), '1,2,2,3,4' ),
  295. array( array( 1, 2, 3, 4 ), array( '1', '2', '3', '4', '3' ) ),
  296. array( array( 1, 2, 3, 4 ), array( 1, '2', 3, '4' ) ),
  297. array( array( 1, 2, 3, 4 ), '-1,2,-3,4' ),
  298. array( array( 1, 2, 3, 4 ), array( -1, 2, '-3', '4' ) ),
  299. );
  300. }
  301. /**
  302. * @ticket 19354
  303. */
  304. function test_data_is_not_an_allowed_protocol() {
  305. $this->assertNotContains( 'data', wp_allowed_protocols() );
  306. }
  307. /**
  308. * @ticket 9064
  309. */
  310. function test_wp_extract_urls() {
  311. $original_urls = array(
  312. 'http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html',
  313. 'http://this.com',
  314. 'http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437',
  315. 'http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html',
  316. 'http://wordpress-core.com:8080/',
  317. 'http://www.website.com:5000',
  318. 'http://wordpress-core/?346236346326&2134362574863.437',
  319. 'http://افغانستا.icom.museum',
  320. 'http://الجزائر.icom.museum',
  321. 'http://österreich.icom.museum',
  322. 'http://বাংলাদেশ.icom.museum',
  323. 'http://беларусь.icom.museum',
  324. 'http://belgië.icom.museum',
  325. 'http://българия.icom.museum',
  326. 'http://تشادر.icom.museum',
  327. 'http://中国.icom.museum',
  328. #'http://القمر.icom.museum', // Comoros http://القمر.icom.museum
  329. #'http://κυπρος.icom.museum', Cyprus http://κυπρος.icom.museum
  330. 'http://českárepublika.icom.museum',
  331. #'http://مصر.icom.museum', // Egypt http://مصر.icom.museum
  332. 'http://ελλάδα.icom.museum',
  333. 'http://magyarország.icom.museum',
  334. 'http://ísland.icom.museum',
  335. 'http://भारत.icom.museum',
  336. 'http://ايران.icom.museum',
  337. 'http://éire.icom.museum',
  338. 'http://איקו״ם.ישראל.museum',
  339. 'http://日本.icom.museum',
  340. 'http://الأردن.icom.museum',
  341. 'http://қазақстан.icom.museum',
  342. 'http://한국.icom.museum',
  343. 'http://кыргызстан.icom.museum',
  344. 'http://ລາວ.icom.museum',
  345. 'http://لبنان.icom.museum',
  346. 'http://македонија.icom.museum',
  347. #'http://موريتانيا.icom.museum', // Mauritania http://موريتانيا.icom.museum
  348. 'http://méxico.icom.museum',
  349. 'http://монголулс.icom.museum',
  350. #'http://المغرب.icom.museum', // Morocco http://المغرب.icom.museum
  351. 'http://नेपाल.icom.museum',
  352. #'http://عمان.icom.museum', // Oman http://عمان.icom.museum
  353. 'http://قطر.icom.museum',
  354. 'http://românia.icom.museum',
  355. 'http://россия.иком.museum',
  356. 'http://србијаицрнагора.иком.museum',
  357. 'http://இலங்கை.icom.museum',
  358. 'http://españa.icom.museum',
  359. 'http://ไทย.icom.museum',
  360. 'http://تونس.icom.museum',
  361. 'http://türkiye.icom.museum',
  362. 'http://украина.icom.museum',
  363. 'http://việtnam.icom.museum'
  364. );
  365. $blob ="
  366. http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html
  367. http://this.com
  368. http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&amp;2134362574863.437
  369. http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html
  370. http://wordpress-core.com:8080/
  371. http://www.website.com:5000
  372. http://wordpress-core/?346236346326&amp;2134362574863.437
  373. http://افغانستا.icom.museum
  374. http://الجزائر.icom.museum
  375. http://österreich.icom.museum
  376. http://বাংলাদেশ.icom.museum
  377. http://беларусь.icom.museum
  378. http://belgië.icom.museum
  379. http://българия.icom.museum
  380. http://تشادر.icom.museum
  381. http://中国.icom.museum
  382. http://českárepublika.icom.museum
  383. http://ελλάδα.icom.museum
  384. http://magyarország.icom.museum
  385. http://ísland.icom.museum
  386. http://भारत.icom.museum
  387. http://ايران.icom.museum
  388. http://éire.icom.museum
  389. http://איקו״ם.ישראל.museum
  390. http://日本.icom.museum
  391. http://الأردن.icom.museum
  392. http://қазақстан.icom.museum
  393. http://한국.icom.museum
  394. http://кыргызстан.icom.museum
  395. http://ລາວ.icom.museum
  396. http://لبنان.icom.museum
  397. http://македонија.icom.museum
  398. http://méxico.icom.museum
  399. http://монголулс.icom.museum
  400. http://नेपाल.icom.museum
  401. http://قطر.icom.museum
  402. http://românia.icom.museum
  403. http://россия.иком.museum
  404. http://србијаицрнагора.иком.museum
  405. http://இலங்கை.icom.museum
  406. http://españa.icom.museum
  407. http://ไทย.icom.museum
  408. http://تونس.icom.museum
  409. http://türkiye.icom.museum
  410. http://украина.icom.museum
  411. http://việtnam.icom.museum
  412. ";
  413. $urls = wp_extract_urls( $blob );
  414. $this->assertNotEmpty( $urls );
  415. $this->assertInternalType( 'array', $urls );
  416. $this->assertCount( count( $original_urls ), $urls );
  417. $this->assertEquals( $original_urls, $urls );
  418. $exploded = array_values( array_filter( array_map( 'trim', explode( "\n", $blob ) ) ) );
  419. // wp_extract_urls calls html_entity_decode
  420. $decoded = array_map( 'html_entity_decode', $exploded );
  421. $this->assertEquals( $decoded, $urls );
  422. $this->assertEquals( $original_urls, $decoded );
  423. $blob ="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
  424. incididunt ut labore http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html et dolore magna aliqua.
  425. Ut http://this.com enim ad minim veniam, quis nostrud exercitation ullamco
  426. laboris nisi ut aliquip ex http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&amp;2134362574863.437 ea
  427. commodo consequat. http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html Duis aute irure dolor in reprehenderit in voluptate
  428. velit esse http://wordpress-core.com:8080/ cillum dolore eu fugiat nulla <A href=\"http://www.website.com:5000\">http://www.website.com:5000</B> pariatur. Excepteur sint occaecat cupidatat non proident,
  429. sunt in culpa qui officia deserunt mollit http://wordpress-core/?346236346326&amp;2134362574863.437 anim id est laborum.";
  430. $urls = wp_extract_urls( $blob );
  431. $this->assertNotEmpty( $urls );
  432. $this->assertInternalType( 'array', $urls );
  433. $this->assertCount( 7, $urls );
  434. $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls );
  435. $blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
  436. incididunt ut labore <a href="http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> et dolore magna aliqua.
  437. Ut <a href="http://this.com">&amp;3640i6p1yi499</a> enim ad minim veniam, quis nostrud exercitation ullamco
  438. laboris nisi ut aliquip ex <a href="http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&amp;2134362574863.437">343462^</a> ea
  439. commodo consequat. <a href="http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> Duis aute irure dolor in reprehenderit in voluptate
  440. velit esse <a href="http://wordpress-core.com:8080/">-3-4--321-64-4@#!$^$!@^@^</a> cillum dolore eu <A href="http://www.website.com:5000">http://www.website.com:5000</B> fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
  441. sunt in culpa qui officia deserunt mollit <a href="http://wordpress-core/?346236346326&amp;2134362574863.437">)(*&^%$</a> anim id est laborum.';
  442. $urls = wp_extract_urls( $blob );
  443. $this->assertNotEmpty( $urls );
  444. $this->assertInternalType( 'array', $urls );
  445. $this->assertCount( 7, $urls );
  446. $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls );
  447. }
  448. }