function it_creates_url_model_from_create_url_request(UrlRepository $repository, UrlFactory $factory, Url $url) { $request = new CreateUrlRequest('http://google'); $factory->createUrl($request->getUrl())->shouldBecalled()->willReturn($url); $repository->save($url)->shouldBeCalled(); $this->beConstructedWith($repository, $factory); $this->execute($request)->shouldReturn($url); }
public function execute(CreateUrlRequest $request) { $url = $this->factory->createUrl($request->getUrl()); $this->repository->save($url); return $url; }