diff --git a/src/Engine.php b/src/Engine.php
index 259f212..c57109c 100644
--- a/src/Engine.php
+++ b/src/Engine.php
@@ -238,6 +238,10 @@ class Engine
public function calc() {
+ $this->debugCalcFormel = [];
+ $this->debugCalcVariables = [];
+ $this->debugFlatPrice = [];
+ $this->debugPrice = [];
$this->price = 0;
$tmp = [];
diff --git a/tests/Customer/R/CalcTest.php b/tests/Customer/R/CalcTest.php
index b8ae586..f450ee0 100644
--- a/tests/Customer/R/CalcTest.php
+++ b/tests/Customer/R/CalcTest.php
@@ -72,4 +72,11 @@ class CalcTest extends TestCase
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen1')->getOptions()[1]->isSelected());
}
+
+ public function testOptionCalcCheckbox(): void
+ {
+ $this->assertEquals(1048, $this->engine->getPrice());
+ $this->engine->setVariable('radio1', 1);
+ $this->assertEquals(1044, $this->engine->getPrice());
+ }
}
diff --git a/tests/Customer/R/CheckboxTest.php b/tests/Customer/R/CheckboxTest.php
new file mode 100644
index 0000000..36d87f7
--- /dev/null
+++ b/tests/Customer/R/CheckboxTest.php
@@ -0,0 +1,56 @@
+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_checkbox.xml'));
+
+ }
+
+ public function tearDown(): void
+ {
+ $this->engine = null;
+ }
+
+ public function testCalcDefault(): void
+ {
+ self::assertSame(26.0, $this->engine->getPrice());
+ self::assertTrue($this->engine->getArticle()->getOptionById('checkbox')->getOptions()[0]->isSelected());
+ self::assertTrue($this->engine->getArticle()->getOptionById('checkbox')->getOptions()[1]->isSelected());
+ }
+
+ public function testCalcOnly2(): void
+ {
+ $this->engine->setVariable('checkbox', [2]);
+ self::assertSame(14.0, $this->engine->getPrice());
+ self::assertFalse($this->engine->getArticle()->getOptionById('checkbox')->getOptions()[0]->isSelected());
+ self::assertTrue($this->engine->getArticle()->getOptionById('checkbox')->getOptions()[1]->isSelected());
+ }
+}
diff --git a/tests/Customer/R/RadioboxTest.php b/tests/Customer/R/RadioboxTest.php
new file mode 100644
index 0000000..8d02eb0
--- /dev/null
+++ b/tests/Customer/R/RadioboxTest.php
@@ -0,0 +1,56 @@
+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_radiobox.xml'));
+
+ }
+
+ public function tearDown(): void
+ {
+ $this->engine = null;
+ }
+
+ public function testCalcDefault(): void
+ {
+ $this->assertSame(12.0, $this->engine->getPrice());
+ self::assertFalse($this->engine->getArticle()->getOptionById('radiobox')->getOptions()[1]->isSelected());
+ self::assertTrue($this->engine->getArticle()->getOptionById('radiobox')->getOptions()[0]->isSelected());
+ }
+
+ public function testCalcOnly2(): void
+ {
+ $this->engine->setVariable('radiobox', 2);
+ $this->assertSame(14.0, $this->engine->getPrice());
+ self::assertFalse($this->engine->getArticle()->getOptionById('radiobox')->getOptions()[0]->isSelected());
+ self::assertTrue($this->engine->getArticle()->getOptionById('radiobox')->getOptions()[1]->isSelected());
+ }
+}
diff --git a/tests/Customer/R/calc.xml b/tests/Customer/R/calc.xml
index 103fe7c..0b06d6f 100644
--- a/tests/Customer/R/calc.xml
+++ b/tests/Customer/R/calc.xml
@@ -50,11 +50,32 @@
-
-
+
+
+
+
+
+
@@ -148,6 +169,24 @@
+
+
+
+
+
diff --git a/tests/Customer/R/calc_checkbox.xml b/tests/Customer/R/calc_checkbox.xml
new file mode 100644
index 0000000..ce65c7a
--- /dev/null
+++ b/tests/Customer/R/calc_checkbox.xml
@@ -0,0 +1,20 @@
+
+
+
+ Checkbox Grenze Formel
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/Customer/R/calc_radiobox.xml b/tests/Customer/R/calc_radiobox.xml
new file mode 100644
index 0000000..5d233ef
--- /dev/null
+++ b/tests/Customer/R/calc_radiobox.xml
@@ -0,0 +1,20 @@
+
+
+
+ Checkbox Grenze Formel
+
+
+
+
+
+
+
+
\ No newline at end of file