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