Faster
This commit is contained in:
parent
bb8424cc60
commit
3ab2cbae60
File diff suppressed because one or more lines are too long
@ -54,8 +54,10 @@ class Calc
|
||||
foreach ($this->article->getOptions() as $option) {
|
||||
|
||||
if ($option instanceof Select || $option instanceof Checkbox || $option instanceof Radio) {
|
||||
if ($option->getSelectedOption() != null && $option->getSelectedOption()->isValid()) {
|
||||
$gesamt = $this->parseEdgeCollection($gesamt, $option, $option->getSelectedOption()->getEdgesCollectionContainer(), [$option->getId()]);
|
||||
foreach($option->getSelectedOptions() as $opt) {
|
||||
if ($opt->isValid()) {
|
||||
$gesamt = $this->parseEdgeCollection($gesamt, $option, $opt->getEdgesCollectionContainer(), [$option->getId()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,9 +55,11 @@ class CalcValues
|
||||
foreach ($this->article->getOptions() as $option) {
|
||||
|
||||
if ($option instanceof Select || $option instanceof Checkbox) {
|
||||
if ($option->getSelectedOption() != null && $option->getSelectedOption()->isValid()) {
|
||||
$price = $this->parseEdgeCollection($price, $option->getId(), $option->getSelectedOption()->getEdgesCollectionContainer());
|
||||
foreach($option->getSelectedOptions() as $opt) {
|
||||
if ($opt->isValid()) {
|
||||
$price = $this->parseEdgeCollection($price, $option->getId(), $opt->getEdgesCollectionContainer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->parseEdgeCollection($price, $option->getId(), $option->getEdgesCollectionContainer());
|
||||
|
||||
@ -53,7 +53,7 @@ class Valid
|
||||
$valid = false;
|
||||
$nextShouldBeValid = false;
|
||||
$isDefaultValid = true;
|
||||
$option->setSelectedOption(null);
|
||||
$option->clearSelected();
|
||||
/** @var Select\Opt $opt */
|
||||
foreach ($option->getOptions() as $opt) {
|
||||
if(count($opt->getEdgesCollectionContainer()) > 0) {
|
||||
@ -114,9 +114,9 @@ class Valid
|
||||
|
||||
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()])) {
|
||||
$opt->setIsSelected(true);
|
||||
$option->addSelectedOption($opt);
|
||||
} else {
|
||||
$opt->setIsSelected(false);
|
||||
//$opt->setIsSelected(false);
|
||||
}
|
||||
|
||||
}else {
|
||||
@ -124,16 +124,16 @@ class Valid
|
||||
if(!$opt->isValid()) {
|
||||
$nextShouldBeValid = true;
|
||||
} else {
|
||||
$option->setSelectedOption($opt);
|
||||
$option->addSelectedOption($opt);
|
||||
}
|
||||
|
||||
} else {
|
||||
if($nextShouldBeValid && $opt->isValid()) {
|
||||
$this->engine->getVariables()[$option->getId()] = $opt->getId();
|
||||
$option->setSelectedOption($opt);
|
||||
$option->addSelectedOption($opt);
|
||||
$nextShouldBeValid = false;
|
||||
} else{
|
||||
$option->setSelectedOption(null);
|
||||
// $option->setSelectedOption(null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -147,7 +147,7 @@ class Valid
|
||||
if($nextShouldBeValid) {
|
||||
foreach($option->getOptions() as $opt) {
|
||||
if($opt->isValid()) {
|
||||
$option->setSelectedOption($opt);
|
||||
$option->addSelectedOption($opt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,12 +633,12 @@ class Engine
|
||||
$count++;
|
||||
}
|
||||
|
||||
// $calcValid = new Valid($this, $this->article);
|
||||
// $calcValid->perform();
|
||||
$calcValid = new Valid($this, $this->article);
|
||||
$calcValid->perform();
|
||||
|
||||
// CALC Values
|
||||
// $calcValues = new CalcValues($this, $this->article);
|
||||
// $calcValues->calc();
|
||||
$calcValues = new CalcValues($this, $this->article);
|
||||
$calcValues->calc();
|
||||
|
||||
// Check if Option is valid
|
||||
// CALC Formel
|
||||
|
||||
@ -3,7 +3,7 @@ namespace PSC\Library\Calc\Option\Parser;
|
||||
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||
use PSC\Library\Calc\Option\Parser\Select\Opt;
|
||||
use PSC\Library\Calc\Option\Parser\Radio\Opt;
|
||||
use PSC\Library\Calc\PaperContainer;
|
||||
use PSC\Library\Calc\Tests\Mock\Paper;
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Type;
|
||||
|
||||
use PSC\Library\Calc\Option\Type\Select\Opt;
|
||||
use ArrayIterator;
|
||||
use PSC\Library\Calc\Option\Type\Checkbox\Opt;
|
||||
|
||||
class Checkbox extends Base
|
||||
{
|
||||
@ -11,10 +12,13 @@ class Checkbox extends Base
|
||||
/** @var \ArrayIterator $options */
|
||||
protected $options;
|
||||
|
||||
protected \ArrayIterator $selectedOptions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->options = new \ArrayIterator();
|
||||
$this->selectedOptions = new \ArrayIterator();
|
||||
}
|
||||
|
||||
public function addOption($option)
|
||||
@ -27,18 +31,19 @@ class Checkbox extends Base
|
||||
*/
|
||||
public function processValue()
|
||||
{
|
||||
$this->selectedOptions = new \ArrayIterator();
|
||||
if(is_array($this->rawValue)) {
|
||||
/** @var \PSC\Library\Calc\Option\Type\Checkbox\Opt $item */
|
||||
foreach($this->options as $item) {
|
||||
if(in_array($item->getId(), $this->rawValue)) {
|
||||
$item->setIsSelected(true);
|
||||
$this->selectedOptions->append($item);
|
||||
}
|
||||
}
|
||||
}elseif($this->rawValue != "") {
|
||||
/** @var \PSC\Library\Calc\Option\Type\Checkbox\Opt $item */
|
||||
foreach($this->options as $item) {
|
||||
if($item->getId() == $this->rawValue) {
|
||||
$item->setIsSelected(true);
|
||||
$this->selectedOptions->append($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,22 +57,25 @@ class Checkbox extends Base
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function clearSelected(): void
|
||||
{
|
||||
$this->selectedOptions = new ArrayIterator();
|
||||
}
|
||||
public function addSelectedOption(Opt $opt): void
|
||||
{
|
||||
$this->selectedOptions->append($opt);
|
||||
}
|
||||
|
||||
|
||||
public function getSelectedOptions()
|
||||
{
|
||||
$tmp = [];
|
||||
|
||||
/** @var Opt $opt */
|
||||
foreach($this->getOptions() as $opt) {
|
||||
if($opt->isSelected()) $tmp[] = $opt;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
return $this->selectedOptions;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
$tmp = array();
|
||||
foreach($this->getSelectedOptions() as $option) {
|
||||
foreach($this->selectedOptions as $option) {
|
||||
$tmp[] = $option->getLabel();
|
||||
}
|
||||
|
||||
|
||||
@ -3,110 +3,8 @@ namespace PSC\Library\Calc\Option\Type\Checkbox;
|
||||
|
||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||
use PSC\Library\Calc\Option\Type\Base;
|
||||
use PSC\Library\Calc\Option\Type\Select\Opt as PSCOpt;
|
||||
|
||||
class Opt
|
||||
class Opt extends PSCOpt
|
||||
{
|
||||
/** @var string $id */
|
||||
protected $id;
|
||||
|
||||
/** @var string $label */
|
||||
protected $label;
|
||||
|
||||
/** @var EdgeCollectionContainer */
|
||||
protected $edgesCollectionContainer;
|
||||
|
||||
/** @var bool */
|
||||
protected $isValid = true;
|
||||
|
||||
/** @var bool */
|
||||
protected $isSelected = false;
|
||||
|
||||
/**
|
||||
* Opt constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->edgesCollectionContainer = new EdgeCollectionContainer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EdgeCollectionContainer
|
||||
*/
|
||||
public function getEdgesCollectionContainer()
|
||||
{
|
||||
return $this->edgesCollectionContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EdgeCollectionContainer $edgesCollectionContainer
|
||||
*/
|
||||
public function setEdgesCollectionContainer($edgesCollectionContainer)
|
||||
{
|
||||
$this->edgesCollectionContainer = $edgesCollectionContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid()
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isValid
|
||||
*/
|
||||
public function setIsValid($isValid)
|
||||
{
|
||||
$this->isValid = $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSelected()
|
||||
{
|
||||
return $this->isSelected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isSelected
|
||||
*/
|
||||
public function setIsSelected($isSelected)
|
||||
{
|
||||
$this->isSelected = $isSelected;
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,7 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Type;
|
||||
|
||||
use PSC\Library\Calc\Option\Type\Select\Opt;
|
||||
use PSC\Library\Calc\Option\Type\Select\PaperOpt;
|
||||
use PSC\Library\Calc\Tests\Mock\Paper;
|
||||
|
||||
class DeliverySelect extends Select
|
||||
{
|
||||
public function getSelectedOption()
|
||||
{
|
||||
/** @var Opt $opt */
|
||||
foreach($this->getOptions() as $opt) {
|
||||
if($opt->isSelected()) return $opt;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -12,8 +12,8 @@ class PaperDbSelect extends Select
|
||||
public function getSelectedOption(): ?Opt
|
||||
{
|
||||
|
||||
if($this->selectedOption != null) {
|
||||
return $this->selectedOption;
|
||||
if(count($this->selectedOptions) > 0) {
|
||||
return $this->selectedOptions[0];
|
||||
}
|
||||
|
||||
if(isset($this->savedCalcValues[$this->getId()]) && $this->savedCalcValues[$this->getId()]['art_nr'] == $this->getRawValue()) {
|
||||
@ -21,7 +21,7 @@ class PaperDbSelect extends Select
|
||||
$opt->setId($this->savedCalcValues[$this->getId()]['art_nr']);
|
||||
$opt->setLabel($this->savedCalcValues[$this->getId()]['description_1']);
|
||||
|
||||
$this->setSelectedOption($opt);
|
||||
$this->addSelectedOption($opt);
|
||||
$paper = $this->newPaperObject;
|
||||
$paper->setId($this->savedCalcValues[$this->getId()]['id']);
|
||||
$paper->setArtNr($this->savedCalcValues[$this->getId()]['art_nr']);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Type;
|
||||
|
||||
use PSC\Library\Calc\Option\Type\Select\Opt;
|
||||
use PSC\Library\Calc\Option\Type\Radio\Opt;
|
||||
|
||||
class Radio extends Base
|
||||
{
|
||||
@ -11,10 +11,13 @@ class Radio extends Base
|
||||
/** @var \ArrayIterator $options */
|
||||
protected $options;
|
||||
|
||||
protected \ArrayIterator $selectedOptions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->options = new \ArrayIterator();
|
||||
$this->selectedOptions = new \ArrayIterator();
|
||||
}
|
||||
|
||||
public function addOption($option)
|
||||
@ -27,11 +30,19 @@ class Radio extends Base
|
||||
*/
|
||||
public function processValue()
|
||||
{
|
||||
if($this->rawValue != "") {
|
||||
/** @var \PSC\Library\Calc\Option\Type\Radio\Opt $item */
|
||||
$this->selectedOptions = new \ArrayIterator();
|
||||
if(is_array($this->rawValue)) {
|
||||
/** @var \PSC\Library\Calc\Option\Type\Checkbox\Opt $item */
|
||||
foreach($this->options as $item) {
|
||||
if(in_array($item->getId(), $this->rawValue)) {
|
||||
$this->selectedOptions->append($item);
|
||||
}
|
||||
}
|
||||
}elseif($this->rawValue != "") {
|
||||
/** @var \PSC\Library\Calc\Option\Type\Checkbox\Opt $item */
|
||||
foreach($this->options as $item) {
|
||||
if($item->getId() == $this->rawValue) {
|
||||
$item->setIsSelected(true);
|
||||
$this->selectedOptions->append($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,17 +56,33 @@ class Radio extends Base
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function getSelectedOption()
|
||||
public function clearSelected(): void
|
||||
{
|
||||
/** @var Opt $opt */
|
||||
foreach($this->getOptions() as $opt) {
|
||||
if($opt->isSelected()) return $opt;
|
||||
}
|
||||
$this->selectedOptions = new ArrayIterator();
|
||||
}
|
||||
public function addSelectedOption(Opt $opt): void
|
||||
{
|
||||
$this->selectedOptions->append($opt);
|
||||
}
|
||||
|
||||
public function getSelectedOption(): ?Opt
|
||||
{
|
||||
return $this->selectedOptions[0]?? null;
|
||||
}
|
||||
|
||||
public function getSelectedOptions()
|
||||
{
|
||||
return $this->selectedOptions;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->getSelectedOption()->getLabel();
|
||||
$tmp = array();
|
||||
foreach($this->selectedOptions as $option) {
|
||||
$tmp[] = $option->getLabel();
|
||||
}
|
||||
|
||||
return implode(", ", $tmp);
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,110 +3,8 @@ namespace PSC\Library\Calc\Option\Type\Radio;
|
||||
|
||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||
use PSC\Library\Calc\Option\Type\Base;
|
||||
use PSC\Library\Calc\Option\Type\Select\Opt as PSCOpt;
|
||||
|
||||
class Opt
|
||||
class Opt extends PSCOpt
|
||||
{
|
||||
/** @var string $id */
|
||||
protected $id;
|
||||
|
||||
/** @var string $label */
|
||||
protected $label;
|
||||
|
||||
/** @var EdgeCollectionContainer */
|
||||
protected $edgesCollectionContainer;
|
||||
|
||||
/** @var bool */
|
||||
protected $isValid = true;
|
||||
|
||||
/** @var bool */
|
||||
protected $isSelected = false;
|
||||
|
||||
/**
|
||||
* Opt constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->edgesCollectionContainer = new EdgeCollectionContainer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $label
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EdgeCollectionContainer
|
||||
*/
|
||||
public function getEdgesCollectionContainer()
|
||||
{
|
||||
return $this->edgesCollectionContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param EdgeCollectionContainer $edgesCollectionContainer
|
||||
*/
|
||||
public function setEdgesCollectionContainer($edgesCollectionContainer)
|
||||
{
|
||||
$this->edgesCollectionContainer = $edgesCollectionContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid()
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isValid
|
||||
*/
|
||||
public function setIsValid($isValid)
|
||||
{
|
||||
$this->isValid = $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSelected()
|
||||
{
|
||||
return $this->isSelected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isSelected
|
||||
*/
|
||||
public function setIsSelected($isSelected)
|
||||
{
|
||||
$this->isSelected = $isSelected;
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@ class Select extends Base
|
||||
/** @var \ArrayIterator $options */
|
||||
protected $options;
|
||||
|
||||
protected ?Opt $selectedOption = null;
|
||||
protected \ArrayIterator $selectedOptions;
|
||||
|
||||
/** @var String $container */
|
||||
protected $container = '';
|
||||
@ -29,6 +29,7 @@ class Select extends Base
|
||||
{
|
||||
parent::__construct();
|
||||
$this->options = new \ArrayIterator();
|
||||
$this->selectedOptions = new \ArrayIterator();
|
||||
}
|
||||
|
||||
public function addOption($option)
|
||||
@ -47,7 +48,7 @@ class Select extends Base
|
||||
*/
|
||||
public function processValue()
|
||||
{
|
||||
$option = $this->getSelectedOption();
|
||||
$option = $this->getSelectedOptions()[0]??null;
|
||||
if($option) {
|
||||
$this->setValue($option->getLabel());
|
||||
$this->setRawValue($option->getId());
|
||||
@ -94,14 +95,24 @@ class Select extends Base
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function getSelectedOption(): ?Opt
|
||||
public function clearSelected(): void
|
||||
{
|
||||
return $this->selectedOption;
|
||||
$this->selectedOptions = new \ArrayIterator();
|
||||
}
|
||||
|
||||
public function setSelectedOption(?Opt $opt): void
|
||||
public function getSelectedOptions(): \ArrayIterator
|
||||
{
|
||||
$this->selectedOption = $opt;
|
||||
return $this->selectedOptions;
|
||||
}
|
||||
|
||||
public function getSelectedOption(): ?Opt
|
||||
{
|
||||
return $this->selectedOptions[0]?? null;
|
||||
}
|
||||
|
||||
public function addSelectedOption(?Opt $opt): void
|
||||
{
|
||||
$this->selectedOptions->append($opt);
|
||||
}
|
||||
|
||||
public function getValidOptions()
|
||||
|
||||
@ -53,11 +53,10 @@ class CalcTest extends TestCase
|
||||
|
||||
public function testOptionCheckbox(): void
|
||||
{
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen2')->getOptions()[0]->isSelected());
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen2')->getOptions()[1]->isSelected());
|
||||
self::assertCount(2, $this->engine->getArticle()->getOptionById('checkboxen2')->getSelectedOptions());
|
||||
|
||||
self::assertFalse($this->engine->getArticle()->getOptionById('checkboxen3')->getOptions()[0]->isSelected());
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen3')->getOptions()[1]->isSelected());
|
||||
self::assertCount(1, $this->engine->getArticle()->getOptionById('checkboxen3')->getSelectedOptions());
|
||||
self::assertSame('2', $this->engine->getArticle()->getOptionById('checkboxen3')->getSelectedOptions()[0]->getId());
|
||||
|
||||
}
|
||||
|
||||
@ -65,11 +64,10 @@ class CalcTest extends TestCase
|
||||
{
|
||||
$this->engine->setVariable('checkboxen1', [1,2]);
|
||||
$this->engine->calc();
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen1')->getOptions()[0]->isSelected());
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen1')->getOptions()[1]->isSelected());
|
||||
self::assertCount(2, $this->engine->getArticle()->getOptionById('checkboxen1')->getSelectedOptions());
|
||||
$this->engine->setVariable('checkboxen1', [2]);
|
||||
self::assertFalse($this->engine->getArticle()->getOptionById('checkboxen1')->getOptions()[0]->isSelected());
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('checkboxen1')->getOptions()[1]->isSelected());
|
||||
self::assertCount(1, $this->engine->getArticle()->getOptionById('checkboxen1')->getSelectedOptions());
|
||||
self::assertSame('2', $this->engine->getArticle()->getOptionById('checkboxen1')->getSelectedOptions()[0]->getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -42,15 +42,16 @@ class CheckboxTest extends TestCase
|
||||
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());
|
||||
self::assertCount(2, $this->engine->getArticle()->getOptionById('checkbox')->getSelectedOptions());
|
||||
self::assertSame('1', $this->engine->getArticle()->getOptionById('checkbox')->getSelectedOptions()[0]->getId());
|
||||
self::assertSame('2', $this->engine->getArticle()->getOptionById('checkbox')->getSelectedOptions()[1]->getId());
|
||||
}
|
||||
|
||||
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());
|
||||
self::assertCount(1, $this->engine->getArticle()->getOptionById('checkbox')->getSelectedOptions());
|
||||
self::assertSame('2', $this->engine->getArticle()->getOptionById('checkbox')->getSelectedOptions()[0]->getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,16 +41,16 @@ class RadioboxTest extends TestCase
|
||||
|
||||
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());
|
||||
self::assertSame(12.0, $this->engine->getPrice());
|
||||
self::assertCount(1, $this->engine->getArticle()->getOptionById('radiobox')->getSelectedOptions());
|
||||
self::assertSame('1', $this->engine->getArticle()->getOptionById('radiobox')->getSelectedOption()->getId());
|
||||
}
|
||||
|
||||
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());
|
||||
self::assertCount(1, $this->engine->getArticle()->getOptionById('radiobox')->getSelectedOptions());
|
||||
self::assertSame('2', $this->engine->getArticle()->getOptionById('radiobox')->getSelectedOption()->getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class selectWithGrenzenTest extends TestCase
|
||||
|
||||
$this->assertCount(6, $article->getOptionsAsArray());
|
||||
|
||||
$this->assertInstanceOf('\PSC\Library\Calc\Option\Type\Select\Opt', $article->getOptionById('umschlag')->getSelectedOption());
|
||||
$this->assertInstanceOf('\PSC\Library\Calc\Option\Type\Select\Opt', $article->getOptionById('umschlag')->getSelectedOptions()[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user