/** * @param $domainName * @return Response */ public function make($domainName) { $url = $this->requestUrlGenerator->generate($domainName); $response = $this->client->get($url); $this->requestValidator->validate($response); return $this->respond($response); }
function it_makes_valid_requests_to_the_moz_api(RequestUrl $requestUrlGenerator, Client $client, ResponseValidator $responseValidator, GuzzleMock $guzzleMock) { $requestUrlGenerator->generate('sunet.se')->shouldBeCalled()->willReturn('foo'); $dummy = '{"foo": "bar"}'; $guzzleMock->getBody()->shouldBeCalled()->willReturn($guzzleMock); $guzzleMock->__toString()->shouldBeCalled()->willReturn($dummy); $client->get('foo')->shouldBeCalled()->willReturn($guzzleMock); $responseValidator->validate($dummy)->shouldBeCalled(); $this->make('sunet.se')->shouldBeAnInstanceOf('SeoMoz\\Response'); }