Beispiel #1
0
 public function testRemoveATrackFromThePlaylist()
 {
     $playlist = PlaylistBuilder::get()->withName('My playlist')->build();
     $playlist->addTrack(Track::create('id', 'My track'));
     $playlist->removeTrack(Track::create('id', 'My track'));
     $this->assertCount(0, $playlist->getTracks());
 }
Beispiel #2
0
 /**
  * Creates a valid Track domain object given a PPO.
  *
  * @param  stdClass $track The php plain object to convert.
  * @return Track
  * @throws \InvalidArgumentException If the object does not contain id and name.
  */
 public function buildTrack(\stdClass $track)
 {
     if (!isset($track->id) || !isset($track->name)) {
         throw new InvalidArgumentException('Id and name are mandatory for building the track object');
     }
     return Track::create($track->id, $track->name);
 }
 public function testSearchTrackReturnsAListOfTracks()
 {
     $track_list = new ArrayCollection(array(Track::create('track 1 id', 'Track 1'), Track::create('amazing track id', 'Amazing track')));
     $track_repository = $this->getMock('Naxhh\\PlayCool\\Domain\\Contract\\TrackRepository');
     $track_repository->expects($this->any())->method('getListByName')->will($this->returnValue($track_list));
     $command = new SearchTrackCommand('Amazing track');
     $use_case = new SearchTrackUseCase($track_repository);
     $track_list = $use_case->handle($command);
     $this->assertCount(2, $track_list);
     $this->assertInstanceOf('Naxhh\\Playcool\\Domain\\Entity\\Track', $track_list->get(1));
 }
Beispiel #4
0
 /**
  * Removes a track from the playlist.
  *
  * @param  Track $track The track to remove from the playlist.
  * @return void
  */
 public function removeTrack(Track $track)
 {
     $this->tracks->remove($track->getId());
 }
Beispiel #5
0
 public function transform(Track $track)
 {
     return array('id' => $track->getId(), 'name' => $track->getName());
 }