@@ -63,7 +63,10 @@ public function setUp(): void
63
63
$ this ->vonageClient = $ this ->prophesize (Client::class);
64
64
$ this ->vonageClient ->getRestUrl ()->willReturn ('https://rest.nexmo.com ' );
65
65
$ this ->vonageClient ->getCredentials ()->willReturn (
66
- new Client \Credentials \Container (new Client \Credentials \Basic ('abc ' , 'def ' ))
66
+ new Client \Credentials \Container (new Client \Credentials \Keypair (
67
+ file_get_contents (__DIR__ . '/../Client/Credentials/test.key ' ),
68
+ 'def '
69
+ ))
67
70
);
68
71
69
72
/** @noinspection PhpParamsInspection */
@@ -72,7 +75,7 @@ public function setUp(): void
72
75
->setIsHAL (false )
73
76
->setErrorsOn200 (false )
74
77
->setClient ($ this ->vonageClient ->reveal ())
75
- ->setAuthHandler (new Client \Credentials \Handler \BasicHandler ())
78
+ ->setAuthHandler ([ new Client \Credentials \Handler \KeypairHandler (), new Client \ Credentials \ Handler \ BasicHandler ()] )
76
79
->setExceptionErrorHandler (new ExceptionErrorHandler ())
77
80
->setBaseUrl ('https://rest.nexmo.com ' );
78
81
@@ -95,6 +98,10 @@ public function testCanSendSMS(): void
95
98
$ message = new SMSText ($ payload ['to ' ], $ payload ['from ' ], $ payload ['text ' ]);
96
99
97
100
$ this ->vonageClient ->send (Argument::that (function (Request $ request ) use ($ payload ) {
101
+ $ this ->assertEquals (
102
+ 'Bearer ' ,
103
+ mb_substr ($ request ->getHeaders ()['Authorization ' ][0 ], 0 , 7 )
104
+ );
98
105
$ this ->assertRequestJsonBodyContains ('to ' , $ payload ['to ' ], $ request );
99
106
$ this ->assertRequestJsonBodyContains ('from ' , $ payload ['from ' ], $ request );
100
107
$ this ->assertRequestJsonBodyContains ('text ' , $ payload ['text ' ], $ request );
0 commit comments