Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/phpunit/tests/oembed/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ public function test_wp_oembed_ensure_format() {
$this->assertSame( 'json', wp_oembed_ensure_format( array() ) );
}

/**
* @requires extension simplexml
*/
public function test_oembed_create_xml() {
$actual = _oembed_create_xml(
array(
Expand Down Expand Up @@ -454,6 +457,9 @@ public function test_request_ms_child_in_root_blog() {
restore_current_blog();
}

/**
* @requires extension simplexml
*/
public function test_rest_pre_serve_request() {
$user = get_user_by( 'id', self::$subscriber );
$post = self::factory()->post->create_and_get(
Expand Down
30 changes: 20 additions & 10 deletions tests/phpunit/tests/oembed/discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public function test_add_oembed_discovery_links_static_front_page() {
$this->go_to( home_url() );
$this->assertQueryTrue( 'is_front_page', 'is_singular', 'is_page' );

$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
}

$this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );

Expand All @@ -45,8 +47,10 @@ public function test_add_oembed_discovery_links_to_post() {
$this->go_to( get_permalink( $post_id ) );
$this->assertQueryTrue( 'is_single', 'is_singular' );

$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
}

$this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );

Expand All @@ -63,8 +67,10 @@ public function test_add_oembed_discovery_links_to_page() {
$this->go_to( get_permalink( $post_id ) );
$this->assertQueryTrue( 'is_page', 'is_singular' );

$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
}

$this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
}
Expand All @@ -83,8 +89,10 @@ public function test_add_oembed_discovery_links_to_attachment() {
$this->go_to( get_permalink( $attachment_id ) );
$this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' );

$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
}

$this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
}
Expand Down Expand Up @@ -132,8 +140,10 @@ public function test_wp_oembed_add_discovery_links_back_compat() {
$wp_head_output = get_echo( 'wp_head' );
$this->assertSame( 1, $mock_action->get_call_count() );

$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
$expected = '<link rel="alternate" title="oEmbed (JSON)" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
$expected .= '<link rel="alternate" title="oEmbed (XML)" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
}

$this->assertSame( $expected, $wp_head_output, 'Expected wp_head output to be the same as the wp_oembed_add_discovery_links() output.' );
$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.' );
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/oembed/headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @group oembed
* @group oembed-headers
* @group xdebug
* @requires extension simplexml
*/
class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {

Expand Down
Loading