From 100f2478a65298eeaed850c0c92d462f707b58db Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Mon, 12 Aug 2019 17:59:12 +0200 Subject: [PATCH] Fixes --- src/General/Type/Edge.php | 13 + tests/Complex/ThirdTest.php | 50 +++ tests/TestFiles/Complex2/2.xml | 538 +++++++++++++++++++++++++++++++++ 3 files changed, 601 insertions(+) create mode 100644 tests/Complex/ThirdTest.php create mode 100644 tests/TestFiles/Complex2/2.xml diff --git a/src/General/Type/Edge.php b/src/General/Type/Edge.php index 1784bf8..e02fd44 100644 --- a/src/General/Type/Edge.php +++ b/src/General/Type/Edge.php @@ -174,6 +174,19 @@ class Edge return true; } + $values = $this->getValues(); + + if(is_array($values)) { + foreach($values as $val) { + if (( + (preg_match("/^([0-9]+)-([0-9]+)$/", trim($val), $regs) && ($value >= $regs [1] && $value <= $regs [2])) || + (preg_match("/^([0-9]+)-$/", trim($val), $regs) && $value >= $regs [1])) + ) { + return true; + } + } + } + return false; } diff --git a/tests/Complex/ThirdTest.php b/tests/Complex/ThirdTest.php new file mode 100644 index 0000000..08449fb --- /dev/null +++ b/tests/Complex/ThirdTest.php @@ -0,0 +1,50 @@ +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/2.xml')); + + } + + public function tearDown() + { + $this->engine = null; + } + + public function testIfArticleCountIsCorrect() + { + $this->assertEquals(1, $this->engine->getArticles()->Count()); + } + + public function testIfDefaultPriceIsOk() + { + $this->engine->setVariable('auflage', 1500); + $this->engine->setVariable('druckfarben_inhalt', 2); + $this->assertEquals(152.00 , $this->engine->getPrice()); + } +} \ No newline at end of file diff --git a/tests/TestFiles/Complex2/2.xml b/tests/TestFiles/Complex2/2.xml new file mode 100644 index 0000000..89ceb66 --- /dev/null +++ b/tests/TestFiles/Complex2/2.xml @@ -0,0 +1,538 @@ + + + + Briefbogen A4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file