Exemplo n.º 1
0
 public function let(NewsInterface $repository, NewsFactory $factory)
 {
     $article_to_save = new NewsEntity();
     $factory->newsEntity(array())->willReturn($article_to_save);
     $non_existing_article = new NewsEntity();
     $non_existing_article->setId('non_existing');
     $factory->newsEntity(array('name' => 'fails'))->willReturn($non_existing_article);
     $repository->getById(null)->willReturn(true);
     $repository->getById('non_existing')->willReturn(false);
     $repository->save(Argument::any())->willReturnArgument(0);
     $this->beConstructedWith($repository, $factory);
 }
Exemplo n.º 2
0
 public function save(NewsEntity $news)
 {
     $news_info = $news->getData();
     if (false !== $news->hasId() && null !== ($id = $news->getId())) {
         $news_info['_id'] = new MongoId($id);
     } else {
         $news_info['_id'] = new MongoId();
         $news->setId($news_info['_id']);
     }
     $news_info['pub_date'] = new MongoDate($news_info['pub_date']);
     $this->collection->save($news_info);
     return $news;
 }
Exemplo n.º 3
0
 public function it_should_be_possible_to_remove_given_conference()
 {
     $college = new NewsEntity();
     $college->setId('54312fd4c863c796148b458b');
     $this->remove($college)->shouldBe(true);
 }