Index: tests/phpunit/tests/wporg-plugin-api.php
===================================================================
--- tests/phpunit/tests/wporg-plugin-api.php	(revision 0)
+++ tests/phpunit/tests/wporg-plugin-api.php	(working copy)
@@ -0,0 +1,166 @@
+<?php
+
+require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
+
+/**
+ *
+ * @group plugins-api
+ */
+class Tests_Plugins_API extends WP_UnitTestCase {
+
+	public function setUp() {
+		parent::setup();
+	}
+
+	function test_wporg_plugin_api_serialize_php() {
+		$response    = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' => array(
+			'action' => 'plugin_information',
+			'timeout' => 15,
+			'request' => serialize( (object) array( 'slug' => 'jetpack' ) ),
+		) ) );
+		$plugin_info = maybe_unserialize( wp_remote_retrieve_body( $response ) );
+
+		$this->_check_response_attributes( $plugin_info );
+	}
+
+	function test_wporg_plugin_api_serialize_php_get() {
+		$response    = wp_remote_get( 'http://api.wordpress.org/plugins/info/1.0/jetpack' );
+		$plugin_info = maybe_unserialize( wp_remote_retrieve_body( $response ) );
+
+		$this->_check_response_attributes( $plugin_info );
+	}
+
+	function test_wporg_plugin_api_json() {
+		$response    = wp_remote_get( 'http://api.wordpress.org/plugins/info/1.0/jetpack.json' );
+		$plugin_info = (object) json_decode( wp_remote_retrieve_body( $response ), true );
+
+		$this->_check_response_attributes( $plugin_info );
+	}
+
+	function test_plugins_api_function_action_plugin_information() {
+		$plugin_info = plugins_api( 'plugin_information', array( 'slug' => 'jetpack' ) );
+
+		$this->_check_response_attributes( $plugin_info );
+	}
+
+	function test_plugins_api_function_action_query_plugins() {
+		$plugin_query = plugins_api( 'query_plugins', array( 'search' => 'hello' ) );
+
+		// Info.
+		$this->assertObjectHasAttribute( 'info', $plugin_query, 'Info exists' );
+		$info = $plugin_query->info;
+
+		$this->assertArrayHasKey( 'page', $info, 'Page exists' );
+		$this->assertArrayHasKey( 'pages', $info, 'Pages exists' );
+		$this->assertArrayHasKey( 'results', $info, 'Results exists' );
+
+		// Plugins.
+		$this->assertObjectHasAttribute( 'plugins', $plugin_query, 'Plugins exists' );
+		$this->assertAttributeInternalType( 'array', 'plugins', $plugin_query, 'Plugins should be an array' );
+
+		$plugin_info = $plugin_query->plugins[0];
+		$this->assertObjectHasAttribute( 'name', $plugin_info, 'Name exists' );
+		$this->assertObjectHasAttribute( 'slug', $plugin_info, 'Slug exits' );
+		$this->assertObjectHasAttribute( 'version', $plugin_info, 'Version exists' );
+		$this->assertObjectHasAttribute( 'author', $plugin_info, 'Author exists' );
+		$this->assertObjectHasAttribute( 'author_profile', $plugin_info, 'Author Profile exists' );
+		$this->assertObjectHasAttribute( 'contributors', $plugin_info, 'Contributors exists' );
+		$this->assertAttributeInternalType( 'array', 'contributors', $plugin_info, 'Contributors should be an array' );
+		$this->assertObjectHasAttribute( 'requires', $plugin_info, 'Requires exists' );
+		$this->assertObjectHasAttribute( 'tested', $plugin_info, 'Tested exists' );
+		$this->assertObjectHasAttribute( 'compatibility', $plugin_info, 'Compatibility exists' );
+		$this->assertAttributeInternalType( 'array', 'compatibility', $plugin_info, 'Compatibility should be an array' );
+
+		// Ratings.
+		$this->assertObjectHasAttribute( 'rating', $plugin_info, 'Rating exists' );
+		$this->assertObjectHasAttribute( 'ratings', $plugin_info, 'Ratings exists' );
+		$this->assertAttributeInternalType( 'array', 'ratings', $plugin_info, 'Ratings should be an array' );
+		$this->assertArrayHasKey( '1', $plugin_info->ratings, 'Rating should have an attribute of 1' );
+		$this->assertArrayHasKey( '2', $plugin_info->ratings, 'Rating should have an attribute of 2' );
+		$this->assertArrayHasKey( '3', $plugin_info->ratings, 'Rating should have an attribute of 3' );
+		$this->assertArrayHasKey( '4', $plugin_info->ratings, 'Rating should have an attribute of 4' );
+		$this->assertArrayHasKey( '5', $plugin_info->ratings, 'Rating should have an attribute of 5' );
+		$this->assertObjectHasAttribute( 'num_ratings', $plugin_info, 'Num ratings exists' );
+		$this->assertTrue( is_numeric( $plugin_info->num_ratings ), 'Num ratings are numeric' );
+
+
+		$this->assertObjectHasAttribute( 'homepage', $plugin_info, 'Homepage exists' );
+		$this->assertObjectHasAttribute( 'description', $plugin_info, 'Description exists' );
+		$this->assertObjectHasAttribute( 'short_description', $plugin_info, 'Short Description exists' );
+	}
+
+	function test_plugins_api_function_action_hot_categories() {
+		$plugin_query_hot_categories = plugins_api( 'hot_categories' );
+
+		$this->assertInternalType( 'array', $plugin_query_hot_categories, 'Response array is array' );
+		foreach ( $plugin_query_hot_categories as $hot_category => $category_array ) {
+			$this->assertInternalType( 'array', $category_array, 'Category array is array' );
+			$this->assertArrayHasKey( 'name', $category_array, 'Name exists' );
+			$this->assertArrayHasKey( 'slug', $category_array, 'Slug exists' );
+
+			// Only check the first result.
+			break;
+		}
+	}
+
+	function test_plugins_api_function_action_hot_tags() {
+		$plugin_query_hot_tags = plugins_api( 'hot_tags' );
+
+		$this->assertInternalType( 'array', $plugin_query_hot_tags, 'Response array is array' );
+		foreach ( $plugin_query_hot_tags as $hot_tag => $tag_array ) {
+			$this->assertInternalType( 'array', $tag_array, 'Tag array is array' );
+			$this->assertArrayHasKey( 'name', $tag_array, 'Name exists' );
+			$this->assertArrayHasKey( 'slug', $tag_array, 'Slug exists' );
+			$this->assertArrayHasKey( 'count', $tag_array, 'Count exists' );
+
+			// Only check the first result.
+			break;
+		}
+	}
+
+	function _check_response_attributes( $plugin_info ) {
+		$this->assertObjectHasAttribute( 'name', $plugin_info, 'Name exists' );
+		$this->assertObjectHasAttribute( 'slug', $plugin_info, 'Slug exits' );
+		$this->assertObjectHasAttribute( 'version', $plugin_info, 'Version exists' );
+		$this->assertObjectHasAttribute( 'author', $plugin_info, 'Author exists' );
+		$this->assertObjectHasAttribute( 'author_profile', $plugin_info, 'Author Profile exists' );
+		$this->assertObjectHasAttribute( 'contributors', $plugin_info, 'Contributors exists' );
+		$this->assertAttributeInternalType( 'array', 'contributors', $plugin_info, 'Contributors should be an array' );
+		$this->assertObjectHasAttribute( 'requires', $plugin_info, 'Requires exists' );
+		$this->assertObjectHasAttribute( 'tested', $plugin_info, 'Tested exists' );
+		$this->assertObjectHasAttribute( 'compatibility', $plugin_info, 'Compatibility exists' );
+		$this->assertAttributeInternalType( 'array', 'compatibility', $plugin_info, 'Compatibility should be an array' );
+
+		// Ratings.
+		$this->assertObjectHasAttribute( 'rating', $plugin_info, 'Rating exists' );
+		$this->assertObjectHasAttribute( 'ratings', $plugin_info, 'Ratings exists' );
+		$this->assertAttributeInternalType( 'array', 'ratings', $plugin_info, 'Ratings should be an array' );
+		$this->assertArrayHasKey( '1', $plugin_info->ratings, 'Rating should have an attribute of 1' );
+		$this->assertArrayHasKey( '2', $plugin_info->ratings, 'Rating should have an attribute of 2' );
+		$this->assertArrayHasKey( '3', $plugin_info->ratings, 'Rating should have an attribute of 3' );
+		$this->assertArrayHasKey( '4', $plugin_info->ratings, 'Rating should have an attribute of 4' );
+		$this->assertArrayHasKey( '5', $plugin_info->ratings, 'Rating should have an attribute of 5' );
+		$this->assertObjectHasAttribute( 'num_ratings', $plugin_info, 'Num ratings exists' );
+		$this->assertTrue( is_numeric( $plugin_info->num_ratings ), 'Num ratings are numeric' );
+
+		// Downloaded.
+		$this->assertObjectHasAttribute( 'downloaded', $plugin_info, 'Downloaded exists' );
+		$this->assertTrue( is_numeric( $plugin_info->downloaded ), 'Downloaded count is numeric' );
+
+		$this->assertObjectHasAttribute( 'last_updated', $plugin_info, 'last_updated exists' );
+		$this->assertObjectHasAttribute( 'added', $plugin_info, 'Added exists' );
+		$this->assertObjectHasAttribute( 'homepage', $plugin_info, 'Homepage exists' );
+		$this->assertObjectHasAttribute( 'sections', $plugin_info, 'Sections Exists' );
+		$this->assertAttributeInternalType( 'array', 'sections', $plugin_info, 'Sections should be an array' );
+
+		// Download link.
+		$this->assertObjectHasAttribute( 'download_link', $plugin_info, 'Download Link exists' );
+
+		// Donate link.
+		$this->assertObjectHasAttribute( 'donate_link', $plugin_info, 'Donate link exists' );
+
+		// Tags.
+		$this->assertObjectHasAttribute( 'tags', $plugin_info, 'Tags exists' );
+		$this->assertAttributeInternalType( 'array', 'tags', $plugin_info, 'Tags should be an array' );
+	}
+}
