public function testGetSongsFromSpotifyIgnoresEmpty() { $song = new Song(); $song->setTitle('Foo song')->setArtist('Bar'); $song2 = new Song(); $song2->setTitle('Baz song')->setArtist('Qux'); $spotifyTrack = new Track(); $spotifyTrack->setId('aoeu')->setSpotifyUri('spotify:track:something'); // First track found $this->trackFinder->expects($this->at(0))->method('findTrack')->willReturn($spotifyTrack); // 2nd track not found with restrictive search $this->trackFinder->expects($this->at(1))->method('findTrack')->willThrowException(NoTracksFoundException::emptyResult()); // 2nd track not found with loose search either $this->trackFinder->expects($this->at(2))->method('findTrack')->willThrowException(NoTracksFoundException::emptyResult()); $result = $this->trackConverter->getSongsFromSpotify([$song, $song2], false); $this->assertCount(1, $result, 'Only 1 track should be returned'); }
/** * Get the search query to send to spotify from song data, but don't specify artist & track * * @param Song $song * * @return string */ protected function getLooseSearchTermFromSongObject(Song $song) : string { return "{$this->removeUnnecessaryCharacters($song->getArtist())} {$this->removeUnnecessaryCharacters($song->getTitle())}"; }