Skip to content

Commit

Permalink
#25 Centralisation of profile recognition -> Some internal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Oct 12, 2023
1 parent cc3bc1a commit 170ebb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ZugferdDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ZugferdDocument
*
* @codeCoverageIgnore
*/
public function __construct(int $profile)
protected function __construct(int $profile)
{
$this->initProfile($profile);
$this->initObjectHelper();
Expand Down
2 changes: 1 addition & 1 deletion src/ZugferdDocumentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 8 additions & 8 deletions tests/testcases/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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));
}
Expand Down

0 comments on commit 170ebb0

Please sign in to comment.