public function testBuildImages() { $image1 = (object) ['width' => 101, 'height' => 102, 'url' => 'http://example.tld/test.png']; $image2 = clone $image1; $result = $this->valueObjectBuilder->buildImages([$image1, $image2]); $this->assertCount(2, $result, 'Number of result should equal number of inputted images'); $this->assertEquals($image1->height, $result[0]->getHeight(), 'Album image height should be set'); $this->assertEquals($image1->width, $result[0]->getWidth(), 'Album image width should be set'); $this->assertEquals($image1->url, $result[0]->getUrl(), 'Album image url should be set'); }
/** * Search for a track and build the response objects * * @param string $string * * @return Track */ public function findTrack(string $string) { $result = $this->spotifyWebApi->search($string, 'track'); if (count($result->tracks->items) === 0) { throw NoTracksFoundException::emptyResult(); } $firstItem = $result->tracks->items[0]; $images = $this->valueObjectBuilder->buildImages($firstItem->album->images); $album = $this->valueObjectBuilder->buildAlbumSimplified($firstItem->album, $images); $artists = $this->valueObjectBuilder->buildArtistsSimplified($firstItem->artists); $track = $this->valueObjectBuilder->buildTrack($firstItem, $album, $artists); return $track; }