Changeset 40071 for branches/4.7/tests/phpunit/tests/media.php
- Timestamp:
- 02/17/2017 06:46:45 AM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/tests/phpunit/tests/media.php
r39399 r40071 392 392 393 393 /** 394 * @ticket 39304 395 */ 396 function test_post_galleries_images_without_global_post() { 397 // Set up an unattached image. 398 $this->factory->attachment->create_object( array( 399 'file' => 'test.jpg', 400 'post_parent' => 0, 401 'post_mime_type' => 'image/jpeg', 402 'post_type' => 'attachment' 403 ) ); 404 405 $post_id = $this->factory->post->create( array( 406 'post_content' => '[gallery]', 407 ) ); 408 409 $galleries = get_post_galleries( $post_id, false ); 410 411 $this->assertEmpty( $galleries[0]['src'] ); 412 } 413 414 /** 415 * @ticket 39304 416 */ 417 function test_post_galleries_ignores_global_post() { 418 $global_post_id = $this->factory->post->create( array( 419 'post_content' => 'Global Post', 420 ) ); 421 $post_id = $this->factory->post->create( array( 422 'post_content' => '[gallery]', 423 ) ); 424 $this->factory->attachment->create_object( array( 425 'file' => 'test.jpg', 426 'post_parent' => $post_id, 427 'post_mime_type' => 'image/jpeg', 428 'post_type' => 'attachment' 429 ) ); 430 $expected_srcs = array( 431 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/test.jpg' 432 ); 433 434 // Set the global $post context to the other post. 435 $GLOBALS['post'] = get_post( $global_post_id ); 436 437 $galleries = get_post_galleries( $post_id, false ); 438 439 $this->assertNotEmpty( $galleries[0]['src'] ); 440 $this->assertSame( $galleries[0]['src'], $expected_srcs ); 441 } 442 443 /** 444 * @ticket 39304 445 */ 446 function test_post_galleries_respects_id_attrs() { 447 $post_id = $this->factory->post->create( array( 448 'post_content' => 'No gallery defined', 449 ) ); 450 $post_id_two = $this->factory->post->create( array( 451 'post_content' => "[gallery id='$post_id']", 452 ) ); 453 $this->factory->attachment->create_object( array( 454 'file' => 'test.jpg', 455 'post_parent' => $post_id, 456 'post_mime_type' => 'image/jpeg', 457 'post_type' => 'attachment' 458 ) ); 459 $expected_srcs = array( 460 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/test.jpg' 461 ); 462 463 $galleries = get_post_galleries( $post_id_two, false ); 464 465 // Set the global $post context 466 $GLOBALS['post'] = get_post( $post_id_two ); 467 $galleries_with_global_context = get_post_galleries( $post_id_two, false ); 468 469 // Check that the global post state doesn't affect the results 470 $this->assertSame( $galleries, $galleries_with_global_context ); 471 472 $this->assertNotEmpty( $galleries[0]['src'] ); 473 $this->assertSame( $galleries[0]['src'], $expected_srcs ); 474 } 475 476 /** 394 477 * @ticket 22960 395 478 */
Note: See TracChangeset
for help on using the changeset viewer.