public function let(CollegeInterface $repository, CollegeFactory $factory) { $college_to_save = new CollegeEntity(); $factory->collegeEntity(array())->willReturn($college_to_save); $non_existing_college = new CollegeEntity(); $non_existing_college->setId('non_existing'); $factory->collegeEntity(array('name' => 'fails'))->willReturn($non_existing_college); $repository->getById(null)->willReturn(true); $repository->getById('non_existing')->willReturn(false); $repository->save(Argument::any())->willReturnArgument(0); $this->beConstructedWith($repository, $factory); }
public function let(CollegeInterface $repository, CollegeFactory $factory) { $college_to_save = new CollegeEntity(); $factory->collegeEntity(array())->willReturn($college_to_save); $college_to_save_that_fails = new CollegeEntity(); $college_to_save_that_fails->setName('Test'); $college_to_save_that_fails->setNickname('Test'); $factory->collegeEntity(array('name' => 'fails'))->willReturn($college_to_save_that_fails); $college_saved = new CollegeEntity(); $college_saved->setName('Test'); $college_saved->setNickname('Test'); $repository->getByName(Argument::any())->willReturn($college_saved); $repository->save($college_to_save)->willReturnArgument(0); $this->beConstructedWith($repository, $factory); }
public function remove(CollegeEntity $college) { $id = $college->getId(); return !empty($id) ? $this->collection->remove(array('_id' => new MongoId($id))) : null; }
public function it_should_be_possible_to_remove_given_college() { $college = new CollegeEntity(); $college->setId('54312fd4c863c796148b458b'); $this->remove($college)->shouldBe(true); }