Changeset 48135 for trunk/tests/phpunit/tests/oembed/controller.php
- Timestamp:
- 06/23/2020 06:06:11 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/controller.php
r47615 r48135 98 98 99 99 // 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 ) ) { 101 101 return array( 102 102 'response' => array( … … 610 610 } 611 611 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 612 637 public function test_proxy_with_invalid_oembed_provider_no_discovery() { 613 638 wp_set_current_user( self::$editor ); 614 639 615 // If discover is false for an unk own provider, no discovery request should take place.640 // If discover is false for an unknown provider, no discovery request should take place. 616 641 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); 617 642 $request->set_param( 'url', self::INVALID_OEMBED_URL ); 618 $request->set_param( 'discover', 0);643 $request->set_param( 'discover', false ); 619 644 $response = rest_get_server()->dispatch( $request ); 620 645 $this->assertEquals( 404, $response->get_status() ); … … 625 650 wp_set_current_user( self::$editor ); 626 651 627 // For an unk own provider, a discovery request should happen.652 // For an unknown provider, a discovery request should happen. 628 653 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); 629 654 $request->set_param( 'url', self::INVALID_OEMBED_URL );
Note: See TracChangeset
for help on using the changeset viewer.