Fix Calc
This commit is contained in:
parent
79a15727ac
commit
50450a5723
File diff suppressed because one or more lines are too long
@ -94,8 +94,10 @@ class Valid
|
|||||||
|
|
||||||
if($option->getDefault() === null && $opt->isValid()) {
|
if($option->getDefault() === null && $opt->isValid()) {
|
||||||
$option->setDefault($opt->getId());
|
$option->setDefault($opt->getId());
|
||||||
|
if(!$this->engine->hasVariable($option->getId())) {
|
||||||
$this->engine->setVariable($option->getId(), $opt->getId());
|
$this->engine->setVariable($option->getId(), $opt->getId());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($option instanceof Checkbox) {
|
if($option instanceof Checkbox) {
|
||||||
if (isset($this->engine->getVariables()[$option->getId()]) && is_array($this->engine->getVariables()[$option->getId()]) && in_array($opt->getId(), $this->engine->getVariables()[$option->getId()])) {
|
if (isset($this->engine->getVariables()[$option->getId()]) && is_array($this->engine->getVariables()[$option->getId()]) && in_array($opt->getId(), $this->engine->getVariables()[$option->getId()])) {
|
||||||
|
|||||||
@ -440,6 +440,11 @@ class Engine
|
|||||||
$this->variables[$var] = $value;
|
$this->variables[$var] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasVariable($var): bool
|
||||||
|
{
|
||||||
|
return isset($this->variables[$var]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -52,4 +52,19 @@ class CalcTest extends TestCase
|
|||||||
$this->assertTrue($this->engine->getArticle()->getOptionById('defa')->isValid());
|
$this->assertTrue($this->engine->getArticle()->getOptionById('defa')->isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testContainerSelectIgnoreDefaultBinden(): void
|
||||||
|
{
|
||||||
|
$this->engine->setVariable('binden', 'leimes');
|
||||||
|
$this->engine->calc();
|
||||||
|
$this->assertTrue($this->engine->getArticle()->getOptionById('dd')->isValid());
|
||||||
|
$this->assertTrue($this->engine->getArticle()->getOptionById('defa')->isValid());
|
||||||
|
|
||||||
|
$this->engine->setVariable('dd', 'ddleim');
|
||||||
|
$this->engine->calc();
|
||||||
|
|
||||||
|
$this->assertTrue($this->engine->getArticle()->getOptionById('dd')->isValid());
|
||||||
|
$this->assertSame('ddleim', $this->engine->getArticle()->getOptionById('dd')->getRawValue());
|
||||||
|
$this->assertTrue($this->engine->getArticle()->getOptionById('defa')->isValid());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user