Skip to content

Commit 2cc3b18

Browse files
authored
test: added new test for tax profile
2 parents 5cca3cd + 104f3ca commit 2cc3b18

File tree

3 files changed

+181
-48
lines changed

3 files changed

+181
-48
lines changed

test/Api/SettingsApiTest.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,66 @@ public function testModifyPaymentMethod()
260260

261261
TestCase::assertEquals($obj, $result);
262262
}
263+
264+
/**
265+
* Test case for getTaxProfile
266+
*
267+
* Get Tax Profile.
268+
*
269+
*/
270+
public function testGetTaxProfile()
271+
{
272+
$stream = '{
273+
"data": {
274+
"company_type": "individual",
275+
"company_subtype": "artigiani",
276+
"profession": "test",
277+
"regime": "forfettario_5",
278+
"rivalsa_name": "",
279+
"default_rivalsa": 0,
280+
"cassa_name": "",
281+
"default_cassa": 0,
282+
"default_cassa_taxable": 100,
283+
"cassa2_name": "",
284+
"default_cassa2": 0,
285+
"default_cassa2_taxable": 0,
286+
"default_withholding_tax": 0,
287+
"default_withholding_tax_taxable": 100,
288+
"default_other_withholding_tax": 0,
289+
"enasarco": false,
290+
"enasarco_type": "null",
291+
"contributions_percentage": 0,
292+
"med": false,
293+
"default_vat": {
294+
"id": 66,
295+
"value": 0,
296+
"description": "Contribuenti forfettari",
297+
"notes": "Operazione non soggetta a IVA ai sensi dell\'art. 1, commi 54-89, Legge n. 190\/2014 e succ. modifiche\/integrazioni",
298+
"e_invoice": true,
299+
"ei_type": "2.2",
300+
"ei_description": "Non soggetta art. 1\/54-89 L. 190\/2014 e succ. modifiche\/integrazioni",
301+
"editable": false,
302+
"is_disabled": false,
303+
"default": true
304+
}
305+
}
306+
}';
307+
$mock = new MockHandler([new Response(
308+
200,
309+
['Content-Type' => 'application/json'],
310+
$stream
311+
)]);
312+
313+
$handler = HandlerStack::create($mock);
314+
$apiInstance = new \FattureInCloud\Api\SettingsApi(
315+
new \GuzzleHttp\Client(['handler' => $handler])
316+
);
317+
$company_id = 2;
318+
$result = $apiInstance->getTaxProfile($company_id);
319+
$obj = ObjectSerializer::deserialize($stream, '\FattureInCloud\Model\GetTaxProfileResponse');
320+
321+
TestCase::assertEquals($obj, $result);
322+
}
323+
324+
263325
}

test/Model/GetTaxProfileResponseTest.php

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
namespace FattureInCloud\Test\Model;
3131

32+
use FattureInCloud\ObjectSerializer;
3233
use PHPUnit\Framework\TestCase;
3334

3435
/**
@@ -42,6 +43,9 @@
4243
*/
4344
class GetTaxProfileResponseTest extends TestCase
4445
{
46+
public $array = [];
47+
public $object;
48+
4549
/**
4650
* Setup before running any test case
4751
*/
@@ -54,6 +58,45 @@ public static function setUpBeforeClass(): void
5458
*/
5559
public function setUp(): void
5660
{
61+
$json = '{
62+
"data": {
63+
"company_type": "individual",
64+
"company_subtype": "artigiani",
65+
"profession": "test",
66+
"regime": "forfettario_5",
67+
"rivalsa_name": "",
68+
"default_rivalsa": 0,
69+
"cassa_name": "",
70+
"default_cassa": 0,
71+
"default_cassa_taxable": 100,
72+
"cassa2_name": "",
73+
"default_cassa2": 0,
74+
"default_cassa2_taxable": 0,
75+
"default_withholding_tax": 0,
76+
"default_withholding_tax_taxable": 100,
77+
"default_other_withholding_tax": 0,
78+
"enasarco": false,
79+
"enasarco_type": "null",
80+
"contributions_percentage": 0,
81+
"med": false,
82+
"default_vat": {
83+
"id": 66,
84+
"value": 0,
85+
"description": "Contribuenti forfettari",
86+
"notes": "Operazione non soggetta a IVA ai sensi dell\'art. 1, commi 54-89, Legge n. 190\/2014 e succ. modifiche\/integrazioni",
87+
"e_invoice": true,
88+
"ei_type": "2.2",
89+
"ei_description": "Non soggetta art. 1\/54-89 L. 190\/2014 e succ. modifiche\/integrazioni",
90+
"editable": false,
91+
"is_disabled": false,
92+
"default": true
93+
}
94+
}
95+
}';
96+
97+
$this->array = json_decode($json, true);
98+
99+
$this->object = ObjectSerializer::deserialize($json, '\FattureInCloud\Model\GetTaxProfileResponse');
57100
}
58101

59102
/**
@@ -75,16 +118,18 @@ public static function tearDownAfterClass(): void
75118
*/
76119
public function testGetTaxProfileResponse()
77120
{
78-
// TODO: implement
79-
self::markTestIncomplete('Not implemented');
121+
foreach ($this->array as $key => $value) {
122+
Testcase::assertArrayHasKey($key, $this->object);
123+
}
80124
}
81125

82126
/**
83127
* Test attribute "data"
84128
*/
85129
public function testPropertyData()
86130
{
87-
// TODO: implement
88-
self::markTestIncomplete('Not implemented');
131+
foreach ($this->array['data'] as $key => $value) {
132+
Testcase::assertArrayHasKey($key, $this->object['data']);
133+
}
89134
}
90135
}

0 commit comments

Comments
 (0)