@@ -46,7 +46,7 @@ public function setUp(): void
4646 ->setErrorsOn200 (false )
4747 ->setClient ($ this ->vonageClient ->reveal ())
4848 ->setAuthHandler ([new Client \Credentials \Handler \BasicHandler (), new Client \Credentials \Handler \KeypairHandler ()])
49- ->setBaseUrl ('https://api.nexmo.com/v2/verify/ ' );
49+ ->setBaseUrl ('https://api.nexmo.com/v2/verify ' );
5050
5151 $ this ->verify2Client = new Verify2Client ($ this ->api );
5252 }
@@ -93,11 +93,12 @@ public function testCanRequestSMS(): void
9393 $ uri = $ request ->getUri ();
9494 $ uriString = $ uri ->__toString ();
9595 $ this ->assertEquals (
96- 'https://api.nexmo.com/v2/verify/ ' ,
96+ 'https://api.nexmo.com/v2/verify ' ,
9797 $ uriString
9898 );
9999
100100 $ this ->assertRequestJsonBodyContains ('locale ' , 'en-us ' , $ request );
101+ $ this ->assertRequestJsonBodyContains ('fraud_check ' , true , $ request );
101102 $ this ->assertRequestJsonBodyContains ('channel_timeout ' , 300 , $ request );
102103 $ this ->assertRequestJsonBodyContains ('client_ref ' , $ payload ['client_ref ' ], $ request );
103104 $ this ->assertRequestJsonBodyContains ('code_length ' , 4 , $ request );
@@ -115,6 +116,29 @@ public function testCanRequestSMS(): void
115116 $ this ->assertArrayHasKey ('request_id ' , $ result );
116117 }
117118
119+ public function testCanBypassFraudCheck (): void
120+ {
121+ $ payload = [
122+ 'to ' => '07785254785 ' ,
123+ 'client_ref ' => 'my-verification ' ,
124+ 'brand ' => 'my-brand ' ,
125+ ];
126+
127+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
128+ $ smsVerification ->setFraudCheck (false );
129+
130+ $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
131+ $ this ->assertRequestJsonBodyContains ('fraud_check ' , false , $ request );
132+
133+ return true ;
134+ }))->willReturn ($ this ->getResponse ('verify-request-success ' , 202 ));
135+
136+ $ result = $ this ->verify2Client ->startVerification ($ smsVerification );
137+
138+ $ this ->assertIsArray ($ result );
139+ $ this ->assertArrayHasKey ('request_id ' , $ result );
140+ }
141+
118142 /**
119143 * @dataProvider localeProvider
120144 */
@@ -591,6 +615,28 @@ public function testCheckHandlesThrottle(): void
591615 $ result = $ this ->verify2Client ->check ('c11236f4-00bf-4b89-84ba-88b25df97315 ' , '24525 ' );
592616 }
593617
618+ public function testWillCancelVerification (): void
619+ {
620+ $ requestId = 'c11236f4-00bf-4b89-84ba-88b25df97315 ' ;
621+
622+ $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
623+ $ uri = $ request ->getUri ();
624+ $ uriString = $ uri ->__toString ();
625+ $ this ->assertEquals (
626+ 'https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315 ' ,
627+ $ uriString
628+ );
629+
630+ $ this ->assertEquals ('DELETE ' , $ request ->getMethod ());
631+
632+ return true ;
633+ }))->willReturn ($ this ->getResponse ('verify-cancel-success ' , 204 ));
634+
635+ $ result = $ this ->verify2Client ->cancelRequest ($ requestId );
636+
637+ $ this ->assertTrue ($ result );
638+ }
639+
594640 /**
595641 * This method gets the fixtures and wraps them in a Response object to mock the API
596642 */
0 commit comments