Ejemplo n.º 1
0
 public function let(GameInterface $repository, GameFactory $factory)
 {
     $game_to_save = new GameEntity();
     $factory->gameEntity(array())->willReturn($game_to_save);
     $non_existing_game = new GameEntity();
     $non_existing_game->setId('non_existing');
     $factory->gameEntity(array('home_team' => 'fails'))->willReturn($non_existing_game);
     $repository->getById(null)->willReturn(true);
     $repository->getById('non_existing')->willReturn(false);
     $repository->save(Argument::any())->willReturnArgument(0);
     $this->beConstructedWith($repository, $factory);
 }
Ejemplo n.º 2
0
 public function let(GameInterface $repository, GameFactory $factory)
 {
     $game_to_save = new GameEntity();
     $game_to_save->setDate(1);
     $factory->gameEntity(array())->willReturn($game_to_save);
     $game_to_save_that_fails = new GameEntity();
     $factory->gameEntity(array('home_team' => 'fails'))->willReturn($game_to_save_that_fails);
     $game_saved = new GameEntity();
     $repository->getById(Argument::any())->willReturn($game_saved);
     $repository->getByDateAndTeams(1, null, null)->willReturn(false);
     $repository->getByDateAndTeams(null, null, null)->willReturn(true);
     $repository->save($game_to_save)->willReturnArgument(0);
     $this->beConstructedWith($repository, $factory);
 }
Ejemplo n.º 3
0
 public function it_should_be_possible_to_remove_given_game()
 {
     $game = new GameEntity();
     $game->setId('54312fd4c863c796148b458b');
     $this->remove($game)->shouldBe(true);
 }
Ejemplo n.º 4
0
 public function remove(GameEntity $game)
 {
     $id = $game->getId();
     return !empty($id) ? $this->collection->remove(array('_id' => new MongoId($id))) : null;
 }