From 70eaae087efeda63818ed7200c8575a8da3c5fda Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Sat, 19 Sep 2020 14:27:46 +0200 Subject: [PATCH] Fix Calc Papedruck --- src/Engine.php | 5 +++ tests/Customer/G/CalcTest.php | 42 +++++++++++++++++++ tests/Customer/G/calc.xml | 60 ++++++++++++++++++++++++++++ tests/Customer/G/calcTemplates.xml | 4 ++ tests/Customer/G/formels.txt | 0 tests/Customer/G/papierContainer.xml | 4 ++ tests/Customer/G/parameters.txt | 0 7 files changed, 115 insertions(+) create mode 100644 tests/Customer/G/CalcTest.php create mode 100644 tests/Customer/G/calc.xml create mode 100644 tests/Customer/G/calcTemplates.xml create mode 100644 tests/Customer/G/formels.txt create mode 100644 tests/Customer/G/papierContainer.xml create mode 100644 tests/Customer/G/parameters.txt diff --git a/src/Engine.php b/src/Engine.php index d304078..e5a8889 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -216,6 +216,11 @@ class Engine $this->article = $this->getArticleByName($this->activeArticle); + if($this->article === null) { + $this->dirty = false; + return true; + } + // Prefill with defaults /** @var Base $option */ foreach($this->article->getOptions() as $option) { diff --git a/tests/Customer/G/CalcTest.php b/tests/Customer/G/CalcTest.php new file mode 100644 index 0000000..dd8f77d --- /dev/null +++ b/tests/Customer/G/CalcTest.php @@ -0,0 +1,42 @@ +parse(simplexml_load_string(file_get_contents(__DIR__ . '/papierContainer.xml'))); + + $this->engine = new Engine(); + $this->engine->setPaperContainer($paperContainer); + $this->engine->setPaperRepository($repository); + $this->engine->setFormulas(file_get_contents(__DIR__ . '/formels.txt')); + $this->engine->setParameters(file_get_contents(__DIR__ . '/parameters.txt')); + $this->engine->setTemplates(file_get_contents(__DIR__ . '/calcTemplates.xml')); + + $this->engine->loadString(file_get_contents(__DIR__ . '/calc.xml')); + + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfDefaultPriceIsOk() + { + $this->assertEquals(10.49 , $this->engine->getPrice()); + } +} \ No newline at end of file diff --git a/tests/Customer/G/calc.xml b/tests/Customer/G/calc.xml new file mode 100644 index 0000000..3e06b62 --- /dev/null +++ b/tests/Customer/G/calc.xml @@ -0,0 +1,60 @@ + + + + Zubehör + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Customer/G/calcTemplates.xml b/tests/Customer/G/calcTemplates.xml new file mode 100644 index 0000000..b3f7d62 --- /dev/null +++ b/tests/Customer/G/calcTemplates.xml @@ -0,0 +1,4 @@ + + + + diff --git a/tests/Customer/G/formels.txt b/tests/Customer/G/formels.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/Customer/G/papierContainer.xml b/tests/Customer/G/papierContainer.xml new file mode 100644 index 0000000..8ec6de3 --- /dev/null +++ b/tests/Customer/G/papierContainer.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/Customer/G/parameters.txt b/tests/Customer/G/parameters.txt new file mode 100644 index 0000000..e69de29