@@ -64,7 +64,8 @@ public function testSetsRequestAuthCorrectly(): void
6464 'brand ' => 'my-brand ' ,
6565 ];
6666
67- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
67+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
68+ $ smsVerification ->setClientRef ($ payload ['client_ref ' ]);
6869
6970 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
7071 $ this ->assertEquals (
@@ -85,7 +86,8 @@ public function testCanRequestSMS(): void
8586 'brand ' => 'my-brand ' ,
8687 ];
8788
88- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
89+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
90+ $ smsVerification ->setClientRef ($ payload ['client_ref ' ]);
8991
9092 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
9193 $ uri = $ request ->getUri ();
@@ -131,7 +133,8 @@ public function testCannotRequestSMSWithInvalidLocale($locale, $valid): void
131133 'locale ' => $ verificationLocale ,
132134 ];
133135
134- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ], $ payload ['locale ' ]);
136+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['locale ' ]);
137+ $ smsVerification ->setClientRef ($ payload ['client_ref ' ]);
135138
136139 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
137140 $ this ->assertEquals (
@@ -167,7 +170,8 @@ public function testTimeoutParsesCorrectly($timeout, $valid): void
167170 'timeout ' => $ timeout
168171 ];
169172
170- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
173+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
174+ $ smsVerification ->setClientRef ($ payload ['client_ref ' ]);
171175 $ smsVerification ->setTimeout ($ timeout );
172176
173177 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
@@ -203,7 +207,8 @@ public function testCannotRequestSMSWithInvalidCodeLength($length, $valid): void
203207 'length ' => $ length
204208 ];
205209
206- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
210+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
211+ $ smsVerification ->setClientRef ($ payload ['client_ref ' ]);
207212 $ smsVerification ->setLength ($ payload ['length ' ]);
208213
209214 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
@@ -225,7 +230,8 @@ public function testCanRequestWhatsApp(): void
225230 'brand ' => 'my-brand ' ,
226231 ];
227232
228- $ whatsAppVerification = new WhatsAppRequest ($ payload ['to ' ], $ payload ['brand ' ],null , $ payload ['client_ref ' ]);
233+ $ whatsAppVerification = new WhatsAppRequest ($ payload ['to ' ], $ payload ['brand ' ]);
234+ $ whatsAppVerification ->setClientRef ($ payload ['client_ref ' ]);
229235
230236 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
231237 $ this ->assertRequestJsonBodyContains ('locale ' , 'en-us ' , $ request );
@@ -254,7 +260,8 @@ public function testCanRequestWhatsAppInteractive(): void
254260 'brand ' => 'my-brand ' ,
255261 ];
256262
257- $ whatsAppInteractiveRequest = new WhatsAppInteractiveRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
263+ $ whatsAppInteractiveRequest = new WhatsAppInteractiveRequest ($ payload ['to ' ], $ payload ['brand ' ]);
264+ $ whatsAppInteractiveRequest ->setClientRef ($ payload ['client_ref ' ]);
258265
259266 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
260267 $ this ->assertRequestJsonBodyContains ('locale ' , 'en-us ' , $ request );
@@ -282,7 +289,8 @@ public function testCanRequestVoice(): void
282289 'brand ' => 'my-brand ' ,
283290 ];
284291
285- $ voiceRequest = new VoiceRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
292+ $ voiceRequest = new VoiceRequest ($ payload ['to ' ], $ payload ['brand ' ]);
293+ $ voiceRequest ->setClientRef ($ payload ['client_ref ' ]);
286294
287295 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
288296 $ this ->assertRequestJsonBodyContains ('locale ' , 'en-us ' , $ request );
@@ -311,7 +319,8 @@ public function testCanRequestEmail(): void
311319 'brand ' => 'my-brand ' ,
312320 ];
313321
314- $ emailRequest = new EmailRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['from ' ], $ payload ['client_ref ' ]);
322+ $ emailRequest = new EmailRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['from ' ]);
323+ $ emailRequest ->setClientRef ($ payload ['client_ref ' ]);
315324
316325 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
317326 $ this ->assertRequestJsonBodyContains ('locale ' , 'en-us ' , $ request );
@@ -332,6 +341,25 @@ public function testCanRequestEmail(): void
332341 $ this ->assertArrayHasKey ('request_id ' , $ result );
333342 }
334343
344+ public function testCanRenderOptionalCode (): void
345+ {
346+ $ payload = [
347+ 'to ' => '07785648870 ' ,
348+ 'brand ' => 'my-brand ' ,
349+ ];
350+
351+ $ smsRequest = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
352+ $ smsRequest ->setCode ('123456789 ' );
353+
354+ $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
355+ $ this ->assertRequestJsonBodyContains ('code ' , '123456789 ' , $ request , true );
356+
357+ return true ;
358+ }))->willReturn ($ this ->getResponse ('verify-request-success ' , 202 ));
359+
360+ $ result = $ this ->verify2Client ->startVerification ($ smsRequest );
361+ }
362+
335363 public function testCanHandleMultipleWorkflows (): void
336364 {
337365 $ payload = [
@@ -340,7 +368,8 @@ public function testCanHandleMultipleWorkflows(): void
340368 'brand ' => 'my-brand ' ,
341369 ];
342370
343- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
371+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
372+ $ smsVerification ->setClientRef ($ payload ['client_ref ' ]);
344373 $ voiceWorkflow = new VerificationWorkflow ('voice ' , '07785254785 ' );
345374 $ smsVerification ->addWorkflow ($ voiceWorkflow );
346375
@@ -389,7 +418,8 @@ public function testCannotSendConcurrentVerifications(): void
389418 'brand ' => 'my-brand ' ,
390419 ];
391420
392- $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
421+ $ smsVerification = new SMSRequest ($ payload ['to ' ], $ payload ['brand ' ]);
422+ $ smsVerification ->setClientRef ( $ payload ['client_ref ' ]);
393423
394424 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
395425 $ this ->assertEquals ('POST ' , $ request ->getMethod ());
@@ -418,7 +448,8 @@ public function testCannotSendWithoutBrand(): void
418448 'brand ' => '' ,
419449 ];
420450
421- $ voiceRequest = new VoiceRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
451+ $ voiceRequest = new VoiceRequest ($ payload ['to ' ], $ payload ['brand ' ]);
452+ $ voiceRequest ->setClientRef ($ payload ['client_ref ' ]);
422453
423454 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
424455 $ this ->assertEquals ('POST ' , $ request ->getMethod ());
@@ -439,7 +470,8 @@ public function testCanHandleThrottle(): void
439470 'brand ' => 'my-brand ' ,
440471 ];
441472
442- $ voiceRequest = new VoiceRequest ($ payload ['to ' ], $ payload ['brand ' ], $ payload ['client_ref ' ]);
473+ $ voiceRequest = new VoiceRequest ($ payload ['to ' ], $ payload ['brand ' ]);
474+ $ voiceRequest ->setClientRef ($ payload ['client_ref ' ]);
443475
444476 $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
445477 $ this ->assertEquals ('POST ' , $ request ->getMethod ());
0 commit comments