From 170ebb0f20d2b5a43879a35075fb4ec45da93891 Mon Sep 17 00:00:00 2001 From: HorstOeko Date: Thu, 12 Oct 2023 17:38:29 +0200 Subject: [PATCH] #25 Centralisation of profile recognition -> Some internal fixes --- src/ZugferdDocument.php | 2 +- src/ZugferdDocumentBuilder.php | 2 +- tests/testcases/DocumentTest.php | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ZugferdDocument.php b/src/ZugferdDocument.php index 6831a2c..5af3684 100644 --- a/src/ZugferdDocument.php +++ b/src/ZugferdDocument.php @@ -75,7 +75,7 @@ class ZugferdDocument * * @codeCoverageIgnore */ - public function __construct(int $profile) + protected function __construct(int $profile) { $this->initProfile($profile); $this->initObjectHelper(); diff --git a/src/ZugferdDocumentBuilder.php b/src/ZugferdDocumentBuilder.php index 2834034..c74bbde 100644 --- a/src/ZugferdDocumentBuilder.php +++ b/src/ZugferdDocumentBuilder.php @@ -72,7 +72,7 @@ class ZugferdDocumentBuilder extends ZugferdDocument * @codeCoverageIgnore * @param int $profile */ - public function __construct(int $profile) + protected function __construct(int $profile) { parent::__construct($profile); diff --git a/tests/testcases/DocumentTest.php b/tests/testcases/DocumentTest.php index 7a2d3a6..ec5be3c 100644 --- a/tests/testcases/DocumentTest.php +++ b/tests/testcases/DocumentTest.php @@ -6,7 +6,7 @@ use \ReflectionProperty; use \horstoeko\zugferd\tests\TestCase; use \horstoeko\zugferd\ZugferdProfiles; -use \horstoeko\zugferd\ZugferdDocument; +use horstoeko\zugferd\ZugferdDocumentBuilder; class DocumentTest extends TestCase { @@ -15,7 +15,7 @@ class DocumentTest extends TestCase */ public function testDocumentCreationMinimum(): void { - $doc = new ZugferdDocument(ZugferdProfiles::PROFILE_MINIMUM); + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_MINIMUM); $this->assertNotNull($doc); $this->assertEquals(ZugferdProfiles::PROFILE_MINIMUM, $doc->profileId); $this->assertArrayHasKey("contextparameter", $doc->profileDefinition); @@ -29,7 +29,7 @@ public function testDocumentCreationMinimum(): void */ public function testDocumentCreationBasic(): void { - $doc = new ZugferdDocument(ZugferdProfiles::PROFILE_BASIC); + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_BASIC); $this->assertNotNull($doc); $this->assertEquals(ZugferdProfiles::PROFILE_BASIC, $doc->profileId); $this->assertArrayHasKey("contextparameter", $doc->profileDefinition); @@ -43,7 +43,7 @@ public function testDocumentCreationBasic(): void */ public function testDocumentCreationBasicWl(): void { - $doc = new ZugferdDocument(ZugferdProfiles::PROFILE_BASICWL); + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_BASICWL); $this->assertNotNull($doc); $this->assertEquals(ZugferdProfiles::PROFILE_BASICWL, $doc->profileId); $this->assertArrayHasKey("contextparameter", $doc->profileDefinition); @@ -57,7 +57,7 @@ public function testDocumentCreationBasicWl(): void */ public function testDocumentCreationEn16931(): void { - $doc = new ZugferdDocument(ZugferdProfiles::PROFILE_EN16931); + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EN16931); $this->assertNotNull($doc); $this->assertEquals(ZugferdProfiles::PROFILE_EN16931, $doc->profileId); $this->assertArrayHasKey("contextparameter", $doc->profileDefinition); @@ -71,7 +71,7 @@ public function testDocumentCreationEn16931(): void */ public function testDocumentCreationExtended(): void { - $doc = new ZugferdDocument(ZugferdProfiles::PROFILE_EXTENDED); + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EXTENDED); $this->assertNotNull($doc); $this->assertEquals(ZugferdProfiles::PROFILE_EXTENDED, $doc->profileId); $this->assertArrayHasKey("contextparameter", $doc->profileDefinition); @@ -86,13 +86,13 @@ public function testDocumentCreationExtended(): void */ public function testDocumentInternals(): void { - $doc = new ZugferdDocument(ZugferdProfiles::PROFILE_EXTENDED); + $doc = ZugferdDocumentBuilder::createNew(ZugferdProfiles::PROFILE_EXTENDED); $property = $this->getPrivateProperty('horstoeko\zugferd\ZugferdDocument', 'serializerBuilder'); $this->assertNotNull($property->getValue($doc)); $property = $this->getPrivateProperty('horstoeko\zugferd\ZugferdDocument', 'serializer'); $this->assertNotNull($property->getValue($doc)); $property = $this->getPrivateProperty('horstoeko\zugferd\ZugferdDocument', 'invoiceObject'); - $this->assertNull($property->getValue($doc)); + $this->assertNotNull($property->getValue($doc)); $property = $this->getPrivateProperty('horstoeko\zugferd\ZugferdDocument', 'objectHelper'); $this->assertNotNull($property->getValue($doc)); }