| 676 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Srmklive\PayPal\Tests\Unit\Client;
|
|
|
4 |
|
|
|
5 |
use GuzzleHttp\Utils;
|
|
|
6 |
use PHPUnit\Framework\TestCase;
|
|
|
7 |
use Srmklive\PayPal\Tests\MockClientClasses;
|
|
|
8 |
use Srmklive\PayPal\Tests\MockRequestPayloads;
|
|
|
9 |
use Srmklive\PayPal\Tests\MockResponsePayloads;
|
|
|
10 |
|
|
|
11 |
class WebHooksVerificationTest extends TestCase
|
|
|
12 |
{
|
|
|
13 |
use MockClientClasses;
|
|
|
14 |
use MockRequestPayloads;
|
|
|
15 |
use MockResponsePayloads;
|
|
|
16 |
|
|
|
17 |
/** @test */
|
|
|
18 |
public function it_can_verify_web_hook_signature()
|
|
|
19 |
{
|
|
|
20 |
$expectedResponse = $this->mockVerifyWebHookSignatureResponse();
|
|
|
21 |
|
|
|
22 |
$expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/notifications/webhooks-event-types';
|
|
|
23 |
$expectedParams = [
|
|
|
24 |
'headers' => [
|
|
|
25 |
'Accept' => 'application/json',
|
|
|
26 |
'Accept-Language' => 'en_US',
|
|
|
27 |
'Authorization' => 'Bearer some-token',
|
|
|
28 |
],
|
|
|
29 |
'json' => $this->mockVerifyWebHookSignatureParams(),
|
|
|
30 |
];
|
|
|
31 |
|
|
|
32 |
$mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
|
|
|
33 |
|
|
|
34 |
$this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
|
|
|
35 |
}
|
|
|
36 |
}
|