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');
 }
 /**
  * Gets a song from Spotify based on the data from SR, or returns track objects with the known values
  *
  * @param Song $song
  *
  * @return Track
  */
 public function getSongFromSpotify(Song $song) : Track
 {
     try {
         $track = $this->spotifyTrackFinder->findTrack($this->getSearchTermFromSongObject($song));
     } catch (NoTracksFoundException $e) {
         try {
             $track = $this->spotifyTrackFinder->findTrack($this->getLooseSearchTermFromSongObject($song));
         } catch (NoTracksFoundException $e) {
             // Set to default
             $artist = new ArtistSimplified();
             $artist->setName($song->getArtist());
             $track = new Track();
             $track->setName($song->getTitle())->setArtists([$artist]);
         }
     }
     return $track;
 }