Skip to content

Commit

Permalink
[CS] Code Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Jan 18, 2025
1 parent 6c15386 commit bff30b6
Show file tree
Hide file tree
Showing 29 changed files with 3,920 additions and 3,920 deletions.
2 changes: 1 addition & 1 deletion build/phprectorconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
strictBooleans: true,
instanceOf: true,
earlyReturn: true,
phpunitCodeQuality: true,
//
carbon: false,
deadCode: false,
doctrineCodeQuality: false,
naming: false,
phpunitCodeQuality: false,
privatization: false,
rectorPreset: false,
symfonyCodeQuality: false,
Expand Down
8 changes: 4 additions & 4 deletions tests/testcases/BuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function testDocumentProfile(): void
public function testDocumentGetters(): void
{
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject'));
$this->assertEquals('horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice', get_class($this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject')));
$this->assertInstanceOf('horstoeko\zugferd\entities\en16931\rsm\CrossIndustryInvoice', $this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject'));
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getSerializer'));
$this->assertEquals(\JMS\Serializer\Serializer::class, get_class($this->invokePrivateMethodFromObject(self::$document, 'getSerializer')));
$this->assertInstanceOf(\JMS\Serializer\Serializer::class, $this->invokePrivateMethodFromObject(self::$document, 'getSerializer'));
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper'));
$this->assertEquals('horstoeko\zugferd\ZugferdObjectHelper', get_class($this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper')));
$this->assertInstanceOf('horstoeko\zugferd\ZugferdObjectHelper', $this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper'));
$this->assertEquals('en16931', self::$document->getProfileDefinitionParameter('name'));
$this->assertEquals('EN 16931 (COMFORT)', self::$document->getProfileDefinitionParameter('altname'));
$this->assertEquals('urn:cen.eu:en16931:2017', self::$document->getProfileDefinitionParameter('contextparameter'));
Expand Down Expand Up @@ -2104,7 +2104,7 @@ public function testSetDocumentShipToMultipleContactsAdd(): void
public function testWriteFile(): void
{
(self::$document)->writeFile(getcwd() . "/myfile.xml");
$this->assertTrue(file_exists(getcwd() . "/myfile.xml"));
$this->assertFileExists(getcwd() . "/myfile.xml");
@unlink(getcwd() . "/myfile.xml");
}

Expand Down
8 changes: 4 additions & 4 deletions tests/testcases/BuilderExtendedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function testDocumentProfile(): void
public function testDocumentGetters(): void
{
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject'));
$this->assertEquals('horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice', get_class($this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject')));
$this->assertInstanceOf('horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice', $this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject'));
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getSerializer'));
$this->assertEquals(\JMS\Serializer\Serializer::class, get_class($this->invokePrivateMethodFromObject(self::$document, 'getSerializer')));
$this->assertInstanceOf(\JMS\Serializer\Serializer::class, $this->invokePrivateMethodFromObject(self::$document, 'getSerializer'));
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper'));
$this->assertEquals('horstoeko\zugferd\ZugferdObjectHelper', get_class($this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper')));
$this->assertInstanceOf('horstoeko\zugferd\ZugferdObjectHelper', $this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper'));
$this->assertEquals('extended', self::$document->getProfileDefinitionParameter('name'));
$this->assertEquals('EXTENDED', self::$document->getProfileDefinitionParameter('altname'));
$this->assertEquals('urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended', self::$document->getProfileDefinitionParameter('contextparameter'));
Expand Down Expand Up @@ -2027,7 +2027,7 @@ public function testSetDocumentShipToMultipleContactsAdd(): void
public function testWriteFile(): void
{
(self::$document)->writeFile(getcwd() . "/myfile.xml");
$this->assertTrue(file_exists(getcwd() . "/myfile.xml"));
$this->assertFileExists(getcwd() . "/myfile.xml");
@unlink(getcwd() . "/myfile.xml");
}

Expand Down
8 changes: 4 additions & 4 deletions tests/testcases/BuilderMinimumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public function testDocumentProfile(): void
public function testDocumentGetters(): void
{
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject'));
$this->assertEquals('horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice', get_class($this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject')));
$this->assertInstanceOf('horstoeko\zugferd\entities\minimum\rsm\CrossIndustryInvoice', $this->invokePrivateMethodFromObject(self::$document, 'getInvoiceObject'));
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getSerializer'));
$this->assertEquals(\JMS\Serializer\Serializer::class, get_class($this->invokePrivateMethodFromObject(self::$document, 'getSerializer')));
$this->assertInstanceOf(\JMS\Serializer\Serializer::class, $this->invokePrivateMethodFromObject(self::$document, 'getSerializer'));
$this->assertNotNull($this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper'));
$this->assertEquals('horstoeko\zugferd\ZugferdObjectHelper', get_class($this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper')));
$this->assertInstanceOf('horstoeko\zugferd\ZugferdObjectHelper', $this->invokePrivateMethodFromObject(self::$document, 'getObjectHelper'));
$this->assertEquals('minimum', self::$document->getProfileDefinitionParameter('name'));
$this->assertEquals('MINIMUM', self::$document->getProfileDefinitionParameter('altname'));
$this->assertEquals('urn:factur-x.eu:1p0:minimum', self::$document->getProfileDefinitionParameter('contextparameter'));
Expand Down Expand Up @@ -2002,7 +2002,7 @@ public function testSetDocumentShipToMultipleContactsAdd(): void
public function testWriteFile(): void
{
(self::$document)->writeFile(getcwd() . "/myfile.xml");
$this->assertTrue(file_exists(getcwd() . "/myfile.xml"));
$this->assertFileExists(getcwd() . "/myfile.xml");
@unlink(getcwd() . "/myfile.xml");
}

Expand Down
16 changes: 8 additions & 8 deletions tests/testcases/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DocumentTest extends TestCase
public function testDocumentCreationMinimum(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_MINIMUM);
$this->assertEquals(ZugferdProfiles::PROFILE_MINIMUM, $doc->getProfileId());
$this->assertSame(ZugferdProfiles::PROFILE_MINIMUM, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
$this->assertEquals("urn:factur-x.eu:1p0:minimum", $doc->getProfileDefinitionParameter("contextparameter"));
Expand All @@ -23,7 +23,7 @@ public function testDocumentCreationMinimum(): void
public function testDocumentCreationBasic(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_BASIC);
$this->assertEquals(ZugferdProfiles::PROFILE_BASIC, $doc->getProfileId());
$this->assertSame(ZugferdProfiles::PROFILE_BASIC, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
$this->assertEquals("urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic", $doc->getProfileDefinitionParameter("contextparameter"));
Expand All @@ -33,7 +33,7 @@ public function testDocumentCreationBasic(): void
public function testDocumentCreationBasicWl(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_BASICWL);
$this->assertEquals(ZugferdProfiles::PROFILE_BASICWL, $doc->getProfileId());
$this->assertSame(ZugferdProfiles::PROFILE_BASICWL, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
$this->assertEquals("urn:factur-x.eu:1p0:basicwl", $doc->getProfileDefinitionParameter("contextparameter"));
Expand All @@ -43,7 +43,7 @@ public function testDocumentCreationBasicWl(): void
public function testDocumentCreationEn16931(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EN16931);
$this->assertEquals(ZugferdProfiles::PROFILE_EN16931, $doc->getProfileId());
$this->assertSame(ZugferdProfiles::PROFILE_EN16931, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
$this->assertEquals("urn:cen.eu:en16931:2017", $doc->getProfileDefinitionParameter("contextparameter"));
Expand All @@ -53,7 +53,7 @@ public function testDocumentCreationEn16931(): void
public function testDocumentCreationExtended(): void
{
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EXTENDED);
$this->assertEquals(ZugferdProfiles::PROFILE_EXTENDED, $doc->getProfileId());
$this->assertSame(ZugferdProfiles::PROFILE_EXTENDED, $doc->getProfileId());
$this->assertArrayHasKey("contextparameter", $doc->getProfileDefinition());
$this->assertArrayHasKey("name", $doc->getProfileDefinition());
$this->assertEquals("urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended", $doc->getProfileDefinitionParameter("contextparameter"));
Expand All @@ -78,11 +78,11 @@ public function testDocumentGetters(): void
$doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EXTENDED);

$this->assertNotNull($this->invokePrivateMethodFromObject($doc, 'getInvoiceObject'));
$this->assertEquals('horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice', get_class($this->invokePrivateMethodFromObject($doc, 'getInvoiceObject')));
$this->assertInstanceOf('horstoeko\zugferd\entities\extended\rsm\CrossIndustryInvoice', $this->invokePrivateMethodFromObject($doc, 'getInvoiceObject'));
$this->assertNotNull($this->invokePrivateMethodFromObject($doc, 'getSerializer'));
$this->assertEquals(\JMS\Serializer\Serializer::class, get_class($this->invokePrivateMethodFromObject($doc, 'getSerializer')));
$this->assertInstanceOf(\JMS\Serializer\Serializer::class, $this->invokePrivateMethodFromObject($doc, 'getSerializer'));
$this->assertNotNull($this->invokePrivateMethodFromObject($doc, 'getObjectHelper'));
$this->assertEquals('horstoeko\zugferd\ZugferdObjectHelper', get_class($this->invokePrivateMethodFromObject($doc, 'getObjectHelper')));
$this->assertInstanceOf('horstoeko\zugferd\ZugferdObjectHelper', $this->invokePrivateMethodFromObject($doc, 'getObjectHelper'));
}

/**
Expand Down
44 changes: 22 additions & 22 deletions tests/testcases/ObjectHelperEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function testGetAmountTypeWithValue(): void
* @var \horstoeko\zugferd\entities\en16931\udt\AmountType
*/
$amounttype = self::$objectHelper->getAmountType(100.0);
$this->assertEquals(100.0, $amounttype->value());
$this->assertEqualsWithDelta(100.0, $amounttype->value(), PHP_FLOAT_EPSILON);
$this->assertEquals("", $amounttype->getCurrencyID());
}

Expand All @@ -331,7 +331,7 @@ public function testGetAmountTypeWithValueAndCurrency(): void
* @var \horstoeko\zugferd\entities\en16931\udt\AmountType
*/
$amounttype = self::$objectHelper->getAmountType(100.0, "EUR");
$this->assertEquals(100.0, $amounttype->value());
$this->assertEqualsWithDelta(100.0, $amounttype->value(), PHP_FLOAT_EPSILON);
$this->assertEquals("EUR", $amounttype->getCurrencyID());
}

Expand All @@ -350,7 +350,7 @@ public function testGetAmountTypeWithValueAndEmptyCurrency(): void
* @var \horstoeko\zugferd\entities\en16931\udt\AmountType
*/
$amounttype = self::$objectHelper->getAmountType(100, "");
$this->assertEquals(100.0, $amounttype->value());
$this->assertEqualsWithDelta(100.0, $amounttype->value(), PHP_FLOAT_EPSILON);
$this->assertEquals("", $amounttype->getCurrencyID());
}

Expand All @@ -369,7 +369,7 @@ public function testGetPercentTypeWithValue(): void
* @var \horstoeko\zugferd\entities\en16931\udt\PercentType
*/
$percenttype = self::$objectHelper->getPercentType(100.0);
$this->assertEquals(100.0, $percenttype->value());
$this->assertEqualsWithDelta(100.0, $percenttype->value(), PHP_FLOAT_EPSILON);
}

public function testGetPercentTypeAllNull(): void
Expand All @@ -387,7 +387,7 @@ public function testGetQuantityTypeWithValue(): void
* @var \horstoeko\zugferd\entities\en16931\udt\QuantityType
*/
$quantitytype = self::$objectHelper->getQuantityType(100.0);
$this->assertEquals(100.0, $quantitytype->value());
$this->assertEqualsWithDelta(100.0, $quantitytype->value(), PHP_FLOAT_EPSILON);
}

public function testGetQuantityTypeWithValueAndUnitCode(): void
Expand All @@ -396,7 +396,7 @@ public function testGetQuantityTypeWithValueAndUnitCode(): void
* @var \horstoeko\zugferd\entities\en16931\udt\QuantityType
*/
$quantitytype = self::$objectHelper->getQuantityType(100.0, "C62");
$this->assertEquals(100.0, $quantitytype->value());
$this->assertEqualsWithDelta(100.0, $quantitytype->value(), PHP_FLOAT_EPSILON);
$this->assertEquals("C62", $quantitytype->getUnitCode());
}

Expand Down Expand Up @@ -1034,8 +1034,8 @@ public function testGetTradeTaxTypeAllValues(): void
$tax = self::$objectHelper->getTradeTaxType("category", "type", 100, 19, 19, "reason", "reasoncode", 100, 10, new \DateTime(), "duedatecode");
$this->assertEquals("category", $tax->getCategoryCode());
$this->assertEquals("type", $tax->getTypeCode());
$this->assertEquals(100.0, $tax->getBasisAmount()->value());
$this->assertEquals(19.0, $tax->getCalculatedAmount()->value());
$this->assertEqualsWithDelta(100.0, $tax->getBasisAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(19.0, $tax->getCalculatedAmount()->value(), PHP_FLOAT_EPSILON);
//$this->assertEquals(19.0, $tax->getRateApplicablePercent()->value());
$this->assertEquals("reasoncode", $tax->getExemptionReasonCode());
$this->assertEquals("reason", $tax->getExemptionReason());
Expand Down Expand Up @@ -1069,13 +1069,13 @@ public function testGetTradeAllowanceChargeTypeAllValues(): void
*/
$calculationpercent = $allowancecharge->getCalculationPercent();

$this->assertEquals(10.0, $allowancecharge->getActualAmount()->value());
$this->assertEqualsWithDelta(10.0, $allowancecharge->getActualAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertTrue($allowancecharge->getChargeIndicator()->getIndicator());
$this->assertEquals("taxtype", $allowancecharge->getCategoryTradeTax()->getTypeCode());
$this->assertEquals("taxcategory", $allowancecharge->getCategoryTradeTax()->getCategoryCode());
$this->assertEquals(19.0, $rateapplicablepercent->value());
$this->assertEqualsWithDelta(19.0, $rateapplicablepercent->value(), PHP_FLOAT_EPSILON);
$this->assertFalse(self::$objectHelper->methodExists($allowancecharge, "getSequenceNumeric"));
$this->assertEquals(2.0, $calculationpercent->value());
$this->assertEqualsWithDelta(2.0, $calculationpercent->value(), PHP_FLOAT_EPSILON);
$this->assertFalse(self::$objectHelper->methodExists($allowancecharge, "getBasisQuantity"));
$this->assertFalse(self::$objectHelper->methodExists($allowancecharge, "getBasisQuantity"));
$this->assertEquals("reason", $allowancecharge->getReason());
Expand Down Expand Up @@ -1117,17 +1117,17 @@ public function testGetTradeSettlementHeaderMonetarySummationTypeAllValues(): vo
* @var \horstoeko\zugferd\entities\en16931\ram\TradeSettlementHeaderMonetarySummationType
*/
$summation = self::$objectHelper->getTradeSettlementHeaderMonetarySummationType(119, 100, 100, 1, 2, 99, 99 * 0.19, 0.0, 10);
$this->assertEquals(119.0, $summation->getGrandTotalAmount()->value());
$this->assertEquals(100.0, $summation->getDuePayableAmount()->value());
$this->assertEquals(100.0, $summation->getLineTotalAmount()->value());
$this->assertEquals(1.0, $summation->getChargeTotalAmount()->value());
$this->assertEquals(2.0, $summation->getAllowanceTotalAmount()->value());
$this->assertEquals(99.0, $summation->getTaxBasisTotalAmount()->value());
$this->assertEqualsWithDelta(119.0, $summation->getGrandTotalAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(100.0, $summation->getDuePayableAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(100.0, $summation->getLineTotalAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(1.0, $summation->getChargeTotalAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(2.0, $summation->getAllowanceTotalAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(99.0, $summation->getTaxBasisTotalAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertIsArray($summation->getTaxTotalAmount());
$this->assertArrayHasKey(0, $summation->getTaxTotalAmount());
$this->assertEquals(99.0 * 0.19, $summation->getTaxTotalAmount()[0]->value());
$this->assertEquals(0.0, $summation->getRoundingAmount()->value());
$this->assertEquals(10.0, $summation->getTotalPrepaidAmount()->value());
$this->assertEqualsWithDelta(0.0, $summation->getRoundingAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(10.0, $summation->getTotalPrepaidAmount()->value(), PHP_FLOAT_EPSILON);
}

public function testGetTradeSettlementHeaderMonetarySummationTypeAllNull(): void
Expand Down Expand Up @@ -1308,8 +1308,8 @@ public function testGetTradePriceTypeAllValues(): void
* @var \horstoeko\zugferd\entities\en16931\ram\TradePriceType
*/
$price = self::$objectHelper->getTradePriceType(1.0, 2.0, "C62");
$this->assertEquals(1.0, $price->getChargeAmount()->value());
$this->assertEquals(2.0, $price->getBasisQuantity()->value());
$this->assertEqualsWithDelta(1.0, $price->getChargeAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(2.0, $price->getBasisQuantity()->value(), PHP_FLOAT_EPSILON);
$this->assertEquals("C62", $price->getBasisQuantity()->getUnitCode());
}

Expand All @@ -1328,7 +1328,7 @@ public function testGetTradeSettlementLineMonetarySummationTypeAllValues(): void
* @var \horstoeko\zugferd\entities\en16931\ram\TradeSettlementLineMonetarySummationType
*/
$summation = self::$objectHelper->getTradeSettlementLineMonetarySummationType(1.0, 6.0, 3.0, 4.0, 5.0, 2.0);
$this->assertEquals(1.0, $summation->getLineTotalAmount()->value());
$this->assertEqualsWithDelta(1.0, $summation->getLineTotalAmount()->value(), PHP_FLOAT_EPSILON);
$this->assertFalse(self::$objectHelper->methodExists($summation, "getChargeTotalAmount"));
$this->assertFalse(self::$objectHelper->methodExists($summation, "getAllowanceTotalAmount"));
$this->assertFalse(self::$objectHelper->methodExists($summation, "getTaxTotalAmount"));
Expand Down
Loading

0 comments on commit bff30b6

Please sign in to comment.