httpClient = $this->prophesize(ClientInterface::class); $this->urlValidator = new UrlValidator($this->httpClient->reveal()); } /** @test */ public function exceptionIsThrownWhenUrlIsInvalid(): void { $request = $this->httpClient->request(Argument::cetera())->willThrow(ClientException::class); $request->shouldBeCalledOnce(); $this->expectException(InvalidUrlException::class); $this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar'); } /** @test */ public function expectedUrlIsCalledWhenTryingToVerify(): void { $expectedUrl = 'http://foobar.com'; $request = $this->httpClient->request( RequestMethodInterface::METHOD_GET, $expectedUrl, [RequestOptions::ALLOW_REDIRECTS => ['max' => 15]], )->willReturn(new Response()); $this->urlValidator->validateUrl($expectedUrl); $request->shouldHaveBeenCalledOnce(); } }