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);
 }
Exemple #2
0
 public function let(NewsInterface $repository, NewsFactory $factory)
 {
     $news_to_save = new NewsEntity();
     $factory->newsEntity(array())->willReturn($news_to_save);
     $news_to_save_that_fails = new NewsEntity();
     $news_to_save_that_fails->setLink('fails');
     $factory->newsEntity(array('link' => 'fails'))->willReturn($news_to_save_that_fails);
     $repository->getByLink(null)->willReturn(false);
     $repository->getByLink('fails')->willReturn(false);
     $repository->save($news_to_save)->willReturnArgument(0);
     $this->beConstructedWith($repository, $factory);
 }