Beispiel #1
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);
 }
Beispiel #2
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());
 }
 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));
 }