Changeset 36307 for trunk/tests/phpunit/tests/oembed/postEmbedUrl.php
- Timestamp:
- 01/15/2016 07:55:19 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/postEmbedUrl.php
r35242 r36307 5 5 */ 6 6 class Tests_Post_Embed_URL extends WP_UnitTestCase { 7 function test_ get_post_embed_url_non_existent_post() {7 function test_non_existent_post() { 8 8 $embed_url = get_post_embed_url( 0 ); 9 9 $this->assertFalse( $embed_url ); 10 10 } 11 11 12 function test_ get_post_embed_url_with_pretty_permalinks() {13 update_option( 'permalink_structure','/%postname%' );12 function test_with_pretty_permalinks() { 13 $this->set_permalink_structure( '/%postname%' ); 14 14 15 15 $post_id = self::factory()->post->create(); … … 17 17 $embed_url = get_post_embed_url( $post_id ); 18 18 19 $this->assertEquals( user_trailingslashit( trailingslashit( $permalink ) . 'embed' ), $embed_url ); 20 21 update_option( 'permalink_structure', '' ); 19 $this->assertEquals( $permalink . '/embed', $embed_url ); 22 20 } 23 21 24 function test_ get_post_embed_url_with_ugly_permalinks() {22 function test_with_ugly_permalinks() { 25 23 $post_id = self::factory()->post->create(); 26 24 $permalink = get_permalink( $post_id ); … … 29 27 $this->assertEquals( $permalink . '&embed=true', $embed_url ); 30 28 } 29 30 /** 31 * @ticket 34971 32 */ 33 function test_static_front_page() { 34 $this->set_permalink_structure( '/%postname%/' ); 35 36 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 37 38 update_option( 'show_on_front', 'page' ); 39 update_option( 'page_on_front', $post_id ); 40 41 $embed_url = get_post_embed_url( $post_id ); 42 43 $this->assertSame( user_trailingslashit( trailingslashit( home_url() ) . 'embed' ), $embed_url ); 44 45 update_option( 'show_on_front', 'posts' ); 46 } 47 48 /** 49 * @ticket 34971 50 */ 51 function test_static_front_page_with_ugly_permalinks() { 52 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 53 54 update_option( 'show_on_front', 'page' ); 55 update_option( 'page_on_front', $post_id ); 56 57 $embed_url = get_post_embed_url( $post_id ); 58 59 $this->assertSame( trailingslashit( home_url() ) . '?embed=true', $embed_url ); 60 61 update_option( 'show_on_front', 'posts' ); 62 } 63 64 /** 65 * @ticket 34971 66 */ 67 function test_page_conflicts_with_embed_slug() { 68 $this->set_permalink_structure( '/%postname%/' ); 69 70 $parent_page = self::factory()->post->create( array( 'post_type' => 'page' ) ); 71 72 add_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ) ); 73 $child_page = self::factory()->post->create( array( 74 'post_type' => 'page', 75 'post_parent' => $parent_page, 76 'post_name' => 'embed', 77 ) ); 78 remove_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ) ); 79 80 $this->assertSame( get_permalink( $parent_page ) . '?embed=true', get_post_embed_url( $parent_page ) ); 81 $this->assertSame( get_permalink( $child_page ) . 'embed/', get_post_embed_url( $child_page ) ); 82 } 83 84 /** 85 * @ticket 34971 86 */ 87 function test_static_front_page_conflicts_with_embed_slug() { 88 $this->set_permalink_structure( '/%postname%/' ); 89 90 // Create a post with the 'embed' post_name 91 add_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ) ); 92 $post_embed_slug = self::factory()->post->create( array( 'post_name' => 'embed' ) ); 93 remove_filter( 'wp_unique_post_slug', array( $this, 'filter_unique_post_slug' ) ); 94 $page_front = self::factory()->post->create( array( 'post_type' => 'page' ) ); 95 96 update_option( 'show_on_front', 'page' ); 97 update_option( 'page_on_front', $page_front ); 98 99 $this->assertSame( home_url() . '/embed/embed/', get_post_embed_url( $post_embed_slug ) ); 100 $this->assertSame( home_url() . '/?embed=true', get_post_embed_url( $page_front ) ); 101 102 update_option( 'show_on_front', 'posts' ); 103 } 104 105 public function filter_unique_post_slug() { 106 return 'embed'; 107 } 31 108 }
Note: See TracChangeset
for help on using the changeset viewer.