| 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 BillingPlansTest extends TestCase
|
|
|
11 |
{
|
|
|
12 |
use MockClientClasses;
|
|
|
13 |
use MockRequestPayloads;
|
|
|
14 |
use MockResponsePayloads;
|
|
|
15 |
|
|
|
16 |
/** @test */
|
|
|
17 |
public function it_can_create_a_billing_plan()
|
|
|
18 |
{
|
|
|
19 |
$expectedResponse = $this->mockCreatePlansResponse();
|
|
|
20 |
|
|
|
21 |
$expectedParams = $this->createPlanParams();
|
|
|
22 |
|
|
|
23 |
$expectedMethod = 'createPlan';
|
|
|
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, 'some-request-id'));
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
/** @test */
|
|
|
34 |
public function it_can_list_billing_plans()
|
|
|
35 |
{
|
|
|
36 |
$expectedResponse = $this->mockListPlansResponse();
|
|
|
37 |
|
|
|
38 |
$expectedMethod = 'listPlans';
|
|
|
39 |
|
|
|
40 |
$mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
|
|
|
41 |
|
|
|
42 |
$mockClient->setApiCredentials($this->getMockCredentials());
|
|
|
43 |
$mockClient->getAccessToken();
|
|
|
44 |
|
|
|
45 |
$this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}(1, 2, true));
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/** @test */
|
|
|
49 |
public function it_can_update_a_billing_plan()
|
|
|
50 |
{
|
|
|
51 |
$expectedResponse = '';
|
|
|
52 |
|
|
|
53 |
$expectedParams = $this->updatePlanParams();
|
|
|
54 |
|
|
|
55 |
$expectedMethod = 'updatePlan';
|
|
|
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}('P-7GL4271244454362WXNWU5NQ', $expectedParams));
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
/** @test */
|
|
|
66 |
public function it_can_show_details_for_a_billing_plan()
|
|
|
67 |
{
|
|
|
68 |
$expectedResponse = $this->mockGetPlansResponse();
|
|
|
69 |
|
|
|
70 |
$expectedMethod = 'showPlanDetails';
|
|
|
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}('P-7GL4271244454362WXNWU5NQ'));
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
/** @test */
|
|
|
81 |
public function it_can_activate_a_billing_plan()
|
|
|
82 |
{
|
|
|
83 |
$expectedResponse = '';
|
|
|
84 |
|
|
|
85 |
$expectedMethod = 'activatePlan';
|
|
|
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}('P-7GL4271244454362WXNWU5NQ'));
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
/** @test */
|
|
|
96 |
public function it_can_deactivate_a_billing_plan()
|
|
|
97 |
{
|
|
|
98 |
$expectedResponse = '';
|
|
|
99 |
|
|
|
100 |
$expectedMethod = 'deactivatePlan';
|
|
|
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}('P-7GL4271244454362WXNWU5NQ'));
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
/** @test */
|
|
|
111 |
public function it_can_update_pricing_for_a_billing_plan()
|
|
|
112 |
{
|
|
|
113 |
$expectedResponse = '';
|
|
|
114 |
|
|
|
115 |
$expectedParams = $this->updatePlanPricingParams();
|
|
|
116 |
|
|
|
117 |
$expectedMethod = 'updatePlanPricing';
|
|
|
118 |
|
|
|
119 |
$mockClient = $this->mock_client($expectedResponse, $expectedMethod, true);
|
|
|
120 |
|
|
|
121 |
$mockClient->setApiCredentials($this->getMockCredentials());
|
|
|
122 |
$mockClient->getAccessToken();
|
|
|
123 |
|
|
|
124 |
$this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('P-2UF78835G6983425GLSM44MA', $expectedParams));
|
|
|
125 |
}
|
|
|
126 |
}
|