@@ -151,7 +151,6 @@ public function getApplication(): array
151151 {
152152 return [
153153 ['78d335fa323d01149c3dd6f0d48968cf ' , '78d335fa323d01149c3dd6f0d48968cf ' , false ],
154- // [new Application('78d335fa323d01149c3dd6f0d48968cf'), '78d335fa323d01149c3dd6f0d48968cf', true]
155154 ];
156155 }
157156
@@ -519,70 +518,47 @@ public function createApplication(): array
519518 "NhPx2LhuLmgwWSRS4L5W851Xe3f \nUQIDAQAB \n-----END PUBLIC KEY----- \n" );
520519 $ application ->getVbcConfig ()->enable ();
521520
522- $ rawV1 = [
523- 'name ' => 'My Application ' ,
524- 'answer_url ' => 'https://example.com/webhooks/answer ' ,
525- 'answer_method ' => 'GET ' ,
526- 'event_url ' => 'https://example.com/webhooks/event ' ,
527- 'event_method ' => 'POST ' ,
528- 'status_url ' => 'https://example.com/webhooks/status ' ,
529- 'status_method ' => 'POST ' ,
530- 'inbound_url ' => 'https://example.com/webhooks/inbound ' ,
531- 'inbound_method ' => 'POST ' ,
532- 'vbc ' => true ,
533- 'public_key ' => "-----BEGIN PUBLIC KEY----- \nMIIBIjANBgkqhkiG9w0BAQEFAAOCA \nKOxjsU4pf/sMFi9N0jqcSLcjxu33G " .
534- "\nd/vynKnlw9SENi+UZR44GdjGdmfm1 \ntL1eA7IBh2HNnkYXnAwYzKJoa4eO3 \n0kYWekeIZawIwe/g9faFgkev+1xsO \nOUNhP " .
535- "x2LhuLmgwWSRS4L5W851Xe3f \nUQIDAQAB \n-----END PUBLIC KEY----- \n"
521+ return [
522+ 'createApplication ' => [clone $ application , 'create ' ],
536523 ];
524+ }
537525
538- $ rawV2 = [
539- 'name ' => 'My Application ' ,
540- 'keys ' => [
541- 'public_key ' => "-----BEGIN PUBLIC KEY----- \nMIIBIjANBgkqhkiG9w0BAQEFAAOCA \nKOxjsU4pf/sMFi9N0jqcSLcjx " .
542- "u33G \nd/vynKnlw9SENi+UZR44GdjGdmfm1 \ntL1eA7IBh2HNnkYXnAwYzKJoa4eO3 \n0kYWekeIZawIwe/g9faFgkev+1xs " .
543- "O \nOUNhPx2LhuLmgwWSRS4L5W851Xe3f \nUQIDAQAB \n-----END PUBLIC KEY----- \n"
544- ],
545- 'capabilities ' => [
546- 'voice ' => [
547- 'webhooks ' => [
548- 'answer_url ' => [
549- 'address ' => 'https://example.com/webhooks/answer ' ,
550- 'http_method ' => 'GET ' ,
551- ],
552- 'event_url ' => [
553- 'address ' => 'https://example.com/webhooks/event ' ,
554- 'http_method ' => 'POST ' ,
555- ],
556- ]
557- ],
558- 'messages ' => [
559- 'webhooks ' => [
560- 'inbound_url ' => [
561- 'address ' => 'https://example.com/webhooks/inbound ' ,
562- 'http_method ' => 'POST '
526+ public function testCreateApplicationWithRegion (): void
527+ {
528+ $ this ->vonageClient ->send (Argument::that (function (Request $ request ) {
529+ $ this ->assertEquals ('/v2/applications ' , $ request ->getUri ()->getPath ());
530+ $ this ->assertEquals ('api.nexmo.com ' , $ request ->getUri ()->getHost ());
531+ $ this ->assertEquals ('POST ' , $ request ->getMethod ());
563532
564- ],
565- 'status_url ' => [
566- 'address ' => 'https://example.com/webhooks/status ' ,
567- 'http_method ' => 'POST '
568- ]
569- ]
570- ],
571- 'rtc ' => [
572- 'webhooks ' => [
573- 'event_url ' => [
574- 'address ' => 'https://example.com/webhooks/event ' ,
575- 'http_method ' => 'POST ' ,
576- ],
577- ]
578- ],
579- 'vbc ' => []
580- ]
581- ];
533+ $ this ->assertRequestJsonBodyContains ('name ' , 'my application ' , $ request );
534+ $ this ->assertRequestJsonBodyContains ('region ' , 'eu-west ' , $ request , true );
535+ $ this ->assertRequestJsonBodyContains ('signed_callbacks ' , true , $ request , true );
536+ $ this ->assertRequestJsonBodyContains ('conversations_ttl ' , 50 , $ request , true );
537+ return true ;
538+ }))->willReturn ($ this ->getResponse ('success ' , 201 ));
582539
583- return [
584- 'createApplication ' => [clone $ application , 'create ' ],
585- ];
540+ $ application = new Application ();
541+ $ application ->setName ('my application ' );
542+ $ application ->getVoiceConfig ()->setRegion ('eu-west ' );
543+ $ application ->getVoiceConfig ()->setConversationsTtl (50 );
544+ $ application ->getVoiceConfig ()->setSignedCallbacks (true );
545+
546+
547+ $ application ->setPublicKey ("-----BEGIN PUBLIC KEY----- \nMIIBIjANBgkqhkiG9w0BAQEFAAOCA \nKOxjsU4pf/sMFi9N0jqcSL " .
548+ "cjxu33G \nd/vynKnlw9SENi+UZR44GdjGdmfm1 \ntL1eA7IBh2HNnkYXnAwYzKJoa4eO3 \n0kYWekeIZawIwe/g9faFgkev+1xsO \nOU " .
549+ "NhPx2LhuLmgwWSRS4L5W851Xe3f \nUQIDAQAB \n-----END PUBLIC KEY----- \n" );
550+
551+
552+ $ response = $ this ->applicationClient ->create ($ application );
553+ }
554+
555+ public function testCannotSetUnknownRegion (): void
556+ {
557+ $ this ->expectException (\InvalidArgumentException::class);
558+ $ this ->expectExceptionMessage ('Unrecognised Region: eu-west-1 ' );
559+ $ application = new Application ();
560+ $ application ->setName ('my application ' );
561+ $ application ->getVoiceConfig ()->setRegion ('eu-west-1 ' );
586562 }
587563
588564 /**
0 commit comments