-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
HorstOeko
committed
Oct 3, 2023
1 parent
1d8899c
commit 4a91fd8
Showing
7 changed files
with
248 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace horstoeko\zugferd\tests\testcases; | ||
|
||
use \horstoeko\zugferd\tests\TestCase; | ||
use \horstoeko\zugferd\ZugferdDocumentJsonExporter; | ||
use \horstoeko\zugferd\ZugferdDocumentReader; | ||
|
||
class JsonExporterTest extends TestCase | ||
{ | ||
/** | ||
* @var ZugferdDocumentReader | ||
*/ | ||
protected static $document; | ||
|
||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$document = ZugferdDocumentReader::readAndGuessFromFile(dirname(__FILE__) . "/../assets/xrechnung_simple_2.xml"); | ||
} | ||
|
||
/** | ||
* @covers \horstoeko\zugferd\ZugferdDocumentJsonExporter::toJsonString | ||
*/ | ||
public function testToJsonString(): void | ||
{ | ||
$exporter = new ZugferdDocumentJsonExporter(static::$document); | ||
$jsonString = $exporter->toJsonString(); | ||
|
||
$this->assertStringStartsWith('{"ExchangedDocumentContext"', $jsonString); | ||
$this->assertStringContainsString('{"GuidelineSpecifiedDocumentContextParameter"', $jsonString); | ||
} | ||
|
||
/** | ||
* @covers \horstoeko\zugferd\ZugferdDocumentJsonExporter::toPrettyJsonString | ||
*/ | ||
public function testToPrettyJsonString(): void | ||
{ | ||
$exporter = new ZugferdDocumentJsonExporter(static::$document); | ||
$jsonString = $exporter->toPrettyJsonString(); | ||
|
||
$this->assertStringStartsWith("{\n \"ExchangedDocumentContext\": {\n \"GuidelineSpecifiedDocumentContextParameter\": {", $jsonString); | ||
} | ||
|
||
/** | ||
* @covers \horstoeko\zugferd\ZugferdDocumentJsonExporter::toJsonObject | ||
*/ | ||
public function testToJsonObject(): void | ||
{ | ||
$exporter = new ZugferdDocumentJsonExporter(static::$document); | ||
$jsonObject = $exporter->toJsonObject(); | ||
|
||
$this->assertInstanceOf("stdClass", $jsonObject); | ||
$this->assertTrue(isset($jsonObject->ExchangedDocumentContext)); | ||
$this->assertTrue(isset($jsonObject->ExchangedDocumentContext->GuidelineSpecifiedDocumentContextParameter)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.