Ticket #26675: media.php_unit-test.patch
File media.php_unit-test.patch, 3.5 KB (added by , 11 years ago) |
---|
-
tests/phpunit/tests/media.php
284 284 } 285 285 286 286 function test_get_media_embedded_in_content() { 287 $object =<<<OBJ287 $object[0] =<<<OBJ 288 288 <object src="this" data="that"> 289 289 <param name="value"/> 290 290 </object> 291 291 OBJ; 292 $embed =<<<EMBED 292 $object[1] =<<<OBJ 293 <object src="that" data="this"> 294 <param name="value"/> 295 </object> 296 OBJ; 297 $embed[0] =<<<EMBED 293 298 <embed src="something.mp4"/> 294 299 EMBED; 295 $iframe =<<<IFRAME 296 <iframe src="youtube.com" width="7000" /> 300 $embed[1] =<<<EMBED 301 <embed src="anotherthing.mp4"/> 302 EMBED; 303 $iframe[0] =<<<IFRAME 304 <iframe src="youtube.com" width="7000"></iframe> 297 305 IFRAME; 298 $audio =<<<AUDIO 306 $iframe[1] =<<<IFRAME 307 <iframe src="vimeo.com" width="7000"></iframe> 308 IFRAME; 309 $audio[0] =<<<AUDIO 299 310 <audio preload="none"> 300 311 <source /> 301 312 </audio> 302 313 AUDIO; 303 $video =<<<VIDEO 314 $audio[1] =<<<AUDIO 315 <audio preload="none"> 316 <source /> 317 </audio> 318 AUDIO; 319 $video[0] =<<<VIDEO 304 320 <video preload="none"> 305 321 <source /> 306 322 </video> 307 323 VIDEO; 324 $video[1] =<<<VIDEO 325 <video preload="none"> 326 <source /> 327 </video> 328 VIDEO; 329 $img[0] =<<<IMG 330 <img src="kittens.jpg"/> 331 IMG; 332 $img[1] =<<<IMG 333 <img src="cats.png"/> 334 IMG; 308 335 309 336 $content =<<<CONTENT 310 337 This is a comment 311 $object 338 $object[0] 312 339 313 340 This is a comment 314 $ embed341 $img[0] 315 342 316 343 This is a comment 317 $iframe 344 $iframe[0] 318 345 319 346 This is a comment 320 $ audio347 $embed[0] 321 348 322 349 This is a comment 323 $video 350 $video[0] 324 351 325 352 This is a comment 353 $iframe[1] 354 355 This is a comment 356 $audio[0] 357 358 This is a comment 359 $embed[1] 360 361 This is a comment 362 $video[1] 363 364 This is a comment 365 $img[1] 366 367 This is a comment 368 $audio[1] 369 370 This is a comment 371 $object[1] 372 373 This is a comment 326 374 CONTENT; 327 375 328 $types = array( 'audio', 'video', 'object', 'embed', 'iframe' ); 329 $contents = array_values( compact( $types ) ); 376 $types = array( 'img', 'audio', 'video', 'object', 'embed', 'iframe' ); 377 $contents = array( $img[0], $img[1], $audio[0], $audio[1], $video[0], $video[1], $object[0], $object[1], $embed[0], $embed[1], $iframe[0], $iframe[1] ); 378 $source_contents = array( $object[0], $img[0], $iframe[0], $embed[0], $video[0], $iframe[1], $audio[0], $embed[1], $video[1], $img[1], $audio[1], $object[1] ); 330 379 380 $matches = get_media_embedded_in_content( $content, 'img' ); 381 $this->assertEquals( $img, $matches ); 382 331 383 $matches = get_media_embedded_in_content( $content, 'audio' ); 332 $this->assertEquals( array( $audio ), $matches );384 $this->assertEquals( $audio, $matches ); 333 385 334 386 $matches = get_media_embedded_in_content( $content, 'video' ); 335 $this->assertEquals( array( $video ), $matches );387 $this->assertEquals( $video, $matches ); 336 388 337 389 $matches = get_media_embedded_in_content( $content, 'object' ); 338 $this->assertEquals( array( $object ), $matches );390 $this->assertEquals( $object, $matches ); 339 391 340 392 $matches = get_media_embedded_in_content( $content, 'embed' ); 341 $this->assertEquals( array( $embed ), $matches );393 $this->assertEquals( $embed, $matches ); 342 394 343 395 $matches = get_media_embedded_in_content( $content, 'iframe' ); 344 $this->assertEquals( array( $iframe ), $matches );396 $this->assertEquals( $iframe, $matches ); 345 397 346 398 $matches = get_media_embedded_in_content( $content, $types ); 347 399 $this->assertEquals( $contents, $matches ); 400 401 $matches = get_media_embedded_in_content( $content, $types, 'source' ); 402 $this->assertEquals( $source_contents, $matches ); 348 403 } 349 } 404 } 405 No newline at end of file