Fix Calc
This commit is contained in:
parent
68dcc64dfd
commit
7c1adb2aba
@ -42,14 +42,10 @@ class Valid
|
|||||||
foreach($this->article->getOptions() as $option) {
|
foreach($this->article->getOptions() as $option) {
|
||||||
if($option instanceof Input) {
|
if($option instanceof Input) {
|
||||||
if($option->getMaxValue() && $option->getMaxValue() <= $option->getRawValue()) {
|
if($option->getMaxValue() && $option->getMaxValue() <= $option->getRawValue()) {
|
||||||
$option->setIsValid(false);
|
|
||||||
$option->addValidationError(new Max($option->getRawValue(), $option->getMaxValue()));
|
$option->addValidationError(new Max($option->getRawValue(), $option->getMaxValue()));
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if($option->getMinValue() && $option->getMinValue() >= $option->getRawValue()) {
|
if($option->getMinValue() && $option->getMinValue() >= $option->getRawValue()) {
|
||||||
$option->setIsValid(false);
|
|
||||||
$option->addValidationError(new Min($option->getRawValue(), $option->getMinValue()));
|
$option->addValidationError(new Min($option->getRawValue(), $option->getMinValue()));
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($option instanceof Select|| $option instanceof Checkbox) {
|
if($option instanceof Select|| $option instanceof Checkbox) {
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class CalcTest extends TestCase
|
|||||||
|
|
||||||
$this->engine->setVariable('breite_frei', 600);
|
$this->engine->setVariable('breite_frei', 600);
|
||||||
$this->engine->calc();
|
$this->engine->calc();
|
||||||
$this->assertFalse($article->getOptionById('breite_frei')->isValid());
|
$this->assertTrue($article->getOptionById('breite_frei')->isValid());
|
||||||
$this->assertEquals(1, count($article->getOptionById('breite_frei')->getValidationErrors()));
|
$this->assertEquals(1, count($article->getOptionById('breite_frei')->getValidationErrors()));
|
||||||
$this->assertInstanceOf(Max::class, $article->getOptionById('breite_frei')->getValidationErrors()->first());
|
$this->assertInstanceOf(Max::class, $article->getOptionById('breite_frei')->getValidationErrors()->first());
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ class CalcTest extends TestCase
|
|||||||
|
|
||||||
$this->engine->setVariable('breite_frei', 10);
|
$this->engine->setVariable('breite_frei', 10);
|
||||||
$this->engine->calc();
|
$this->engine->calc();
|
||||||
$this->assertFalse($article->getOptionById('breite_frei')->isValid());
|
$this->assertTrue($article->getOptionById('breite_frei')->isValid());
|
||||||
$this->assertEquals(1, count($article->getOptionById('breite_frei')->getValidationErrors()));
|
$this->assertEquals(1, count($article->getOptionById('breite_frei')->getValidationErrors()));
|
||||||
$this->assertInstanceOf(Min::class, $article->getOptionById('breite_frei')->getValidationErrors()->first());
|
$this->assertInstanceOf(Min::class, $article->getOptionById('breite_frei')->getValidationErrors()->first());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user