Skip to content

Commit ed0258a

Browse files
committed
ADDED TEST CASES for setAction
1 parent 65cce9d commit ed0258a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/ScoreTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,40 @@ public function testScore8()
318318
$response = $service->setScore(0.8)->verifyResponse('test response');
319319
$this->assertEquals(false, $response->isSuccess());
320320
}
321+
322+
323+
324+
public function testScore12()
325+
{
326+
// Create a stub for the SomeClass class.
327+
$configStub = $this->createMock(ReCaptchaConfigV3::class);
328+
329+
// Configure the stub.
330+
$configStub->method('isServiceEnabled')
331+
->willReturn(true);
332+
333+
$configStub->method('isScoreEnabled')
334+
->willReturn(true);
335+
336+
$configStub->method('getSetting')
337+
->willReturn([
338+
[
339+
'action' => 'contact_us',
340+
'threshold' => 0.6,
341+
'score_comparision' => true,
342+
],
343+
]);
344+
345+
$testJson = '{ "success": true, "challenge_ts": "2018-12-25T03:35:32Z", "hostname": "ryandeng.test", "score": 0.7, "action": "contact_us" }';
346+
347+
$clientStub = $this->createMock(GuzzleRequestClient::class);
348+
$clientStub->method('post')
349+
->willReturn($testJson);
350+
351+
$_service = new GoogleReCaptchaV3Service($configStub, $clientStub);
352+
$service = new GoogleReCaptchaV3($_service);
353+
354+
$response = $service->setScore(0.8)->verifyResponse('test response');
355+
$this->assertEquals(false, $response->isSuccess());
356+
}
321357
}

0 commit comments

Comments
 (0)