Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
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 PaymentExperienceWebProfilesTest extends TestCase
12
{
13
    use MockClientClasses;
14
    use MockRequestPayloads;
15
    use MockResponsePayloads;
16
 
17
    /** @test */
18
    public function it_can_list_web_experience_profiles()
19
    {
20
        $expectedResponse = $this->mockListWebProfilesResponse();
21
 
22
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/payment-experience/web-profiles';
23
        $expectedParams = [
24
            'headers' => [
25
                'Accept'            => 'application/json',
26
                'Accept-Language'   => 'en_US',
27
                'Authorization'     => 'Bearer some-token',
28
            ],
29
        ];
30
 
31
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get');
32
 
33
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true));
34
    }
35
 
36
    /** @test */
37
    public function it_can_create_web_experience_profile()
38
    {
39
        $expectedResponse = $this->mockWebProfileResponse();
40
 
41
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/payment-experience/web-profiles';
42
        $expectedParams = [
43
            'headers' => [
44
                'Accept'            => 'application/json',
45
                'Accept-Language'   => 'en_US',
46
                'Authorization'     => 'Bearer some-token',
47
                'PayPal-Request-Id' => 'some-request-id',
48
            ],
49
            'json' => $this->mockCreateWebProfileParams(),
50
        ];
51
 
52
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
53
 
54
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
55
    }
56
 
57
    /** @test */
58
    public function it_can_delete_web_experience_profile()
59
    {
60
        $expectedResponse = '';
61
 
62
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/payment-experience/web-profiles/XP-A88A-LYLW-8Y3X-E5ER';
63
        $expectedParams = [
64
            'headers' => [
65
                'Accept'            => 'application/json',
66
                'Accept-Language'   => 'en_US',
67
                'Authorization'     => 'Bearer some-token',
68
            ],
69
        ];
70
 
71
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete');
72
 
73
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true));
74
    }
75
 
76
    /** @test */
77
    public function it_can_partially_update_web_experience_profile()
78
    {
79
        $expectedResponse = '';
80
 
81
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/payment-experience/web-profiles/XP-A88A-LYLW-8Y3X-E5ER';
82
        $expectedParams = [
83
            'headers' => [
84
                'Accept'            => 'application/json',
85
                'Accept-Language'   => 'en_US',
86
                'Authorization'     => 'Bearer some-token',
87
            ],
88
            'json' => $this->partiallyUpdateWebProfileParams(),
89
        ];
90
 
91
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch');
92
 
93
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true));
94
    }
95
 
96
    /** @test */
97
    public function it_can_fully_update_web_experience_profile()
98
    {
99
        $expectedResponse = '';
100
 
101
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/payment-experience/web-profiles/XP-A88A-LYLW-8Y3X-E5ER';
102
        $expectedParams = [
103
            'headers' => [
104
                'Accept'            => 'application/json',
105
                'Accept-Language'   => 'en_US',
106
                'Authorization'     => 'Bearer some-token',
107
            ],
108
            'json' => $this->updateWebProfileParams(),
109
        ];
110
 
111
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch');
112
 
113
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true));
114
    }
115
 
116
    /** @test */
117
    public function it_can_get_web_experience_profile_details()
118
    {
119
        $expectedResponse = $this->mockWebProfileResponse();
120
 
121
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/payment-experience/web-profiles/XP-A88A-LYLW-8Y3X-E5ER';
122
        $expectedParams = [
123
            'headers' => [
124
                'Accept'            => 'application/json',
125
                'Accept-Language'   => 'en_US',
126
                'Authorization'     => 'Bearer some-token',
127
            ],
128
        ];
129
 
130
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get');
131
 
132
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true));
133
    }
134
}