WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/23/2020 06:06:11 AM (15 months ago)
Author:
whyisjake
Message:

Embeds: Ensure that classic embed support works in the block editor.

See https://github.com/WordPress/gutenberg/pull/6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/oembed/controller.php

    r47615 r48135  
    9898
    9999        // Mock request to YouTube Embed.
    100         if ( ! empty( $query_params['url'] ) && false !== strpos( $query_params['url'], self::YOUTUBE_VIDEO_ID ) ) {
     100        if ( ! empty( $query_params['url'] ) && false !== strpos( $query_params['url'], '?v=' . self::YOUTUBE_VIDEO_ID ) ) {
    101101            return array(
    102102                'response' => array(
     
    610610    }
    611611
     612    /**
     613     * @ticket 45447
     614     *
     615     * @see wp_maybe_load_embeds()
     616     */
     617    public function test_proxy_with_classic_embed_provider() {
     618        wp_set_current_user( self::$editor );
     619        $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' );
     620        $request->set_param( 'url', 'https://www.youtube.com/embed/' . self::YOUTUBE_VIDEO_ID );
     621        $request->set_param( 'maxwidth', 456 );
     622        $request->set_param( 'maxheight', 789 );
     623        $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) );
     624        $response = rest_get_server()->dispatch( $request );
     625        $this->assertEquals( 200, $response->get_status() );
     626        $this->assertEquals( 2, $this->request_count );
     627
     628        // Test data object.
     629        $data = $response->get_data();
     630
     631        $this->assertNotEmpty( $data );
     632        $this->assertInternalType( 'object', $data );
     633        $this->assertInternalType( 'string', $data->html );
     634        $this->assertInternalType( 'array', $data->scripts );
     635    }
     636
    612637    public function test_proxy_with_invalid_oembed_provider_no_discovery() {
    613638        wp_set_current_user( self::$editor );
    614639
    615         // If discover is false for an unkown provider, no discovery request should take place.
     640        // If discover is false for an unknown provider, no discovery request should take place.
    616641        $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' );
    617642        $request->set_param( 'url', self::INVALID_OEMBED_URL );
    618         $request->set_param( 'discover', 0 );
     643        $request->set_param( 'discover', false );
    619644        $response = rest_get_server()->dispatch( $request );
    620645        $this->assertEquals( 404, $response->get_status() );
     
    625650        wp_set_current_user( self::$editor );
    626651
    627         // For an unkown provider, a discovery request should happen.
     652        // For an unknown provider, a discovery request should happen.
    628653        $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' );
    629654        $request->set_param( 'url', self::INVALID_OEMBED_URL );
Note: See TracChangeset for help on using the changeset viewer.