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\Adapter;
4
 
5
use PHPUnit\Framework\TestCase;
6
use Srmklive\PayPal\Tests\MockClientClasses;
7
use Srmklive\PayPal\Tests\MockRequestPayloads;
8
use Srmklive\PayPal\Tests\MockResponsePayloads;
9
 
10
class SubscriptionsTest extends TestCase
11
{
12
    use MockClientClasses;
13
    use MockRequestPayloads;
14
    use MockResponsePayloads;
15
 
16
    /** @test */
17
    public function it_can_create_a_subscription()
18
    {
19
        $expectedResponse = $this->mockCreateSubscriptionResponse();
20
 
21
        $expectedParams = $this->mockCreateSubscriptionParams();
22
 
23
        $expectedMethod = 'createSubscription';
24
 
25
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
26
 
27
        $mockClient->setApiCredentials($this->getMockCredentials());
28
        $mockClient->getAccessToken();
29
 
30
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams));
31
    }
32
 
33
    /** @test */
34
    public function it_can_update_a_subscription()
35
    {
36
        $expectedResponse = '';
37
 
38
        $expectedParams = $this->mockUpdateSubscriptionParams();
39
 
40
        $expectedMethod = 'updateSubscription';
41
 
42
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
43
 
44
        $mockClient->setApiCredentials($this->getMockCredentials());
45
        $mockClient->getAccessToken();
46
 
47
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', $expectedParams));
48
    }
49
 
50
    /** @test */
51
    public function it_can_show_details_for_a_subscription()
52
    {
53
        $expectedResponse = $this->mockGetSubscriptionDetailsResponse();
54
 
55
        $expectedMethod = 'showSubscriptionDetails';
56
 
57
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
58
 
59
        $mockClient->setApiCredentials($this->getMockCredentials());
60
        $mockClient->getAccessToken();
61
 
62
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G'));
63
    }
64
 
65
    /** @test */
66
    public function it_can_activate_a_subscription()
67
    {
68
        $expectedResponse = '';
69
 
70
        $expectedMethod = 'activateSubscription';
71
 
72
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
73
 
74
        $mockClient->setApiCredentials($this->getMockCredentials());
75
        $mockClient->getAccessToken();
76
 
77
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Reactivating the subscription'));
78
    }
79
 
80
    /** @test */
81
    public function it_can_cancel_a_subscription()
82
    {
83
        $expectedResponse = '';
84
 
85
        $expectedMethod = 'cancelSubscription';
86
 
87
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
88
 
89
        $mockClient->setApiCredentials($this->getMockCredentials());
90
        $mockClient->getAccessToken();
91
 
92
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Not satisfied with the service'));
93
    }
94
 
95
    /** @test */
96
    public function it_can_suspend_a_subscription()
97
    {
98
        $expectedResponse = '';
99
 
100
        $expectedMethod = 'suspendSubscription';
101
 
102
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
103
 
104
        $mockClient->setApiCredentials($this->getMockCredentials());
105
        $mockClient->getAccessToken();
106
 
107
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Item out of stock'));
108
    }
109
 
110
    /** @test */
111
    public function it_can_capture_payment_for_a_subscription()
112
    {
113
        $expectedResponse = '';
114
 
115
        $expectedMethod = 'captureSubscriptionPayment';
116
 
117
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
118
 
119
        $mockClient->setApiCredentials($this->getMockCredentials());
120
        $mockClient->getAccessToken();
121
 
122
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Charging as the balance reached the limit', 100));
123
    }
124
 
125
    /** @test */
126
    public function it_can_update_quantity_or_product_for_a_subscription()
127
    {
128
        $expectedResponse = $this->mockUpdateSubscriptionItemsResponse();
129
 
130
        $expectedParams = $this->mockUpdateSubscriptionItemsParams();
131
 
132
        $expectedMethod = 'reviseSubscription';
133
 
134
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
135
 
136
        $mockClient->setApiCredentials($this->getMockCredentials());
137
        $mockClient->getAccessToken();
138
 
139
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', $expectedParams));
140
    }
141
 
142
    /** @test */
143
    public function it_can_list_transactions_for_a_subscription()
144
    {
145
        $expectedResponse = $this->mockListSubscriptionTransactionsResponse();
146
 
147
        $expectedMethod = 'listSubscriptionTransactions';
148
 
149
        $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
150
 
151
        $mockClient->setApiCredentials($this->getMockCredentials());
152
        $mockClient->getAccessToken();
153
 
154
        $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', '2018-01-21T07:50:20.940Z', '2018-08-22T07:50:20.940Z'));
155
    }
156
}