From f2bf130ab67bb8560884242703857dbc4085d670 Mon Sep 17 00:00:00 2001 From: "DESKTOP-E17406D\\boonkerz" Date: Fri, 28 Oct 2022 14:06:09 +0200 Subject: [PATCH] Fix Calc --- src/Calc/Valid.php | 10 ++++++++++ tests/Customer/Q/CalcTest.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/Calc/Valid.php b/src/Calc/Valid.php index b6974fe..1339210 100644 --- a/src/Calc/Valid.php +++ b/src/Calc/Valid.php @@ -113,6 +113,16 @@ class Valid $valid = true; } } + + if($nextShouldBeValid) { + foreach($option->getOptions() as $opt) { + if($opt->isValid()) { + $opt->setIsSelected(true); + break; + } + } + } + $option->processValue(); $option->setIsValid($valid); diff --git a/tests/Customer/Q/CalcTest.php b/tests/Customer/Q/CalcTest.php index 8319768..488a527 100644 --- a/tests/Customer/Q/CalcTest.php +++ b/tests/Customer/Q/CalcTest.php @@ -55,4 +55,14 @@ class CalcTest extends TestCase } + public function testCalcPriceDefaultChangeSecound(): void + { + $this->engine->setVariable('print', '885731'); + $this->assertSame(50.29, $this->engine->getPrice()); + $this->engine->setVariable('print', '885731'); + $this->engine->setVariable('auflage', '40329547'); + $this->assertSame(276.48, $this->engine->getPrice()); + $this->engine->setVariable('print', '885730'); + $this->assertSame(11.22, $this->engine->getPrice()); + } }