public function testSearchArtistReturnsAListOfAlbums()
 {
     $track_list = new ArrayCollection(array(Artist::create('id', 'Artist 1'), Artist::create('id2', 'Artist 2')));
     $repository = $this->getMock('Naxhh\\PlayCool\\Domain\\Contract\\ArtistRepository');
     $repository->expects($this->any())->method('getListByName')->will($this->returnValue($track_list));
     $command = new SearchArtistCommand('Search term');
     $use_case = new SearchArtistUseCase($repository);
     $artist_list = $use_case->handle($command);
     $this->assertCount(2, $artist_list);
     $this->assertInstanceOf('Naxhh\\Playcool\\Domain\\Entity\\Artist', $artist_list->get(1));
 }
Beispiel #2
0
 /**
  * Retrieves a list of artists that match the given name.
  *
  * @param  string $name The name to search for.
  * @return Domain\Entity\Artist[]
  */
 public function getListByName($name)
 {
     $result = $this->spotify_api->search($name);
     if (!isset($result->artists->items)) {
         return array();
     }
     $result = $result->artists->items;
     $artists = array();
     foreach ($result as $artist) {
         $artists[] = Artist::create($artist->id, $artist->name);
     }
     unset($result);
     return $artists;
 }
Beispiel #3
0
 public function includeAlbums(Artist $artist)
 {
     return $this->collection($artist->getAlbums(), new AlbumTransformer());
 }