public function getPopularVideos($regionCode, $maxResults = 10, $part = ['id', 'snippet', 'contentDetails', 'player', 'statistics', 'status']) { $API_URL = $this->getApi('videos.list'); $params = array('chart' => 'mostPopular', 'part' => implode(', ', $part), 'regionCode' => $regionCode, 'maxResults' => $maxResults); $apiData = $this->api_get($API_URL, $params); return $this->decodeList($apiData); }
public function testGetPopularVideos() { $maxResult = rand(10, 40); $regionCode = 'us'; $response = $this->youtube->getPopularVideos($regionCode, $maxResult); $this->assertNotNull('response'); $this->assertEquals($maxResult, count($response)); $this->assertEquals('youtube#video', $response[0]->kind); $this->assertObjectHasAttribute('statistics', $response[0]); $this->assertObjectHasAttribute('status', $response[0]); $this->assertObjectHasAttribute('snippet', $response[0]); $this->assertObjectHasAttribute('contentDetails', $response[0]); }