Changeset 41047 for trunk/tests/phpunit/tests/oembed/controller.php
- Timestamp:
- 07/14/2017 04:04:04 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/controller.php
r41035 r41047 50 50 parent::tearDown(); 51 51 52 remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10 , 3);52 remove_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10 ); 53 53 } 54 54 … … 71 71 unset( $preempt, $r ); 72 72 73 $parsed_url = wp_parse_url( $url ); 74 parse_str( $parsed_url['query'], $query_params ); 73 75 $this->request_count += 1; 74 76 75 77 // Mock request to YouTube Embed. 76 if ( false !== strpos( $url, self::YOUTUBE_VIDEO_ID ) ) {78 if ( ! empty( $query_params['url'] ) && false !== strpos( $query_params['url'], self::YOUTUBE_VIDEO_ID ) ) { 77 79 return array( 78 80 'response' => array( … … 85 87 'provider_name' => 'YouTube', 86 88 'provider_url' => 'https://www.youtube.com', 87 'thumbnail_width' => 480, 88 'width' => 500, 89 'thumbnail_height' => 360, 90 'html' => '<iframe width="500" height="375" src="https://www.youtube.com/embed/' . self::YOUTUBE_VIDEO_ID . '?feature=oembed" frameborder="0" allowfullscreen></iframe>', 89 'thumbnail_width' => $query_params['maxwidth'], 90 'width' => $query_params['maxwidth'], 91 'thumbnail_height' => $query_params['maxheight'], 92 'height' => $query_params['maxheight'], 93 'html' => '<iframe width="' . $query_params['maxwidth'] . '" height="' . $query_params['maxheight'] . '" src="https://www.youtube.com/embed/' . self::YOUTUBE_VIDEO_ID . '?feature=oembed" frameborder="0" allowfullscreen></iframe>', 91 94 'author_name' => 'Yosemitebear62', 92 95 'thumbnail_url' => 'https://i.ytimg.com/vi/' . self::YOUTUBE_VIDEO_ID . '/hqdefault.jpg', 93 96 'title' => 'Yosemitebear Mountain Double Rainbow 1-8-10', 94 'height' => 375,95 97 ) 96 98 ), … … 478 480 479 481 $this->assertEquals( 400, $response->get_status() ); 480 $data = $response->get_data();481 482 } 482 483 … … 485 486 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); 486 487 $request->set_param( 'url', 'https://www.youtube.com/watch?v=' . self::YOUTUBE_VIDEO_ID ); 488 $request->set_param( 'maxwidth', 456 ); 489 $request->set_param( 'maxheight', 789 ); 487 490 $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) ); 488 491 $response = $this->server->dispatch( $request ); … … 499 502 $request->set_param( 'url', 'https://www.youtube.com/watch?v=' . self::YOUTUBE_VIDEO_ID ); 500 503 $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) ); 504 $request->set_param( 'maxwidth', 456 ); 505 $request->set_param( 'maxheight', 789 ); 501 506 $response = $this->server->dispatch( $request ); 502 507 $this->assertEquals( 1, $this->request_count ); … … 509 514 $this->assertEquals( 'YouTube', $data->provider_name ); 510 515 $this->assertEquals( 'https://i.ytimg.com/vi/' . self::YOUTUBE_VIDEO_ID . '/hqdefault.jpg', $data->thumbnail_url ); 516 $this->assertEquals( $data->width, $request['maxwidth'] ); 517 $this->assertEquals( $data->height, $request['maxheight'] ); 511 518 } 512 519
Note: See TracChangeset
for help on using the changeset viewer.