예제 #1
0
 public function testSearchAlbumReturnsAListOfAlbums()
 {
     $track_list = new ArrayCollection(array(Album::create('id', 'Album 1'), Album::create('id2', 'Album 2')));
     $repository = $this->getMock('Naxhh\\PlayCool\\Domain\\Contract\\AlbumRepository');
     $repository->expects($this->any())->method('getListByName')->will($this->returnValue($track_list));
     $command = new SearchAlbumCommand('Search term');
     $use_case = new SearchAlbumUseCase($repository);
     $album_list = $use_case->handle($command);
     $this->assertCount(2, $album_list);
     $this->assertInstanceOf('Naxhh\\Playcool\\Domain\\Entity\\Album', $album_list->get(1));
 }
예제 #2
0
 /**
  * Retrieves the artist with the given identity.
  *
  * @param  ArtistIdentity $identity The identity of the artist to retrieve.
  * @return Domain\Entity\Artist
  * @throws Domain\Exception\ArtistNotFoundException If no artist has the requested identity.
  */
 public function get(ArtistIdentity $identity)
 {
     try {
         $artist_raw = $this->spotify_api->getArtist($identity->getId());
         $artist_albums = $this->spotify_api->getArtistAlbums($identity->getId());
         $artist = Artist::create($artist_raw->id, $artist_raw->name);
         foreach ($artist_albums->items as $album) {
             $artist->addAlbum(Album::create($album->id, $album->name));
         }
         return $artist;
     } catch (NotFoundException $e) {
         throw new ArtistNotFoundException();
     }
 }
예제 #3
0
 /**
  * Retrieves a list of albums that match the given name.
  *
  * @param  string $name The name to search for.
  * @return Domain\Entity\Album[]
  */
 public function getListByName($name)
 {
     $result = $this->spotify_api->search($name);
     if (!isset($result->albums->items)) {
         return array();
     }
     $result = $result->albums->items;
     $albums = array();
     foreach ($result as $artist) {
         $albums[] = Album::create($artist->id, $artist->name);
     }
     unset($result);
     return $albums;
 }
예제 #4
0
 public function includeTracks(Album $album)
 {
     return $this->collection($album->getTracks(), new TrackTransformer());
 }
예제 #5
0
파일: Artist.php 프로젝트: alexgt9/PlayCool
 /**
  * Removes a album from the artist.
  *
  * @param  album $album The album to remove.
  * @return void
  */
 public function removealbum(Album $album)
 {
     $this->albums->remove($album->getId());
 }