Index: tests/phpunit/tests/oembed.php
===================================================================
--- tests/phpunit/tests/oembed.php	(revision 0)
+++ tests/phpunit/tests/oembed.php	(working copy)
@@ -0,0 +1,567 @@
+<?php
+
+/**
+ * @group oembed
+ */
+class Tests_oEmbed extends WP_UnitTestCase {
+
+	/**
+	 * An HTTP API response.
+	 * 
+	 * @var array|WP_Error
+	 */
+	protected $http_response;
+
+	public function setUp() {
+		parent::setUp();
+
+		require_once ABSPATH . WPINC . '/class-oembed.php';
+		$this->oembed = _wp_oembed_get_object();
+	}
+
+	/**
+	 * Test the tests
+	 *
+	 * @ticket 32360
+	 *
+	 * @dataProvider oEmbedProviderData
+	 */
+	public function testOembedTestURLsMatch( $match, array $urls ) {
+
+		if ( empty( $urls ) ) {
+			$this->markTestIncomplete();
+		}
+
+		foreach ( $urls as $url ) {
+
+			$msg = sprintf( 'Test URL: %s', $url );
+
+			// Ensure the test URL is actually matched by the provider regex
+			if ( true === $this->oembed->providers[ $match ][1] ) {
+
+				$this->assertSame( 1, preg_match( $match, $url ), $msg );
+
+			} else {
+
+				// @TODO convert non-regex into regex and test
+
+				$this->markTestSkipped( $msg );
+
+			}
+
+		}
+
+	}
+
+	/**
+	 * @group external-oembed
+	 * @ticket 32360
+	 *
+	 * @dataProvider oEmbedProviderData
+	 */
+	public function testOembedProviderReturnsExpectedResponse( $match, array $urls ) {
+
+		if ( empty( $urls ) ) {
+			$this->markTestIncomplete();
+		}
+
+		$this->setup_http_hooks();
+
+		$test_args = array(
+			array(
+				'discover' => false,
+				'width'    => 500,
+				'height'   => 500,
+			),
+			// array(
+			// 	'discover' => false,
+			// 	'width'    => '_INVALID_',
+			// 	'height'   => '_INVALID_',
+			// ),
+		);
+
+		// @TODO consider testing every URL as http and https
+		// @TODO test schemes of URLs in response
+
+		foreach ( $urls as $url ) {
+
+			foreach ( $test_args as $args ) {
+
+				$msg = sprintf( "- Test URL: %s", $url );
+
+				$provider = $this->oembed->get_provider( $url, array(
+					'discover' => false,
+				) );
+				$this->assertNotFalse( $provider, $msg );
+
+				$data = $this->oembed->fetch( $provider, $url, $args );
+
+				$r = $this->http_response;
+
+				$msg .= sprintf( "\n- oEmbed URL: %s", $r['url'] );
+
+				// `WP_oEmbed::fetch()` only returns boolean false, so we need to hook into the HTTP API to get its error
+				if ( is_wp_error( $r['response'] ) ) {
+					$error_message = $r['response']->get_error_message();
+					if ( empty( $error_message ) ) {
+						$error_message = '- no message -';
+					}
+
+					$this->fail( sprintf( "%s (%s)\n%s", $error_message, $r['response']->get_error_code(), $msg ) );
+				}
+
+				$this->assertSame( 200, wp_remote_retrieve_response_code( $r['response'] ), $msg );
+
+				$query = parse_url( $r['url'], PHP_URL_QUERY );
+				parse_str( $query, $query_vars );
+
+				$this->assertArrayHasKey( 'maxheight', $query_vars, $msg );
+				$this->assertArrayHasKey( 'maxwidth', $query_vars, $msg );
+				$this->assertArrayHasKey( 'url', $query_vars, $msg );
+
+				// Check the `content-type` header is as expected based on the requested format
+				switch ( $query_vars['format'] ) {
+
+					case 'json':
+						$this->assertStringStartsWith( 'application/json', wp_remote_retrieve_header( $r['response'], 'content-type' ), $msg );
+						break;
+
+					case 'xml':
+						$this->assertStringStartsWith( 'text/xml', wp_remote_retrieve_header( $r['response'], 'content-type' ), $msg );
+						break;
+
+				}
+
+				$this->assertNotFalse( $data, $msg );
+
+				// Check for required response parameters
+				$this->assertObjectHasAttribute( 'type', $data, $msg );
+				$this->assertObjectHasAttribute( 'version', $data, $msg );
+				$this->assertEquals( '1.0', $data->version, $msg );
+
+				switch ( $data->type ) {
+
+					case 'photo':
+
+						// Check for required response parameters
+						$this->assertObjectHasAttribute( 'url', $data, $msg );
+						$this->assertObjectHasAttribute( 'width', $data, $msg );
+						$this->assertObjectHasAttribute( 'height', $data, $msg );
+
+						// Validate response parameters
+						$this->assertNotEmpty( $data->url, $msg );
+						$this->assertInternalType( 'string', $data->url, $msg );
+
+						break;
+
+					case 'video':
+
+						// Check for required response parameters
+						$this->assertObjectHasAttribute( 'html', $data, $msg );
+						$this->assertObjectHasAttribute( 'width', $data, $msg );
+						$this->assertObjectHasAttribute( 'height', $data, $msg );
+
+						// Validate response parameters
+						$this->assertNotEmpty( $data->html, $msg );
+						$this->assertInternalType( 'string', $data->html, $msg );
+
+						// Test for invalid data in response parameters
+						$this->assertNotContains( '_INVALID_', $data->html, $msg );
+
+						break;
+
+					case 'rich':
+
+						// Check for required response parameters
+						$this->assertObjectHasAttribute( 'html', $data, $msg );
+						$this->assertObjectHasAttribute( 'width', $data, $msg );
+						$this->assertObjectHasAttribute( 'height', $data, $msg );
+
+						// Validate response parameters
+						$this->assertNotEmpty( $data->html, $msg );
+						$this->assertInternalType( 'string', $data->html, $msg );
+
+						// Test for invalid data in response parameters
+						$this->assertNotContains( '_INVALID_', $data->html, $msg );
+
+						break;
+
+					case 'link':
+
+						// Check for required response parameters
+						$this->assertObjectHasAttribute( 'title', $data, $msg );
+
+						// Validate response parameters
+						$this->assertNotEmpty( $data->title, $msg );
+						$this->assertInternalType( 'string', $data->title, $msg );
+
+						break;
+
+					default:
+
+						$this->fail( sprintf( "Invalid value for the 'type' response parameter\n%s", $msg ) );
+
+						break;
+
+				}
+
+				if ( isset( $data->thumbnail_width ) ) {
+
+					// Validate response parameter
+					$this->assertTrue( is_numeric( $data->thumbnail_width ), $msg );
+					$this->assertLessThanOrEqual( intval( $query_vars['maxwidth'] ), $data->thumbnail_width, $msg );
+
+				}
+
+				if ( isset( $data->thumbnail_height ) ) {
+
+					// Validate response parameter
+					$this->assertTrue( is_numeric( $data->thumbnail_height ), $msg );
+					$this->assertLessThanOrEqual( intval( $query_vars['maxheight'] ), $data->thumbnail_height, $msg );
+
+				}
+
+				if ( isset( $data->width ) ) {
+
+					// Validate response parameter
+					$this->assertNotEmpty( $data->width, $msg );
+					$this->assertTrue( is_numeric( $data->width ), $msg );
+					$this->assertLessThanOrEqual( intval( $query_vars['maxwidth'] ), $data->width, $msg );
+
+				}
+
+				if ( isset( $data->height ) ) {
+
+					// Validate response parameter
+					$this->assertNotEmpty( $data->height, $msg );
+					$this->assertTrue( is_numeric( $data->height ), $msg );
+					$this->assertLessThanOrEqual( intval( $query_vars['maxheight'] ), $data->height, $msg );
+
+				}
+
+			}
+
+		}
+
+		$this->teardown_http_hooks();
+
+	}
+
+	/**
+	 * Test the tests
+	 *
+	 * @ticket 32360
+	 */
+	public function testOembedTestsCoverAllProviders() {
+
+		$tests     = wp_list_pluck( $this->oEmbedProviderData(), 0 );
+		$providers = array_keys( $this->oembed->providers );
+		$missing   = array_diff( $providers, $tests );
+
+		$this->assertEmpty( $missing, sprintf( "These oEmbed providers are not tested:\n- %s", implode( "\n- ", $missing ) ) );
+
+	}
+
+	/**
+	 * Test the tests
+	 *
+	 * @ticket 32360
+	 * 
+	 */
+	public function testOembedTestsAreAllUseful() {
+
+		$tests     = wp_list_pluck( $this->oEmbedProviderData(), 0 );
+		$providers = array_keys( $this->oembed->providers );
+		$useless   = array_diff( $tests, $providers );
+
+		$this->assertEmpty( $useless, sprintf( "These tests do not cover any oEmbed provider:\n- %s", implode( "\n- ", $useless ) ) );
+
+	}
+
+	/**
+	 * Data provider for our oEmbed tests
+	 *
+	 * @return array
+	 */
+	public function oEmbedProviderData() {
+		return array(
+			array(
+				'#http://((m|www)\.)?youtube\.com/watch.*#i',
+				array(
+					'http://youtube.com/watch?v=zdtD19tXX30',
+					'http://m.youtube.com/watch?v=QkP_rOCBrpY',
+				),
+			),
+			array(
+				'#https://((m|www)\.)?youtube\.com/watch.*#i',
+				array(
+					'https://www.youtube.com/watch?v=bDRQRdFaFEo',
+					'https://m.youtube.com/watch?v=yfUflij74P4',
+				),
+			),
+			array(
+				'#http://((m|www)\.)?youtube\.com/playlist.*#i',
+				array(
+					'http://www.youtube.com/playlist?list=PLC7D2959C96B8D27B',
+					'http://m.youtube.com/playlist?list=PLEC422D53B7588DC7',
+				),
+			),
+			array(
+				'#https://((m|www)\.)?youtube\.com/playlist.*#i',
+				array(
+					'https://youtube.com/playlist?list=PL93B9F6B77FBB0160',
+					'https://m.youtube.com/playlist?list=PL1AC02C68F976A10F',
+				),
+			),
+			array(
+				'#http://youtu\.be/.*#i',
+				array(
+					'http://youtu.be/nfWlot6h_JM?list=PLirAqAtl_h2r5g8xGajEwdXd3x1sZh8hC',
+				),
+			),
+			array(
+				'#https://youtu\.be/.*#i',
+				array(
+					'https://youtu.be/U8SYRUYfs_I',
+				),
+			),
+			array(
+				'#https?://(.+\.)?vimeo\.com/.*#i',
+				array(
+					'https://vimeo.com/12339198',
+				),
+			),
+			array(
+				'#https?://(www\.)?dailymotion\.com/.*#i',
+				array(
+					'http://www.dailymotion.com/video/x27bwvb_how-to-wake-up-better_news',
+				),
+			),
+			array(
+				'http://dai.ly/*',
+				array(
+					'http://dai.ly/x33exze',
+				),
+			),
+			array(
+				'#https?://(www\.)?flickr\.com/.*#i',
+				array(
+					'http://www.flickr.com/photos/bon/14004280667/',
+				),
+			),
+			array(
+				'#https?://flic\.kr/.*#i',
+				array(
+					'https://flic.kr/p/6BFrbQ',
+				),
+			),
+			array(
+				'#https?://(.+\.)?smugmug\.com/.*#i',
+				array(
+					'https://fotoeffects.smugmug.com/Daily-shots-for-the-dailies/Dailies/6928550_9gMRmv/476011624_WhGWpts#!i=476011624&k=WhGWpts',
+				),
+			),
+			array(
+				'#https?://(www\.)?hulu\.com/watch/.*#i',
+				array(
+					'http://www.hulu.com/watch/807443',
+				),
+			),
+			array(
+				'http://i*.photobucket.com/albums/*',
+				array(
+					'http://i415.photobucket.com/albums/pp236/Keefers_/Keffers%20Animals/funny-cats-a10.jpg',
+				),
+			),
+			array(
+				'http://gi*.photobucket.com/groups/*',
+				array(
+					// ??
+				),
+			),
+			array(
+				'#https?://(www\.)?scribd\.com/doc/.*#i',
+				array(
+					'http://www.scribd.com/doc/110799637/Synthesis-of-Knowledge-Effects-of-Fire-and-Thinning-Treatments-on-Understory-Vegetation-in-Dry-U-S-Forests',
+				),
+			),
+			array(
+				'#https?://wordpress.tv/.*#i',
+				array(
+					'http://wordpress.tv/2015/08/18/billie/',
+				),
+			),
+			array(
+				'#https?://(.+\.)?polldaddy\.com/.*#i',
+				array(
+					'https://camikaos.polldaddy.com/s/2015-wordpress-community-summit-dates',
+				),
+			),
+			array(
+				'#https?://poll\.fm/.*#i',
+				array(
+					// ??
+				),
+			),
+			array(
+				'#https?://(www\.)?funnyordie\.com/videos/.*#i',
+				array(
+					'http://www.funnyordie.com/videos/e5ef40bf2a/cute-overload',
+				),
+			),
+			array(
+				'#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i',
+				array(
+					'https://twitter.com/WordPress/status/633718182335922177',
+				),
+			),
+			array(
+				'#https?://vine.co/v/.*#i',
+				array(
+					'https://vine.co/v/OjiLun5LuQ6',
+				),
+			),
+			array(
+				'#https?://(www\.)?soundcloud\.com/.*#i',
+				array(
+					'https://soundcloud.com/steveaoki/kid-cudi-pursuit-of-happiness',
+				),
+			),
+			array(
+				'#https?://(.+?\.)?slideshare\.net/.*#i',
+				array(
+					'http://www.slideshare.net/haraldf/business-quotes-for-2011',
+				),
+			),
+			array(
+				'#https?://instagr(\.am|am\.com)/p/.*#i',
+				array(
+					'https://instagram.com/p/68WqXbTcfl/',
+					'http://instagr.am/p/MRM3HQy6kh/',
+				),
+			),
+			array(
+				'#https?://(www\.)?rdio\.com/.*#i',
+				array(
+					'https://www.rdio.com/artist/Wolf_Alice/album/My_Love_Is_Cool_1/',
+				),
+			),
+			array(
+				'#https?://rd\.io/x/.*#i',
+				array(
+					'http://rd.io/x/Rl4F5xw-bsh5/',
+				),
+			),
+			array(
+				'#https?://(open|play)\.spotify\.com/.*#i',
+				array(
+					'https://open.spotify.com/track/2i1KmyEXN3pNLwdxAWSGcg',
+				),
+			),
+			array(
+				'#https?://(.+\.)?imgur\.com/.*#i',
+				array(
+					'https://imgur.com/a/WdJim',
+					'http://i.imgur.com/mbOPX2L.png',
+				),
+			),
+			array(
+				'#https?://(www\.)?meetu(\.ps|p\.com)/.*#i',
+				array(
+					'https://www.meetup.com/WordPress-Amsterdam/events/224346396/',
+					'http://meetu.ps/2L533w',
+				),
+			),
+			array(
+				'#https?://(www\.)?issuu\.com/.+/docs/.+#i',
+				array(
+					'http://issuu.com/vmagazine/docs/v87',
+				),
+			),
+			array(
+				'#https?://(www\.)?collegehumor\.com/video/.*#i',
+				array(
+					'http://www.collegehumor.com/video/2862877/jake-and-amir-math',
+				),
+			),
+			array(
+				'#https?://(www\.)?mixcloud\.com/.*#i',
+				array(
+					'http://www.mixcloud.com/8_8s/disclosurefriends/',
+				),
+			),
+			array(
+				'#https?://(www\.|embed\.)?ted\.com/talks/.*#i',
+				array(
+					'http://www.ted.com/talks/rodney_mullen_pop_an_ollie_and_innovate',
+				),
+			),
+			array(
+				'#https?://(www\.)?(animoto|video214)\.com/play/.*#i',
+				array(
+					'https://animoto.com/play/MlRRgXHhoT8gOZyHanM6TA',
+				),
+			),
+			array(
+				'#https?://(.+)\.tumblr\.com/post/.*#i',
+				array(
+					'http://yahoo.tumblr.com/post/50902111638/tumblr-yahoo',
+				),
+			),
+			array(
+				'#https?://(www\.)?kickstarter\.com/projects/.*#i',
+				array(
+					'https://www.kickstarter.com/projects/zackdangerbrown/potato-salad',
+				),
+			),
+			array(
+				'#https?://kck\.st/.*#i',
+				array(
+					'http://kck.st/1ukxHcx',
+				),
+			),
+			array(
+				'#https?://cloudup\.com/.*#i',
+				array(
+					'https://cloudup.com/cWX2Bi5DmfJ',
+				),
+			),
+			array(
+				'#https?://(www\.)?reverbnation\.com/.*#i',
+				array(
+					'http://www.reverbnation.com/coralbones/song/18668300-rising-sand',
+					'https://www.reverbnation.com/coralbones',
+				),
+			),
+		);
+	}
+
+	protected function setup_http_hooks() {
+		add_action( 'http_api_debug', array( $this, 'action_http_api_debug' ), 99, 5 );
+	}
+
+	protected function teardown_http_hooks() {
+		remove_action( 'http_api_debug', array( $this, 'action_http_api_debug' ), 99 );
+		$this->http_response = null;
+	}
+
+	/**
+	 * Debugging action for the HTTP API response.
+	 * 
+	 * @param array|WP_Error $response The HTTP response.
+	 * @param string         $action   The debug action.
+	 * @param string         $class    The HTTP transport class name.
+	 * @param array          $args     HTTP request arguments.
+	 * @param string         $url      The request URL.
+	 */
+	public function action_http_api_debug( $response, $action, $class, $args, $url ) {
+
+		if ( 'response' !== $action ) {
+			return;
+		}
+
+		$this->http_response = compact( 'response', 'args', 'url' );
+
+	}
+
+}
Index: tests/phpunit/includes/bootstrap.php
===================================================================
--- tests/phpunit/includes/bootstrap.php	(revision 33800)
+++ tests/phpunit/includes/bootstrap.php	(working copy)
@@ -133,6 +133,7 @@
 			'ajax' => true,
 			'ms-files' => true,
 			'external-http' => true,
+			'external-oembed' => true,
 		);
 
 		foreach ( $options as $option ) {
