Changeset 61119 for trunk/tests/phpunit/tests/oembed/discovery.php
- Timestamp:
- 11/04/2025 12:45:02 AM (6 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/oembed/discovery.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/discovery.php
r59700 r61119 50 50 51 51 $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); 52 53 add_filter( 'oembed_discovery_links', '__return_empty_string' ); 54 $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ), 'Expected filtering oembed_discovery_links to empty string to result in no wp_oembed_add_discovery_links() output.' ); 52 55 } 53 56 … … 101 104 $this->assertFalse( get_oembed_response_data( $post, 100 ) ); 102 105 } 106 107 /** 108 * @ticket 64178 109 * @covers ::wp_oembed_add_discovery_links 110 */ 111 public function test_wp_oembed_add_discovery_links_back_compat() { 112 $action = 'wp_head'; 113 $old_priority = 10; 114 $new_priority = 4; 115 $callback = 'wp_oembed_add_discovery_links'; 116 117 $this->assertTrue( has_action( $action, $callback, $old_priority ), 'Expected wp_oembed_add_discovery_links() to be hooked at wp_head with old priority.' ); 118 $this->assertTrue( has_action( $action, $callback, $new_priority ), 'Expected wp_oembed_add_discovery_links() to be hooked at wp_head with new priority.' ); 119 120 // Remove all wp_head actions and re-add just the one being tested. 121 remove_all_actions( $action ); 122 add_action( $action, $callback, $old_priority ); 123 add_action( $action, $callback, $new_priority ); 124 125 $post_id = self::factory()->post->create(); 126 $this->go_to( get_permalink( $post_id ) ); 127 $this->assertQueryTrue( 'is_single', 'is_singular' ); 128 129 $mock_action = new MockAction(); 130 add_filter( 'oembed_discovery_links', array( $mock_action, 'filter' ) ); 131 132 $wp_head_output = get_echo( 'wp_head' ); 133 $this->assertSame( 1, $mock_action->get_call_count() ); 134 135 $expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; 136 $expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; 137 138 $this->assertSame( $expected, $wp_head_output, 'Expected wp_head output to be the same as the wp_oembed_add_discovery_links() output.' ); 139 $this->assertSame( $expected, get_echo( $callback ), 'Expected wp_oembed_add_discovery_links() output to be the same as the wp_head output when called outside of wp_head.' ); 140 } 103 141 }
Note: See TracChangeset
for help on using the changeset viewer.