|
1 |
| -<?php |
2 |
| - |
3 |
| -namespace Deviddev\BillingoApiV3Wrapper\Tests; |
4 |
| - |
5 |
| -use Orchestra\Testbench\TestCase; |
6 |
| -use Deviddev\BillingoApiV3Wrapper\BillingoApiV3WrapperServiceProvider; |
7 |
| -use Deviddev\BillingoApiV3Wrapper\BillingoApiV3Wrapper as Billingo; |
8 |
| - |
9 |
| -class ExampleTest extends TestCase |
10 |
| -{ |
11 |
| - |
12 |
| - /** |
13 |
| - * Partner data |
14 |
| - * |
15 |
| - * @var array |
16 |
| - */ |
17 |
| - protected $partner = [ |
18 |
| - 'name' => 'Test Company', |
19 |
| - 'address' => [ |
20 |
| - 'country_code' => 'HU', |
21 |
| - 'post_code' => '1010', |
22 |
| - 'city' => 'Budapest', |
23 |
| - 'address' => 'Nagy Lajos 12.', |
24 |
| - ], |
25 |
| - 'emails' => [ '[email protected]'], |
26 |
| - 'taxcode' => '', |
27 |
| - ]; |
28 |
| - |
29 |
| - /** |
30 |
| - * Partner update data |
31 |
| - * |
32 |
| - * @var array |
33 |
| - */ |
34 |
| - protected $partnerUpdate = [ |
35 |
| - 'name' => 'Test Company updated', |
36 |
| - 'address' => [ |
37 |
| - 'country_code' => 'HU', |
38 |
| - 'post_code' => '1010', |
39 |
| - 'city' => 'Budapest', |
40 |
| - 'address' => 'Nagy Lajos 12.', |
41 |
| - ], |
42 |
| - 'emails' => [ '[email protected]'], |
43 |
| - 'taxcode' => '', |
44 |
| - ]; |
45 |
| - |
46 |
| - /** |
47 |
| - * Hold billingoApi instance |
48 |
| - * |
49 |
| - * @var object |
50 |
| - */ |
51 |
| - protected $billingoApi; |
52 |
| - |
53 |
| - /** |
54 |
| - * Set up partner id accross tests |
55 |
| - * |
56 |
| - * @return integer|null |
57 |
| - */ |
58 |
| - protected function &getPartnerId(): ?int |
59 |
| - { |
60 |
| - static $partnerId = null; |
61 |
| - return $partnerId; |
62 |
| - } |
63 |
| - |
64 |
| - /** |
65 |
| - * Get package provider |
66 |
| - * |
67 |
| - * @param [type] $app |
68 |
| - * |
69 |
| - * @return array |
70 |
| - */ |
71 |
| - protected function getPackageProviders($app): array |
72 |
| - { |
73 |
| - return [BillingoApiV3WrapperServiceProvider::class]; |
74 |
| - } |
75 |
| - |
76 |
| - /** |
77 |
| - * Set up variables |
78 |
| - * |
79 |
| - * @return void |
80 |
| - */ |
81 |
| - protected function setUp(): void |
82 |
| - { |
83 |
| - $this->billingoApi = new Billingo(); |
84 |
| - } |
85 |
| - |
86 |
| - /** |
87 |
| - * Test that partner create contains partner id |
88 |
| - * |
89 |
| - * @return void |
90 |
| - */ |
91 |
| - public function testPartnerApiCreateContainsId(): void |
92 |
| - { |
93 |
| - $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partner)->create()->getId(); |
94 |
| - |
95 |
| - $partnerId = &$this->getPartnerId(); |
96 |
| - |
97 |
| - $partnerId = $billingoApi; |
98 |
| - |
99 |
| - $this->assertIsInt($billingoApi); |
100 |
| - } |
101 |
| - |
102 |
| - /** |
103 |
| - * Test that partner create response contains partner name |
104 |
| - * |
105 |
| - * @return void |
106 |
| - */ |
107 |
| - public function testPartnerApiCreateResponseContainsPartner(): void |
108 |
| - { |
109 |
| - $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partner)->create()->getResponse(); |
110 |
| - |
111 |
| - $this->assertContains('Test Company', $billingoApi); |
112 |
| - } |
113 |
| - |
114 |
| - /** |
115 |
| - * Test that partner update conatins partner id |
116 |
| - * |
117 |
| - * @return void |
118 |
| - */ |
119 |
| - public function testPartnerApiUpdateContainsId(): void |
120 |
| - { |
121 |
| - $partnerId = &$this->getPartnerId(); |
122 |
| - |
123 |
| - $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partner)->update($partnerId)->getId(); |
124 |
| - |
125 |
| - $this->assertIsInt($billingoApi); |
126 |
| - } |
127 |
| - |
128 |
| - /** |
129 |
| - * Test that partner update response contains partner name |
130 |
| - * |
131 |
| - * @return void |
132 |
| - */ |
133 |
| - public function testPartnerApiUpdateResponseContainsPartner(): void |
134 |
| - { |
135 |
| - $partnerId = &$this->getPartnerId(); |
136 |
| - |
137 |
| - $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partnerUpdate)->update($partnerId)->getResponse(); |
138 |
| - |
139 |
| - $this->assertContains('Test Company updated', $billingoApi); |
140 |
| - } |
141 |
| -} |
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Deviddev\BillingoApiV3Wrapper\Tests; |
| 4 | + |
| 5 | +use Orchestra\Testbench\TestCase; |
| 6 | +use Deviddev\BillingoApiV3Wrapper\BillingoApiV3WrapperServiceProvider; |
| 7 | +use Deviddev\BillingoApiV3Wrapper\BillingoApiV3Wrapper as Billingo; |
| 8 | + |
| 9 | +class ExampleTest extends TestCase |
| 10 | +{ |
| 11 | + |
| 12 | + /** |
| 13 | + * Partner data |
| 14 | + * |
| 15 | + * @var array |
| 16 | + */ |
| 17 | + protected $partner = [ |
| 18 | + 'name' => 'Test Company', |
| 19 | + 'address' => [ |
| 20 | + 'country_code' => 'HU', |
| 21 | + 'post_code' => '1010', |
| 22 | + 'city' => 'Budapest', |
| 23 | + 'address' => 'Nagy Lajos 12.', |
| 24 | + ], |
| 25 | + 'emails' => [ '[email protected]'], |
| 26 | + 'taxcode' => '', |
| 27 | + ]; |
| 28 | + |
| 29 | + /** |
| 30 | + * Partner update data |
| 31 | + * |
| 32 | + * @var array |
| 33 | + */ |
| 34 | + protected $partnerUpdate = [ |
| 35 | + 'name' => 'Test Company updated', |
| 36 | + 'address' => [ |
| 37 | + 'country_code' => 'HU', |
| 38 | + 'post_code' => '1010', |
| 39 | + 'city' => 'Budapest', |
| 40 | + 'address' => 'Nagy Lajos 12.', |
| 41 | + ], |
| 42 | + 'emails' => [ '[email protected]'], |
| 43 | + 'taxcode' => '', |
| 44 | + ]; |
| 45 | + |
| 46 | + /** |
| 47 | + * Hold billingoApi instance |
| 48 | + * |
| 49 | + * @var object |
| 50 | + */ |
| 51 | + protected $billingoApi; |
| 52 | + |
| 53 | + /** |
| 54 | + * Set up partner id accross tests |
| 55 | + * |
| 56 | + * @return integer|null |
| 57 | + */ |
| 58 | + protected function &getPartnerId(): ?int |
| 59 | + { |
| 60 | + static $partnerId = null; |
| 61 | + return $partnerId; |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Get package provider |
| 66 | + * |
| 67 | + * @param [type] $app |
| 68 | + * |
| 69 | + * @return array |
| 70 | + */ |
| 71 | + protected function getPackageProviders($app): array |
| 72 | + { |
| 73 | + return [BillingoApiV3WrapperServiceProvider::class]; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Set up variables |
| 78 | + * |
| 79 | + * @return void |
| 80 | + */ |
| 81 | + protected function setUp(): void |
| 82 | + { |
| 83 | + parent::setUp(); |
| 84 | + $this->billingoApi = new Billingo('b1679ed6-b0a7-11ea-8593-0254eb6072a0'); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Test that partner create contains partner id |
| 89 | + * |
| 90 | + * @return void |
| 91 | + */ |
| 92 | + public function testPartnerApiCreateContainsId(): void |
| 93 | + { |
| 94 | + $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partner)->create()->getId(); |
| 95 | + |
| 96 | + $partnerId = &$this->getPartnerId(); |
| 97 | + |
| 98 | + $partnerId = $billingoApi; |
| 99 | + |
| 100 | + $this->assertIsInt($billingoApi); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Test that partner create response contains partner name |
| 105 | + * |
| 106 | + * @return void |
| 107 | + */ |
| 108 | + public function testPartnerApiCreateResponseContainsPartner(): void |
| 109 | + { |
| 110 | + $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partner)->create()->getResponse(); |
| 111 | + |
| 112 | + $this->assertContains('Test Company', $billingoApi); |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Test that partner update conatins partner id |
| 117 | + * |
| 118 | + * @return void |
| 119 | + */ |
| 120 | + public function testPartnerApiUpdateContainsId(): void |
| 121 | + { |
| 122 | + $partnerId = &$this->getPartnerId(); |
| 123 | + |
| 124 | + $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partner)->update($partnerId)->getId(); |
| 125 | + |
| 126 | + $this->assertIsInt($billingoApi); |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * Test that partner update response contains partner name |
| 131 | + * |
| 132 | + * @return void |
| 133 | + */ |
| 134 | + public function testPartnerApiUpdateResponseContainsPartner(): void |
| 135 | + { |
| 136 | + $partnerId = &$this->getPartnerId(); |
| 137 | + |
| 138 | + $billingoApi = $this->billingoApi->api('Partner')->model('PartnerUpsert', $this->partnerUpdate)->update($partnerId)->getResponse(); |
| 139 | + |
| 140 | + $this->assertContains('Test Company updated', $billingoApi); |
| 141 | + } |
| 142 | +} |
0 commit comments