Changeset 1313 in tests
- Timestamp:
- 07/20/2013 08:52:04 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/media.php
r1310 r1313 237 237 } 238 238 239 /** 240 * @ticket 22960 241 */ 242 function test_post_gallery_images() { 243 $ids1 = array(); 244 $ids1_srcs = array(); 245 foreach ( range( 1, 3 ) as $i ) { 246 $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( 247 'post_mime_type' => 'image/jpeg', 248 'post_type' => 'attachment' 249 ) ); 250 wp_update_attachment_metadata( $attachment_id, $this->img_dimensions ); 251 $ids1[] = $attachment_id; 252 $ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg"; 253 } 254 255 $ids2 = array(); 256 $ids2_srcs = array(); 257 foreach ( range( 4, 6 ) as $i ) { 258 $attachment_id = $this->factory->attachment->create_object( "image$i.jpg", 0, array( 259 'post_mime_type' => 'image/jpeg', 260 'post_type' => 'attachment' 261 ) ); 262 wp_update_attachment_metadata( $attachment_id, $this->img_dimensions ); 263 $ids2[] = $attachment_id; 264 $ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg"; 265 } 266 267 $ids1_joined = join( ',', $ids1 ); 268 $ids2_joined = join( ',', $ids2 ); 269 270 $blob =<<<BLOB 271 [gallery ids="$ids1_joined"] 272 273 [gallery ids="$ids2_joined"] 274 BLOB; 275 $post_id = $this->factory->post->create( array( 'post_content' => $blob ) ); 276 $srcs = get_post_gallery_images( $post_id ); 277 $this->assertEquals( $srcs, $ids1_srcs ); 278 } 279 280 function test_get_media_embedded_in_content() { 281 $obj =<<<OBJ 282 <object src="this" data="that"> 283 <param name="value"/> 284 </object> 285 OBJ; 286 $embed =<<<EMBED 287 <embed src="something.mp4"/> 288 EMBED; 289 $iframe =<<<IFRAME 290 <iframe src="youtube.com" width="7000" /> 291 IFRAME; 292 $audio =<<<AUDIO 293 <audio preload="none"> 294 <source /> 295 </audio> 296 AUDIO; 297 $video =<<<VIDEO 298 <video preload="none"> 299 <source /> 300 </video> 301 VIDEO; 302 303 $content =<<<CONTENT 304 This is a comment 305 $obj 306 307 This is a comment 308 $embed 309 310 This is a comment 311 $iframe 312 313 This is a comment 314 $audio 315 316 This is a comment 317 $video 318 319 This is a comment 320 CONTENT; 321 322 $audios = array_values( compact( 'audio', 'obj', 'embed', 'iframe' ) ); 323 $videos = array_values( compact( 'video', 'obj', 'embed', 'iframe' ) ); 324 325 $matches = get_media_embedded_in_content( 'audio', $content ); 326 $this->assertEquals( $matches, $audios ); 327 $matches = get_media_embedded_in_content( 'video', $content ); 328 $this->assertEquals( $matches, $videos ); 329 } 239 330 }
Note: See TracChangeset
for help on using the changeset viewer.