From 8c085018a13269ce3bf6cc148d535d238cacdb33 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 13 Apr 2021 11:02:08 +0100 Subject: [PATCH] Improves testing --- .../Validation/ValidationNotPwnedVerifierTest.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/Validation/ValidationNotPwnedVerifierTest.php b/tests/Validation/ValidationNotPwnedVerifierTest.php index d44e51f04928..782ccf7dddb5 100644 --- a/tests/Validation/ValidationNotPwnedVerifierTest.php +++ b/tests/Validation/ValidationNotPwnedVerifierTest.php @@ -39,16 +39,20 @@ public function testApiResponseGoesWrong() $httpFactory ->shouldReceive('withHeaders') + ->once() ->with(['Add-Padding' => true]) - ->andThrow($httpFactory); + ->andReturn($httpFactory); $httpFactory->shouldReceive('get') + ->once() ->andReturn($response); $response->shouldReceive('successful') + ->once() ->andReturn(true); $response->shouldReceive('body') + ->once() ->andReturn(''); $verifier = new NotPwnedVerifier($httpFactory); @@ -63,13 +67,16 @@ public function testApiGoesDown() $httpFactory ->shouldReceive('withHeaders') + ->once() ->with(['Add-Padding' => true]) - ->andThrow($httpFactory); + ->andReturn($httpFactory); $httpFactory->shouldReceive('get') + ->once() ->andReturn($response); $response->shouldReceive('successful') + ->once() ->andReturn(false); $verifier = new NotPwnedVerifier($httpFactory); @@ -92,11 +99,13 @@ public function testDnsDown() $httpFactory ->shouldReceive('withHeaders') + ->once() ->with(['Add-Padding' => true]) - ->andThrow($httpFactory); + ->andReturn($httpFactory); $httpFactory ->shouldReceive('get') + ->once() ->andThrow($exception); $verifier = new NotPwnedVerifier($httpFactory);