コード例 #1
0
ファイル: College.php プロジェクト: collegefb/collegefb
 public function save(CollegeEntity $college)
 {
     $college_info = $college->getData();
     if (false !== $college->hasId() && null !== ($id = $college->getId())) {
         $college_info['_id'] = new MongoId($id);
     } else {
         $college_info['_id'] = new MongoId();
         $college->setId($college_info['_id']);
     }
     $this->collection->save($college_info);
     return $college;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: CollegeSpec.php プロジェクト: collegefb/collegefb
 public function it_should_be_possible_to_remove_given_college()
 {
     $college = new CollegeEntity();
     $college->setId('54312fd4c863c796148b458b');
     $this->remove($college)->shouldBe(true);
 }