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 IdentityTest extends TestCase
12
{
13
    use MockClientClasses;
14
    use MockRequestPayloads;
15
    use MockResponsePayloads;
16
 
17
    /** @test */
18
    public function it_can_user_profile_details()
19
    {
20
        $expectedResponse = $this->mockShowProfileInfoResponse();
21
 
22
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1';
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_merchant_applications()
38
    {
39
        $expectedResponse = $this->mockCreateMerchantApplicationResponse();
40
 
41
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/identity/applications';
42
        $expectedParams = [
43
            'headers' => [
44
                'Accept'            => 'application/json',
45
                'Accept-Language'   => 'en_US',
46
                'Authorization'     => 'Bearer some-token',
47
            ],
48
            'json' => $this->mockCreateMerchantApplicationParams(),
49
        ];
50
 
51
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
52
 
53
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true));
54
    }
55
 
56
    /** @test */
57
    public function it_can_set_account_properties()
58
    {
59
        $expectedResponse = '';
60
 
61
        $params = $this->mockSetAccountPropertiesParams();
62
        $params['account_property'] = 'BRAINTREE_MERCHANT';
63
 
64
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/identity/account-settings';
65
        $expectedParams = [
66
            'headers' => [
67
                'Accept'            => 'application/json',
68
                'Accept-Language'   => 'en_US',
69
                'Authorization'     => 'Bearer some-token',
70
            ],
71
            'json' => $params,
72
        ];
73
 
74
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
75
 
76
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody()));
77
    }
78
 
79
    /** @test */
80
    public function it_can_disable_account_properties()
81
    {
82
        $expectedResponse = '';
83
 
84
        $params = [
85
            'account_property' => 'BRAINTREE_MERCHANT',
86
        ];
87
 
88
        $expectedEndpoint = 'https://api-m.sandbox.paypal.com/v1/identity/account-settings/deactivate';
89
        $expectedParams = [
90
            'headers' => [
91
                'Accept'            => 'application/json',
92
                'Accept-Language'   => 'en_US',
93
                'Authorization'     => 'Bearer some-token',
94
            ],
95
            'json' => $params,
96
        ];
97
 
98
        $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post');
99
 
100
        $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody()));
101
    }
102
}