@@ -366,6 +366,64 @@ function test_autoembed( $content, $result = null ) {
366366 $ this ->assertSame ( $ wp_embed ->autoembed ( $ content ), $ result ? $ result : $ content );
367367 }
368368
369+ function data_oembed () {
370+ $ default_embed = wp_embed_defaults ();
371+
372+ return array (
373+ array (
374+ 'https://example.org/oembed ' ,
375+ 'https://youtube.com/?v=xyz ' ,
376+ '' ,
377+ add_query_arg (
378+ array (
379+ 'maxwidth ' => (int ) $ default_embed [0 ],
380+ 'maxheight ' => (int ) $ default_embed [1 ],
381+ 'url ' => urlencode ( 'https://youtube.com/?v=xyz ' ),
382+ 'dnt ' => 1 ,
383+ ),
384+ 'https://example.org/oembed ' ,
385+ ),
386+ ),
387+ array (
388+ 'https://example.org/oembed ' ,
389+ 'https://youtube.com/?v=xyz ' ,
390+ 'width=1280 ' ,
391+ add_query_arg (
392+ array (
393+ 'maxwidth ' => 1280 ,
394+ 'maxheight ' => (int ) $ default_embed [1 ],
395+ 'url ' => urlencode ( 'https://youtube.com/?v=xyz ' ),
396+ 'dnt ' => 1 ,
397+ ),
398+ 'https://example.org/oembed ' ,
399+ ),
400+ ),
401+ array (
402+ 'https://example.org/oembed ' ,
403+ 'https://youtube.com/?v=xyz ' ,
404+ array ( 'width ' => 1280 ),
405+ add_query_arg (
406+ array (
407+ 'maxwidth ' => 1280 ,
408+ 'maxheight ' => (int ) $ default_embed [1 ],
409+ 'url ' => urlencode ( 'https://youtube.com/?v=xyz ' ),
410+ 'dnt ' => 1 ,
411+ ),
412+ 'https://example.org/oembed ' ,
413+ ),
414+ ),
415+ );
416+ }
417+
418+ /**
419+ * @dataProvider data_oembed
420+ */
421+ function test_oembed_fetch_url ( $ provider , $ url , $ args , $ result ) {
422+ $ wp_oembed = new Test_oEmbed ;
423+
424+ $ this ->assertSame ( $ wp_oembed ->fetch ( $ provider , $ url , $ args ), $ result );
425+ }
426+
369427 function test_wp_prepare_attachment_for_js () {
370428 // Attachment without media.
371429 $ id = wp_insert_attachment (
@@ -3169,3 +3227,12 @@ public function shortcode( $attr, $url = '' ) {
31693227 return '[embed] ' ;
31703228 }
31713229}
3230+
3231+ /**
3232+ * Helper class for `test_oembed`.
3233+ */
3234+ class Test_oEmbed extends WP_oEmbed {
3235+ private function _fetch_with_format ( $ provider_url_with_args , $ format ) {
3236+ return $ provider_url_with_args ;
3237+ }
3238+ }
0 commit comments