From ee6bbf1b50c970339b202760a295fc6df43a53ff Mon Sep 17 00:00:00 2001 From: Gabriele Barcella Date: Wed, 13 Nov 2024 16:32:43 +0100 Subject: [PATCH 1/2] fix: added new test for tax profile --- test/Api/SettingsApiTest.php | 62 ++++++++++++ test/Model/GetTaxProfileResponseTest.php | 53 +++++++++- test/Model/TaxProfileTest.php | 119 +++++++++++++---------- 3 files changed, 179 insertions(+), 55 deletions(-) diff --git a/test/Api/SettingsApiTest.php b/test/Api/SettingsApiTest.php index bcc4880c..ea62d07b 100644 --- a/test/Api/SettingsApiTest.php +++ b/test/Api/SettingsApiTest.php @@ -260,4 +260,66 @@ public function testModifyPaymentMethod() TestCase::assertEquals($obj, $result); } + + /** + * Test case for getTaxProfile + * + * Get Tax Profile. + * + */ + public function testGetTaxProfile() + { + $stream = '{ + "data": { + "company_type": "individual", + "company_subtype": "artigiani", + "profession": "test", + "regime": "forfettario_5", + "rivalsa_name": "", + "default_rivalsa": 0, + "cassa_name": "", + "default_cassa": 0, + "default_cassa_taxable": 100, + "cassa2_name": "", + "default_cassa2": 0, + "default_cassa2_taxable": 0, + "default_withholding_tax": 0, + "default_withholding_tax_taxable": 100, + "default_other_withholding_tax": 0, + "enasarco": false, + "enasarco_type": "null", + "contributions_percentage": 0, + "med": false, + "default_vat": { + "id": 66, + "value": 0, + "description": "Contribuenti forfettari", + "notes": "Operazione non soggetta a IVA ai sensi dell\'art. 1, commi 54-89, Legge n. 190\/2014 e succ. modifiche\/integrazioni", + "e_invoice": true, + "ei_type": "2.2", + "ei_description": "Non soggetta art. 1\/54-89 L. 190\/2014 e succ. modifiche\/integrazioni", + "editable": false, + "is_disabled": false, + "default": true + } + } + }'; + $mock = new MockHandler([new Response( + 200, + ['Content-Type' => 'application/json'], + $stream + )]); + + $handler = HandlerStack::create($mock); + $apiInstance = new \FattureInCloud\Api\SettingsApi( + new \GuzzleHttp\Client(['handler' => $handler]) + ); + $company_id = 2; + $result = $apiInstance->getTaxProfile($company_id); + $obj = ObjectSerializer::deserialize($stream, '\FattureInCloud\Model\GetTaxProfileResponse'); + + TestCase::assertEquals($obj, $result); + } + + } diff --git a/test/Model/GetTaxProfileResponseTest.php b/test/Model/GetTaxProfileResponseTest.php index 22398d09..1ecf0446 100644 --- a/test/Model/GetTaxProfileResponseTest.php +++ b/test/Model/GetTaxProfileResponseTest.php @@ -29,6 +29,7 @@ namespace FattureInCloud\Test\Model; +use FattureInCloud\ObjectSerializer; use PHPUnit\Framework\TestCase; /** @@ -42,6 +43,9 @@ */ class GetTaxProfileResponseTest extends TestCase { + public $array = []; + public $object; + /** * Setup before running any test case */ @@ -54,6 +58,45 @@ public static function setUpBeforeClass(): void */ public function setUp(): void { + $json = '{ + "data": { + "company_type": "individual", + "company_subtype": "artigiani", + "profession": "test", + "regime": "forfettario_5", + "rivalsa_name": "", + "default_rivalsa": 0, + "cassa_name": "", + "default_cassa": 0, + "default_cassa_taxable": 100, + "cassa2_name": "", + "default_cassa2": 0, + "default_cassa2_taxable": 0, + "default_withholding_tax": 0, + "default_withholding_tax_taxable": 100, + "default_other_withholding_tax": 0, + "enasarco": false, + "enasarco_type": "null", + "contributions_percentage": 0, + "med": false, + "default_vat": { + "id": 66, + "value": 0, + "description": "Contribuenti forfettari", + "notes": "Operazione non soggetta a IVA ai sensi dell\'art. 1, commi 54-89, Legge n. 190\/2014 e succ. modifiche\/integrazioni", + "e_invoice": true, + "ei_type": "2.2", + "ei_description": "Non soggetta art. 1\/54-89 L. 190\/2014 e succ. modifiche\/integrazioni", + "editable": false, + "is_disabled": false, + "default": true + } + } + }'; + + $this->array = json_decode($json, true); + + $this->object = ObjectSerializer::deserialize($json, '\FattureInCloud\Model\GetTaxProfileResponse'); } /** @@ -75,8 +118,9 @@ public static function tearDownAfterClass(): void */ public function testGetTaxProfileResponse() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + foreach ($this->array as $key => $value) { + Testcase::assertArrayHasKey($key, $this->object); + } } /** @@ -84,7 +128,8 @@ public function testGetTaxProfileResponse() */ public function testPropertyData() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + foreach ($this->array['data'] as $key => $value) { + Testcase::assertArrayHasKey($key, $this->object['data']); + } } } diff --git a/test/Model/TaxProfileTest.php b/test/Model/TaxProfileTest.php index 3ee7e055..5956fb13 100644 --- a/test/Model/TaxProfileTest.php +++ b/test/Model/TaxProfileTest.php @@ -29,7 +29,9 @@ namespace FattureInCloud\Test\Model; +use FattureInCloud\ObjectSerializer; use PHPUnit\Framework\TestCase; +use PHPUnit\Util\Test; /** * TaxProfileTest Class Doc Comment @@ -42,6 +44,9 @@ */ class TaxProfileTest extends TestCase { + public $array = []; + public $object; + /** * Setup before running any test case */ @@ -54,6 +59,44 @@ public static function setUpBeforeClass(): void */ public function setUp(): void { + $json = '{ + "company_type": "individual", + "company_subtype": "artigiani", + "profession": "test", + "regime": "forfettario_5", + "rivalsa_name": "", + "default_rivalsa": 0, + "cassa_name": "", + "default_cassa": 0, + "default_cassa_taxable": 100, + "cassa2_name": "", + "default_cassa2": 0, + "default_cassa2_taxable": 0, + "default_withholding_tax": 0, + "default_withholding_tax_taxable": 100, + "default_other_withholding_tax": 0, + "enasarco": false, + "enasarco_type": "null", + "contributions_percentage": 0, + "med": false, + "default_vat": { + "id": 66, + "value": 0, + "description": "Contribuenti forfettari", + "notes": "Operazione non soggetta a IVA ai sensi dell\'art. 1, commi 54-89, Legge n. 190\/2014 e succ. modifiche\/integrazioni", + "e_invoice": true, + "ei_type": "2.2", + "ei_description": "Non soggetta art. 1\/54-89 L. 190\/2014 e succ. modifiche\/integrazioni", + "editable": false, + "is_disabled": false, + "default": true + } + }'; + + + $this->array = json_decode($json, true); + + $this->object = ObjectSerializer::deserialize($json, '\FattureInCloud\Model\TaxProfile'); } /** @@ -75,8 +118,9 @@ public static function tearDownAfterClass(): void */ public function testTaxProfile() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + foreach ($this->array as $key => $value) { + Testcase::assertArrayHasKey($key, $this->object); + } } /** @@ -84,8 +128,7 @@ public function testTaxProfile() */ public function testPropertyCompanyType() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['company_type'], $this->array['company_type']); } /** @@ -93,8 +136,7 @@ public function testPropertyCompanyType() */ public function testPropertyCompanySubtype() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['company_subtype'], $this->array['company_subtype']); } /** @@ -102,8 +144,7 @@ public function testPropertyCompanySubtype() */ public function testPropertyProfession() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['profession'], $this->array['profession']); } /** @@ -111,8 +152,7 @@ public function testPropertyProfession() */ public function testPropertyRegime() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['regime'], $this->array['regime']); } /** @@ -120,8 +160,7 @@ public function testPropertyRegime() */ public function testPropertyRivalsaName() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['rivalsa_name'], $this->array['rivalsa_name']); } /** @@ -129,8 +168,7 @@ public function testPropertyRivalsaName() */ public function testPropertyDefaultRivalsa() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_rivalsa'], $this->array['default_rivalsa']); } /** @@ -138,8 +176,7 @@ public function testPropertyDefaultRivalsa() */ public function testPropertyCassaName() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['cassa_name'], $this->array['cassa_name']); } /** @@ -147,8 +184,7 @@ public function testPropertyCassaName() */ public function testPropertyDefaultCassa() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_cassa'], $this->array['default_cassa']); } /** @@ -156,8 +192,7 @@ public function testPropertyDefaultCassa() */ public function testPropertyDefaultCassaTaxable() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_cassa_taxable'], $this->array['default_cassa_taxable']); } /** @@ -165,8 +200,7 @@ public function testPropertyDefaultCassaTaxable() */ public function testPropertyCassa2Name() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['cassa2_name'], $this->array['cassa2_name']); } /** @@ -174,8 +208,7 @@ public function testPropertyCassa2Name() */ public function testPropertyDefaultCassa2() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_cassa2'], $this->array['default_cassa2']); } /** @@ -183,8 +216,7 @@ public function testPropertyDefaultCassa2() */ public function testPropertyDefaultCassa2Taxable() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_cassa2_taxable'], $this->array['default_cassa2_taxable']); } /** @@ -192,8 +224,7 @@ public function testPropertyDefaultCassa2Taxable() */ public function testPropertyDefaultWithholdingTax() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_withholding_tax'], $this->array['default_withholding_tax']); } /** @@ -201,8 +232,7 @@ public function testPropertyDefaultWithholdingTax() */ public function testPropertyDefaultWithholdingTaxTaxable() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_withholding_tax_taxable'], $this->array['default_withholding_tax_taxable']); } /** @@ -210,8 +240,7 @@ public function testPropertyDefaultWithholdingTaxTaxable() */ public function testPropertyDefaultOtherWithholdingTax() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['default_other_withholding_tax'], $this->array['default_other_withholding_tax']); } /** @@ -219,8 +248,7 @@ public function testPropertyDefaultOtherWithholdingTax() */ public function testPropertyEnasarco() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['enasarco'], $this->array['enasarco']); } /** @@ -228,8 +256,7 @@ public function testPropertyEnasarco() */ public function testPropertyEnasarcoType() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['enasarco_type'], $this->array['enasarco_type']); } /** @@ -237,17 +264,7 @@ public function testPropertyEnasarcoType() */ public function testPropertyContributionsPercentage() { - // TODO: implement - self::markTestIncomplete('Not implemented'); - } - - /** - * Test attribute "profit_coefficient" - */ - public function testPropertyProfitCoefficient() - { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['contributions_percentage'], $this->array['contributions_percentage']); } /** @@ -255,8 +272,7 @@ public function testPropertyProfitCoefficient() */ public function testPropertyMed() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + TestCase::assertEquals($this->object['med'], $this->array['med']); } /** @@ -264,7 +280,8 @@ public function testPropertyMed() */ public function testPropertyDefaultVat() { - // TODO: implement - self::markTestIncomplete('Not implemented'); + foreach ($this->array['default_vat'] as $key => $value) { + Testcase::assertArrayHasKey($key, $this->object['default_vat']); + } } } From 104f3ca8de524e216cd1d62493f191cdbbbab2eb Mon Sep 17 00:00:00 2001 From: Gabriele Barcella Date: Wed, 20 Nov 2024 08:43:57 +0100 Subject: [PATCH 2/2] test: added test for profit coefficient --- test/Model/TaxProfileTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/Model/TaxProfileTest.php b/test/Model/TaxProfileTest.php index 5956fb13..947adea6 100644 --- a/test/Model/TaxProfileTest.php +++ b/test/Model/TaxProfileTest.php @@ -78,6 +78,7 @@ public function setUp(): void "enasarco": false, "enasarco_type": "null", "contributions_percentage": 0, + "profit_coefficient": 0, "med": false, "default_vat": { "id": 66, @@ -267,6 +268,14 @@ public function testPropertyContributionsPercentage() TestCase::assertEquals($this->object['contributions_percentage'], $this->array['contributions_percentage']); } + /** + * Test attribute "profit_coefficient" + */ + public function testPropertyProfitCoefficient() + { + TestCase::assertEquals($this->object['profit_coefficient'], $this->array['profit_coefficient']); + } + /** * Test attribute "med" */