From e78b942301c197c9402540ff536c08f043a26462 Mon Sep 17 00:00:00 2001 From: driesvints Date: Mon, 2 Sep 2024 06:26:21 +0000 Subject: [PATCH] Fix code styling --- .../VATCheckUnavailableException.php | 4 +- tests/Rules/ValidVatNumberTest.php | 4 +- tests/Traits/BillableWithinTheEUTest.php | 10 ++-- tests/VatCalculatorTest.php | 46 +++++++++---------- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/Exceptions/VATCheckUnavailableException.php b/src/Exceptions/VATCheckUnavailableException.php index 60fa704..befb93d 100644 --- a/src/Exceptions/VATCheckUnavailableException.php +++ b/src/Exceptions/VATCheckUnavailableException.php @@ -4,6 +4,4 @@ use Exception; -class VATCheckUnavailableException extends Exception -{ -} +class VATCheckUnavailableException extends Exception {} diff --git a/tests/Rules/ValidVatNumberTest.php b/tests/Rules/ValidVatNumberTest.php index 24a7b4a..7f81d61 100644 --- a/tests/Rules/ValidVatNumberTest.php +++ b/tests/Rules/ValidVatNumberTest.php @@ -65,7 +65,7 @@ public function testValidatesUnavailableVATNumberCheck() VatCalculator::shouldReceive('isValidVATNumber') ->with($vatNumber) ->once() - ->andThrow(new VATCheckUnavailableException()); + ->andThrow(new VATCheckUnavailableException); $validator = Validator::make( ['vat_number' => $vatNumber], @@ -82,7 +82,7 @@ public function testDefaultErrorMessageWorks() VatCalculator::shouldReceive('isValidVATNumber') ->with($vatNumber) ->once() - ->andThrow(new VATCheckUnavailableException()); + ->andThrow(new VATCheckUnavailableException); $validator = Validator::make( ['vat_number' => $vatNumber], diff --git a/tests/Traits/BillableWithinTheEUTest.php b/tests/Traits/BillableWithinTheEUTest.php index eca1b6b..b60d84b 100644 --- a/tests/Traits/BillableWithinTheEUTest.php +++ b/tests/Traits/BillableWithinTheEUTest.php @@ -29,7 +29,7 @@ public function testTaxPercentZeroByDefault() ->with(null, false) ->andReturn(0); - $billable = new BillableWithinTheEUTestStub(); + $billable = new BillableWithinTheEUTestStub; $taxPercent = $billable->getTaxPercent(); $this->assertEquals(0, $taxPercent); } @@ -44,7 +44,7 @@ public function testTaxPercentGetsCalculated() ->with($countryCode, $company) ->andReturn(0.19); - $billable = new BillableWithinTheEUTestStub(); + $billable = new BillableWithinTheEUTestStub; $billable->setTaxForCountry($countryCode, $company); $taxPercent = $billable->getTaxPercent(); $this->assertEquals(19, $taxPercent); @@ -59,7 +59,7 @@ public function testTaxPercentGetsCalculatedByUseTaxFrom() ->with($countryCode, $company) ->andReturn(0.19); - $billable = new BillableWithinTheEUTestStub(); + $billable = new BillableWithinTheEUTestStub; $billable->useTaxFrom($countryCode); $taxPercent = $billable->getTaxPercent(); $this->assertEquals(19, $taxPercent); @@ -74,7 +74,7 @@ public function testTaxPercentGetsCalculatedByUseTaxFromAsBusinessCustomer() ->with($countryCode, $company) ->andReturn(0); - $billable = new BillableWithinTheEUTestStub(); + $billable = new BillableWithinTheEUTestStub; $billable->useTaxFrom($countryCode)->asBusiness(); $taxPercent = $billable->getTaxPercent(); $this->assertEquals(0, $taxPercent); @@ -90,7 +90,7 @@ public function testTaxPercentGetsCalculatedByUseTaxFromAsIndividual() ->with($countryCode, $company) ->andReturn(0.19); - $billable = new BillableWithinTheEUTestStub(); + $billable = new BillableWithinTheEUTestStub; $billable->useTaxFrom($countryCode)->asIndividual(); $taxPercent = $billable->getTaxPercent(); $this->assertEquals(19, $taxPercent); diff --git a/tests/VatCalculatorTest.php b/tests/VatCalculatorTest.php index c252ba8..7864e91 100644 --- a/tests/VatCalculatorTest.php +++ b/tests/VatCalculatorTest.php @@ -39,7 +39,7 @@ public function testCalculateVatWithoutCountryAndConfig() { $net = 25.00; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculate($net); $this->assertEquals(25.00, $result); } @@ -74,7 +74,7 @@ public function testCalculateVatWithPredefinedRulesWithoutConfig() $net = 24.00; $countryCode = 'DE'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculate($net, $countryCode); $this->assertEquals(28.56, $result); $this->assertEquals(0.19, $vatCalculator->getTaxRate()); @@ -132,7 +132,7 @@ public function testCalculatVatWithCountryDirectSetWithoutConfiguration() $net = 24.00; $countryCode = 'DE'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculate($net, $countryCode); $this->assertEquals(28.56, $result); $this->assertEquals(0.19, $vatCalculator->getTaxRate()); @@ -303,7 +303,7 @@ public function testCanValidateValidVATNumber() ->with('vat_calculator', []) ->andReturn([]); - $result = new \stdClass(); + $result = new \stdClass; $result->valid = true; $vatCheck = $this->getMockFromWsdl(__DIR__.'/checkVatService.wsdl', 'VATService'); @@ -324,7 +324,7 @@ public function testCanValidateValidVATNumber() public function testCanValidateInvalidVATNumber() { - $result = new \stdClass(); + $result = new \stdClass; $result->valid = false; $vatCheck = $this->getMockFromWsdl(__DIR__.'/checkVatService.wsdl', 'VATService'); @@ -337,7 +337,7 @@ public function testCanValidateInvalidVATNumber() ->willReturn($result); $vatNumber = 'SomeInvalidNumber'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $vatCalculator->setSoapClient($vatCheck); $result = $vatCalculator->isValidVATNumber($vatNumber); $this->assertFalse($result); @@ -355,7 +355,7 @@ public function testValidateVATNumberReturnsFalseOnSoapFailure() ->willThrowException(new \SoapFault('Server', 'Something went wrong')); $vatNumber = 'SomeInvalidNumber'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $vatCalculator->setSoapClient($vatCheck); $result = $vatCalculator->isValidVATNumber($vatNumber); $this->assertFalse($result); @@ -414,11 +414,11 @@ public function testCannotValidateVATNumberWhenServiceIsDown() { $this->expectException(VATCheckUnavailableException::class); - $result = new \stdClass(); + $result = new \stdClass; $result->valid = false; $vatNumber = 'SomeInvalidNumber'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $vatCalculator->setSoapClient(false); $vatCalculator->isValidVATNumber($vatNumber); } @@ -431,7 +431,7 @@ public function testCanValidateValidUKVATNumber() ->with('vat_calculator', []) ->andReturn([]); - $result = new \stdClass(); + $result = new \stdClass; $result->valid = true; $vatNumber = 'GB 553557881'; @@ -448,7 +448,7 @@ public function testCanValidateInvalidUKVATNumber() ->with('vat_calculator', []) ->andReturn([]); - $result = new \stdClass(); + $result = new \stdClass; $result->valid = true; $vatNumber = 'GB Invalid'; @@ -480,7 +480,7 @@ public function testCompanyInBusinessCountryGetsValidVATRateDirectSet() $net = 24.00; $countryCode = 'DE'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $vatCalculator->setBusinessCountryCode('DE'); $result = $vatCalculator->calculate($net, $countryCode, null, true); $this->assertEquals(28.56, $result); @@ -493,7 +493,7 @@ public function testCompanyOutsideBusinessCountryGetsValidVATRate() $net = 24.00; $countryCode = 'DE'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $vatCalculator->setBusinessCountryCode('NL'); $result = $vatCalculator->calculate($net, $countryCode, null, true); $this->assertEquals(24.00, $result); @@ -506,7 +506,7 @@ public function testReturnsZeroForInvalidCountryCode() $net = 24.00; $countryCode = 'XXX'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculate($net, $countryCode, null, true); $this->assertEquals(24.00, $result); $this->assertEquals(0.00, $vatCalculator->getTaxRate()); @@ -516,7 +516,7 @@ public function testReturnsZeroForInvalidCountryCode() public function testChecksPostalCodeForVATExceptions() { $net = 24.00; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $postalCode = '27498'; // Heligoland $result = $vatCalculator->calculate($net, 'DE', $postalCode, false); $this->assertEquals(24.00, $result); @@ -551,7 +551,7 @@ public function testChecksPostalCodeForVATExceptions() public function testPostalCodesWithoutExceptionsGetStandardRate() { $net = 24.00; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; // Invalid post code $postalCode = 'IGHJ987ERT35'; @@ -602,7 +602,7 @@ public function testPostalCodesWithoutExceptionsOverwrittenByConfiguration() public function testShouldCollectVAT() { - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $this->assertTrue($vatCalculator->shouldCollectVAT('DE')); $this->assertTrue($vatCalculator->shouldCollectVAT('NL')); $this->assertFalse($vatCalculator->shouldCollectVAT('')); @@ -647,7 +647,7 @@ public function testCalculateNetPriceWithoutCountryAndConfig() { $gross = 25.00; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculateNet($gross); $this->assertEquals(25.00, $result); } @@ -675,7 +675,7 @@ public function testCalculateNetPriceWithPredefinedRulesWithoutConfig() $gross = 28.56; $countryCode = 'DE'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculateNet($gross, $countryCode); $this->assertEquals(24.00, $result); $this->assertEquals(0.19, $vatCalculator->getTaxRate()); @@ -733,7 +733,7 @@ public function testCalculateNetPriceWithCountryDirectSetWithoutConfiguration() $gross = 28.56; $countryCode = 'DE'; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculateNet($gross, $countryCode); $this->assertEquals(24.00, $result); @@ -835,7 +835,7 @@ public function testCalculateHighVatType() $type = 'high'; $postalCode = null; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculate($gross, $countryCode, $postalCode, $company, $type); $this->assertEquals(29.04, $result); @@ -849,7 +849,7 @@ public function testCalculateLowVatType() $type = 'low'; $postalCode = null; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; $result = $vatCalculator->calculate($gross, $countryCode, $postalCode, $company, $type); $this->assertEquals(26.16, $result); @@ -927,7 +927,7 @@ public function testIsValidVatNumberFormat() 'SK1234567890', ]; - $vatCalculator = new VatCalculator(); + $vatCalculator = new VatCalculator; foreach ($valid as $format) { $this->assertTrue($vatCalculator->isValidVatNumberFormat($format), "{$format} did not pass validation.");