mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-03 14:17:06 +00:00
Embeds: Who put this REST API infrastructure in my WordPress?
Well, while it's here, we probably should make use of it. The oEmbed endpoint now uses the REST API infrastructure, instead of providing its own. Props swissspidy. Fixes #34207. git-svn-id: https://develop.svn.wordpress.org/trunk@35436 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -5,26 +5,18 @@
|
||||
*/
|
||||
class Tests_oEmbed_Discovery extends WP_UnitTestCase {
|
||||
function test_add_oembed_discovery_links_non_singular() {
|
||||
ob_start();
|
||||
wp_oembed_add_discovery_links();
|
||||
$actual = ob_get_clean();
|
||||
$this->assertSame( '', $actual );
|
||||
$this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
}
|
||||
|
||||
function test_add_oembed_discovery_links_to_post() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$this->go_to( get_permalink( $post_id ) );
|
||||
|
||||
$this->assertQueryTrue( 'is_single', 'is_singular' );
|
||||
|
||||
ob_start();
|
||||
wp_oembed_add_discovery_links();
|
||||
$actual = ob_get_clean();
|
||||
|
||||
$expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
|
||||
$expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
|
||||
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
}
|
||||
|
||||
function test_add_oembed_discovery_links_to_page() {
|
||||
@@ -32,17 +24,12 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
|
||||
'post_type' => 'page'
|
||||
));
|
||||
$this->go_to( get_permalink( $post_id ) );
|
||||
|
||||
$this->assertQueryTrue( 'is_page', 'is_singular' );
|
||||
|
||||
ob_start();
|
||||
wp_oembed_add_discovery_links();
|
||||
$actual = ob_get_clean();
|
||||
|
||||
$expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
|
||||
$expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
|
||||
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
}
|
||||
|
||||
function test_add_oembed_discovery_links_to_attachment() {
|
||||
@@ -53,16 +40,11 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase {
|
||||
) );
|
||||
|
||||
$this->go_to( get_permalink( $attachment_id ) );
|
||||
|
||||
$this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' );
|
||||
|
||||
ob_start();
|
||||
wp_oembed_add_discovery_links();
|
||||
$actual = ob_get_clean();
|
||||
|
||||
$expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
|
||||
$expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
|
||||
|
||||
$this->assertEquals( $expected, $actual );
|
||||
$this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user