From 7fc71f021ea51d6778bb05b1a7bad9ec445a9788 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Tue, 13 Aug 2019 13:34:54 +0200 Subject: [PATCH] Fixes --- src/General/Parser/Edge.php | 2 +- tests/Complex/FiveTest.php | 49 + tests/Complex/FourTest.php | 48 + tests/Mock/PaperRepostory.php | 7 + tests/TestFiles/Complex2/3.xml | 538 +++++++++++ tests/TestFiles/Complex2/4.xml | 888 +++++++++++++++++++ tests/TestFiles/Complex2/papierContainer.xml | 12 + 7 files changed, 1543 insertions(+), 1 deletion(-) create mode 100644 tests/Complex/FiveTest.php create mode 100644 tests/Complex/FourTest.php create mode 100644 tests/TestFiles/Complex2/3.xml create mode 100644 tests/TestFiles/Complex2/4.xml diff --git a/src/General/Parser/Edge.php b/src/General/Parser/Edge.php index dac9371..de962f1 100644 --- a/src/General/Parser/Edge.php +++ b/src/General/Parser/Edge.php @@ -39,7 +39,7 @@ class Edge } if(isset($this->node->attributes()->value) && $this->node->children()) { - $edge->setValues([(string)$this->node->attributes()->value]); + $edge->setValues(explode(",", trim((string)$this->node->attributes()->value))); if($this->node->children()) { $edgeCollectionContainerParser = new EdgeCollectionContainer($this->node); $edge->setEdgesCollectionContainer($edgeCollectionContainerParser->parse()); diff --git a/tests/Complex/FiveTest.php b/tests/Complex/FiveTest.php new file mode 100644 index 0000000..f03b4ee --- /dev/null +++ b/tests/Complex/FiveTest.php @@ -0,0 +1,49 @@ +parse(simplexml_load_string(file_get_contents(__DIR__ . '/../TestFiles/Complex2/papierContainer.xml'))); + + $this->engine = new Engine(); + $this->engine->setPaperContainer($paperContainer); + $this->engine->setPaperRepository($repository); + $this->engine->setFormulas(file_get_contents(__DIR__.'/../TestFiles/Complex2/formels.txt')); + $this->engine->setParameters(file_get_contents(__DIR__.'/../TestFiles/Complex2/parameters.txt')); + + $this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/Complex2/4.xml')); + + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfArticleCountIsCorrect() + { + $this->assertEquals(1, $this->engine->getArticles()->Count()); + } + + public function testIfDefaultPriceIsOk() + { + $this->engine->setVariable('auflage', '10000'); + $this->assertEquals(4204.00 , $this->engine->getPrice()); + } +} \ No newline at end of file diff --git a/tests/Complex/FourTest.php b/tests/Complex/FourTest.php new file mode 100644 index 0000000..edfbd00 --- /dev/null +++ b/tests/Complex/FourTest.php @@ -0,0 +1,48 @@ +parse(simplexml_load_string(file_get_contents(__DIR__ . '/../TestFiles/Complex2/papierContainer.xml'))); + + $this->engine = new Engine(); + $this->engine->setPaperContainer($paperContainer); + $this->engine->setPaperRepository($repository); + $this->engine->setFormulas(file_get_contents(__DIR__.'/../TestFiles/Complex2/formels.txt')); + $this->engine->setParameters(file_get_contents(__DIR__.'/../TestFiles/Complex2/parameters.txt')); + + $this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/Complex2/3.xml')); + + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfArticleCountIsCorrect() + { + $this->assertEquals(1, $this->engine->getArticles()->Count()); + } + + public function testIfDefaultPriceIsOk() + { + $this->assertEquals(152.00 , $this->engine->getPrice()); + } +} \ No newline at end of file diff --git a/tests/Mock/PaperRepostory.php b/tests/Mock/PaperRepostory.php index d952a9c..944787e 100644 --- a/tests/Mock/PaperRepostory.php +++ b/tests/Mock/PaperRepostory.php @@ -178,6 +178,13 @@ class PaperRepostory implements ObjectRepository $papier['grasnatur85']->setDescription1('Graspapier 50% Faseranteil (85 g/m²)'); $papier['grasnatur85']->setDescription2('Graspapier 50% Faseranteil (85 g/m²)'); + $papier['grasnatur205'] = new Paper(); + $papier['grasnatur205']->setArtNr('grasnatur205'); + $papier['grasnatur205']->setGrammatur('205'); + $papier['grasnatur205']->setPreis('160'); + $papier['grasnatur205']->setVolume('1.2'); + $papier['grasnatur205']->setDescription1('Graspapier 50% Faseranteil (205 g/m²)'); + $papier['grasnatur205']->setDescription2('Graspapier 50% Faseranteil (205 g/m²)'); return $papier[$criteria['artNr']]; diff --git a/tests/TestFiles/Complex2/3.xml b/tests/TestFiles/Complex2/3.xml new file mode 100644 index 0000000..89ceb66 --- /dev/null +++ b/tests/TestFiles/Complex2/3.xml @@ -0,0 +1,538 @@ + + + + Briefbogen A4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/TestFiles/Complex2/4.xml b/tests/TestFiles/Complex2/4.xml new file mode 100644 index 0000000..75eb267 --- /dev/null +++ b/tests/TestFiles/Complex2/4.xml @@ -0,0 +1,888 @@ + + + + Broschüre RDH + kein + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //Hier muss berechnet werden, wieviele Druckbogen wir für den Digitaldruck brauchen + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/TestFiles/Complex2/papierContainer.xml b/tests/TestFiles/Complex2/papierContainer.xml index f0bd1e9..13c3579 100644 --- a/tests/TestFiles/Complex2/papierContainer.xml +++ b/tests/TestFiles/Complex2/papierContainer.xml @@ -2,6 +2,18 @@ + + + + + + + + + + \ No newline at end of file