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'); }