public function testBuildAlbumSimplified() { $album = (object) ['id' => 'testid', 'name' => 'I am someone', 'uri' => 'nonense:test', 'href' => 'http://...']; $result = $this->valueObjectBuilder->buildAlbumSimplified($album, []); $this->assertEquals($album->id, $result->getId(), 'Album id should be set'); $this->assertEquals($album->name, $result->getName(), 'Album name should be set'); $this->assertEquals($album->uri, $result->getSpotifyUri(), 'Album uri should be set'); $this->assertEquals($album->href, $result->getSpotifyHref(), 'Album href 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; }