@@ -63,7 +63,10 @@ public function setUp(): void
6363 $ this ->vonageClient = $ this ->prophesize (Client::class);
6464 $ this ->vonageClient ->getRestUrl ()->willReturn ('https://rest.nexmo.com ' );
6565 $ 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+ ))
6770 );
6871
6972 /** @noinspection PhpParamsInspection */
@@ -72,7 +75,7 @@ public function setUp(): void
7275 ->setIsHAL (false )
7376 ->setErrorsOn200 (false )
7477 ->setClient ($ this ->vonageClient ->reveal ())
75- ->setAuthHandler (new Client \Credentials \Handler \BasicHandler ())
78+ ->setAuthHandler ([ new Client \Credentials \Handler \KeypairHandler (), new Client \ Credentials \ Handler \ BasicHandler ()] )
7679 ->setExceptionErrorHandler (new ExceptionErrorHandler ())
7780 ->setBaseUrl ('https://rest.nexmo.com ' );
7881
@@ -95,6 +98,10 @@ public function testCanSendSMS(): void
9598 $ message = new SMSText ($ payload ['to ' ], $ payload ['from ' ], $ payload ['text ' ]);
9699
97100 $ 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+ );
98105 $ this ->assertRequestJsonBodyContains ('to ' , $ payload ['to ' ], $ request );
99106 $ this ->assertRequestJsonBodyContains ('from ' , $ payload ['from ' ], $ request );
100107 $ this ->assertRequestJsonBodyContains ('text ' , $ payload ['text ' ], $ request );
0 commit comments