Fix Calc
This commit is contained in:
parent
d901c7155a
commit
7a55bf4cc2
@ -14,6 +14,7 @@ use PSC\Library\Calc\General\Type\Edge;
|
|||||||
use PSC\Library\Calc\General\Type\EdgeCollection;
|
use PSC\Library\Calc\General\Type\EdgeCollection;
|
||||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
||||||
use PSC\Library\Calc\Option\Type\Select;
|
use PSC\Library\Calc\Option\Type\Select;
|
||||||
use PSC\Library\Calc\Tests\Mock\Paper;
|
use PSC\Library\Calc\Tests\Mock\Paper;
|
||||||
@ -51,7 +52,7 @@ class Calc
|
|||||||
/** @var Base $option */
|
/** @var Base $option */
|
||||||
foreach($this->article->getOptions() as $option) {
|
foreach($this->article->getOptions() as $option) {
|
||||||
|
|
||||||
if($option instanceof Select) {
|
if($option instanceof Select || $option instanceof Checkbox) {
|
||||||
/** @var Select\Opt $opt */
|
/** @var Select\Opt $opt */
|
||||||
foreach($option->getOptions() as $opt) {
|
foreach($option->getOptions() as $opt) {
|
||||||
if($opt->isValid() && $opt->isSelected()) {
|
if($opt->isValid() && $opt->isSelected()) {
|
||||||
@ -132,6 +133,20 @@ class Calc
|
|||||||
|
|
||||||
$this->engine->setVariable('price', $gesamt);
|
$this->engine->setVariable('price', $gesamt);
|
||||||
}
|
}
|
||||||
|
if ($formel != "" && $option->getId() != 'weight' && $option->isAjaxExport() && !$option->isDisplayOnly() && $option->isAmount()) {
|
||||||
|
$p = 0;
|
||||||
|
$formel = str_replace("tonumber", '$this->toNumber', $formel);
|
||||||
|
eval('@$p = ' . $formel . ';');
|
||||||
|
|
||||||
|
$this->engine->addAjaxVariable($option->getId(), $p);
|
||||||
|
}
|
||||||
|
if ($formel != "" && $option->getId() != 'weight' && !$option->isAjaxExport() && $option->isDisplayOnly() && $option->isAmount()) {
|
||||||
|
$p = 0;
|
||||||
|
$formel = str_replace("tonumber", '$this->toNumber', $formel);
|
||||||
|
eval('@$p = ' . $formel . ';');
|
||||||
|
|
||||||
|
$this->engine->addDisplayVariable($option->getId(), $p);
|
||||||
|
}
|
||||||
if(!$option->isAmount()) {
|
if(!$option->isAmount()) {
|
||||||
$p = 0;
|
$p = 0;
|
||||||
$formel = str_replace("tonumber", '$this->toNumber', $formel);
|
$formel = str_replace("tonumber", '$this->toNumber', $formel);
|
||||||
|
|||||||
@ -15,6 +15,7 @@ use PSC\Library\Calc\General\Type\Edge;
|
|||||||
use PSC\Library\Calc\General\Type\EdgeCollection;
|
use PSC\Library\Calc\General\Type\EdgeCollection;
|
||||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
||||||
use PSC\Library\Calc\Option\Type\Select;
|
use PSC\Library\Calc\Option\Type\Select;
|
||||||
use PSC\Library\Calc\Tests\Mock\Paper;
|
use PSC\Library\Calc\Tests\Mock\Paper;
|
||||||
@ -53,7 +54,7 @@ class CalcValues
|
|||||||
/** @var Base $option */
|
/** @var Base $option */
|
||||||
foreach ($this->article->getOptions() as $option) {
|
foreach ($this->article->getOptions() as $option) {
|
||||||
|
|
||||||
if ($option instanceof Select) {
|
if ($option instanceof Select || $option instanceof Checkbox) {
|
||||||
/** @var Select\Opt $opt */
|
/** @var Select\Opt $opt */
|
||||||
foreach ($option->getOptions() as $opt) {
|
foreach ($option->getOptions() as $opt) {
|
||||||
if ($opt->isValid() && $opt->isSelected()) {
|
if ($opt->isValid() && $opt->isSelected()) {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use PSC\Library\Calc\General\Type\Edge;
|
|||||||
use PSC\Library\Calc\General\Type\EdgeCollection;
|
use PSC\Library\Calc\General\Type\EdgeCollection;
|
||||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Type\Select;
|
use PSC\Library\Calc\Option\Type\Select;
|
||||||
|
|
||||||
class Valid
|
class Valid
|
||||||
@ -37,7 +38,7 @@ class Valid
|
|||||||
/** @var Base $option */
|
/** @var Base $option */
|
||||||
foreach($this->article->getOptions() as $option) {
|
foreach($this->article->getOptions() as $option) {
|
||||||
|
|
||||||
if($option instanceof Select) {
|
if($option instanceof Select|| $option instanceof Checkbox) {
|
||||||
|
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
|
||||||
@ -70,10 +71,19 @@ class Valid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->engine->getVariables()[$option->getId()] == $opt->getId()) {
|
if($option instanceof Checkbox) {
|
||||||
$opt->setIsSelected(true);
|
if (in_array($opt->getId(), $this->engine->getVariables()[$option->getId()])) {
|
||||||
}else{
|
$opt->setIsSelected(true);
|
||||||
$opt->setIsSelected(false);
|
} else {
|
||||||
|
$opt->setIsSelected(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
if ($this->engine->getVariables()[$option->getId()] == $opt->getId()) {
|
||||||
|
$opt->setIsSelected(true);
|
||||||
|
} else {
|
||||||
|
$opt->setIsSelected(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($opt->isValid() && !$valid) {
|
if($opt->isValid() && !$valid) {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use PSC\Library\Calc\Calc\Calc;
|
|||||||
use PSC\Library\Calc\Calc\CalcValues;
|
use PSC\Library\Calc\Calc\CalcValues;
|
||||||
use PSC\Library\Calc\Calc\Valid;
|
use PSC\Library\Calc\Calc\Valid;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
||||||
use PSC\Library\Calc\Option\Type\Select\Opt;
|
use PSC\Library\Calc\Option\Type\Select\Opt;
|
||||||
use PSC\Library\Calc\Option\Type\Text;
|
use PSC\Library\Calc\Option\Type\Text;
|
||||||
@ -37,6 +38,12 @@ class Engine
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
protected $calcVariables = array();
|
protected $calcVariables = array();
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $ajaxVariables = array();
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
protected $displayVariables = array();
|
||||||
|
|
||||||
/** @var float */
|
/** @var float */
|
||||||
protected $price = 0;
|
protected $price = 0;
|
||||||
|
|
||||||
@ -230,7 +237,11 @@ class Engine
|
|||||||
$option->setSavedCalcValues($this->savedCalcValues);
|
$option->setSavedCalcValues($this->savedCalcValues);
|
||||||
|
|
||||||
if(!isset($this->variables[$option->getId()]) && $option->getDefault() !== null && !$option instanceof Text) {
|
if(!isset($this->variables[$option->getId()]) && $option->getDefault() !== null && !$option instanceof Text) {
|
||||||
$this->variables[$option->getId()] = $option->getDefault();
|
if($option instanceof Checkbox) {
|
||||||
|
$this->variables[$option->getId()] = explode(",", $option->getDefault());
|
||||||
|
}else{
|
||||||
|
$this->variables[$option->getId()] = $option->getDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->variables[$option->getId()])) {
|
if(isset($this->variables[$option->getId()])) {
|
||||||
@ -412,4 +423,46 @@ class Engine
|
|||||||
{
|
{
|
||||||
$this->savedCalcValues = $values;
|
$this->savedCalcValues = $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAjaxVariables()
|
||||||
|
{
|
||||||
|
return $this->ajaxVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $ajaxVariables
|
||||||
|
*/
|
||||||
|
public function setAjaxVariables($ajaxVariables)
|
||||||
|
{
|
||||||
|
$this->ajaxVariables = $ajaxVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addAjaxVariable($key, $value)
|
||||||
|
{
|
||||||
|
$this->ajaxVariables[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDisplayVariables()
|
||||||
|
{
|
||||||
|
return $this->displayVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $displayVariables
|
||||||
|
*/
|
||||||
|
public function setDisplayVariables($displayVariables)
|
||||||
|
{
|
||||||
|
$this->displayVariables = $displayVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addDisplayVariable($key, $value)
|
||||||
|
{
|
||||||
|
$this->displayVariables[$key] = $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -359,6 +359,9 @@ class Edge
|
|||||||
(preg_match("/^([0-9]+)-$/", trim($val), $regs) && $value >= $regs[1]))) {
|
(preg_match("/^([0-9]+)-$/", trim($val), $regs) && $value >= $regs[1]))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if(is_array($value) && in_array($val, $value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace PSC\Library\Calc\Option;
|
namespace PSC\Library\Calc\Option;
|
||||||
|
|
||||||
|
use PSC\Library\Calc\Option\Parser\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Parser\Hidden;
|
use PSC\Library\Calc\Option\Parser\Hidden;
|
||||||
use PSC\Library\Calc\Option\Parser\Input;
|
use PSC\Library\Calc\Option\Parser\Input;
|
||||||
use PSC\Library\Calc\Option\Parser\Radio;
|
use PSC\Library\Calc\Option\Parser\Radio;
|
||||||
@ -34,6 +35,9 @@ class Parser
|
|||||||
case 'radio':
|
case 'radio':
|
||||||
$obj = new Radio($node);
|
$obj = new Radio($node);
|
||||||
break;
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
$obj = new Checkbox($node);
|
||||||
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
$obj = new Text($node);
|
$obj = new Text($node);
|
||||||
break;
|
break;
|
||||||
|
|||||||
48
src/Option/Parser/Checkbox.php
Normal file
48
src/Option/Parser/Checkbox.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Option\Parser;
|
||||||
|
|
||||||
|
use Doctrine\Common\Persistence\ObjectRepository;
|
||||||
|
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||||
|
use PSC\Library\Calc\Option\Parser\Checkbox\Opt;
|
||||||
|
use PSC\Library\Calc\PaperContainer;
|
||||||
|
use PSC\Library\Calc\Tests\Mock\Paper;
|
||||||
|
|
||||||
|
class Checkbox extends Base
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $element;
|
||||||
|
|
||||||
|
/** @var \SimpleXMLElement $node */
|
||||||
|
protected $node;
|
||||||
|
|
||||||
|
public function __construct(\SimpleXMLElement $node)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->element = new \PSC\Library\Calc\Option\Type\Checkbox();
|
||||||
|
|
||||||
|
parent::__construct($node);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parse()
|
||||||
|
{
|
||||||
|
parent::parse();
|
||||||
|
|
||||||
|
if(isset($this->node->grenzen) && $this->node->grenzen->children()) {
|
||||||
|
$edgeCollectionContainerParser = new EdgeCollectionContainer($this->node->grenzen);
|
||||||
|
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parse());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->parseModeNormal();
|
||||||
|
|
||||||
|
return $this->element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseModeNormal()
|
||||||
|
{
|
||||||
|
foreach ($this->node->opt as $opt) {
|
||||||
|
$optParser = new Opt($opt);
|
||||||
|
$this->element->addOption($optParser->parse());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
src/Option/Parser/Checkbox/Opt.php
Normal file
30
src/Option/Parser/Checkbox/Opt.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Option\Parser\Checkbox;
|
||||||
|
|
||||||
|
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||||
|
use PSC\Library\Calc\Option\Parser\Base;
|
||||||
|
|
||||||
|
class Opt
|
||||||
|
{
|
||||||
|
protected $element;
|
||||||
|
|
||||||
|
public function __construct(\SimpleXMLElement $node)
|
||||||
|
{
|
||||||
|
$this->element = new \PSC\Library\Calc\Option\Type\Checkbox\Opt();
|
||||||
|
$this->node = $node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parse()
|
||||||
|
{
|
||||||
|
$this->element->setId((string)$this->node['id']);
|
||||||
|
$this->element->setLabel((string)$this->node['name']);
|
||||||
|
|
||||||
|
if($this->node->children()) {
|
||||||
|
$edgeCollectionContainerParser = new EdgeCollectionContainer($this->node);
|
||||||
|
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parse());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->element;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
49
src/Option/Type/Checkbox.php
Normal file
49
src/Option/Type/Checkbox.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Option\Type;
|
||||||
|
|
||||||
|
use PSC\Library\Calc\Option\Type\Select\Opt;
|
||||||
|
|
||||||
|
class Checkbox extends Base
|
||||||
|
{
|
||||||
|
|
||||||
|
static public $type = 'checkbox';
|
||||||
|
|
||||||
|
/** @var \ArrayIterator $options */
|
||||||
|
protected $options;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->options = new \ArrayIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addOption($option)
|
||||||
|
{
|
||||||
|
$this->options->append($option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verarbeitet das Value
|
||||||
|
*/
|
||||||
|
public function processValue()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \ArrayIterator
|
||||||
|
*/
|
||||||
|
public function getOptions()
|
||||||
|
{
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSelectedOptions()
|
||||||
|
{
|
||||||
|
/** @var Opt $opt */
|
||||||
|
foreach($this->getOptions() as $opt) {
|
||||||
|
if($opt->isSelected()) return $opt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
112
src/Option/Type/Checkbox/Opt.php
Normal file
112
src/Option/Type/Checkbox/Opt.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
|
|
||||||
|
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||||
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
|
|
||||||
|
class Opt
|
||||||
|
{
|
||||||
|
/** @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
54
tests/Complex/SixTest.php
Normal file
54
tests/Complex/SixTest.php
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Tests\Complex;
|
||||||
|
|
||||||
|
use PSC\Library\Calc\Article;
|
||||||
|
use PSC\Library\Calc\Engine;
|
||||||
|
use PSC\Library\Calc\PaperContainer;
|
||||||
|
use PSC\Library\Calc\Tests\Mock\PaperRepostory;
|
||||||
|
|
||||||
|
class SixTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var Engine */
|
||||||
|
protected $engine = null;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$repository = new PaperRepostory();
|
||||||
|
|
||||||
|
$paperContainer = new PaperContainer();
|
||||||
|
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ . '/../TestFiles/Complex2/papierContainer.xml')));
|
||||||
|
|
||||||
|
$this->engine = new Engine();
|
||||||
|
$this->engine->setPaperContainer($paperContainer);
|
||||||
|
$this->engine->setPaperRepository($repository);
|
||||||
|
$this->engine->setFormulas(file_get_contents(__DIR__.'/../TestFiles/Complex2/formels.txt'));
|
||||||
|
$this->engine->setParameters(file_get_contents(__DIR__.'/../TestFiles/Complex2/parameters.txt'));
|
||||||
|
|
||||||
|
$this->engine->loadString(file_get_contents(__DIR__ . '/../TestFiles/Complex2/6.xml'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
$this->engine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIfArticleCountIsCorrect()
|
||||||
|
{
|
||||||
|
$this->assertEquals(1, $this->engine->getArticles()->Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIfSelectedOptionsCorrect()
|
||||||
|
{
|
||||||
|
$this->engine->getPrice();
|
||||||
|
$this->assertEquals(37500 , $this->engine->getPrice());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIfCalcCorrect()
|
||||||
|
{
|
||||||
|
$this->engine->setVariable('size', ['a3q','a4q']);
|
||||||
|
$this->engine->getPrice();
|
||||||
|
$this->assertEquals(42000 , $this->engine->getPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,4 +39,16 @@ class CalcTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->assertEquals(10.49 , $this->engine->getPrice());
|
$this->assertEquals(10.49 , $this->engine->getPrice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIfDisplayValues()
|
||||||
|
{
|
||||||
|
$this->assertEquals(10.49 , $this->engine->getPrice());
|
||||||
|
$this->assertCount(1 , $this->engine->getDisplayVariables());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIfAjaxValues()
|
||||||
|
{
|
||||||
|
$this->assertEquals(10.49 , $this->engine->getPrice());
|
||||||
|
$this->assertCount(1 , $this->engine->getDisplayVariables());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,14 @@
|
|||||||
<!-- Lieferzeit Gesamt DISPLAY -->
|
<!-- Lieferzeit Gesamt DISPLAY -->
|
||||||
<option id="lieferzeit_gesamt_display" name="lieferzeit_gesamt_display" type="Hidden" default="1" displayOnly="1">
|
<option id="lieferzeit_gesamt_display" name="lieferzeit_gesamt_display" type="Hidden" default="1" displayOnly="1">
|
||||||
<auflage>
|
<auflage>
|
||||||
<grenze formel="5">-1</grenze>
|
<grenze formel="5">1-</grenze>
|
||||||
|
</auflage>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<!-- Lieferzeit Gesamt DISPLAY -->
|
||||||
|
<option id="lieferzeit_gesamt_ajax" name="lieferzeit_gesamt_display" type="Hidden" default="1" exportAjax="1">
|
||||||
|
<auflage>
|
||||||
|
<grenze formel="5">1-</grenze>
|
||||||
</auflage>
|
</auflage>
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
|||||||
23
tests/Parse/Option/CheckboxTest.php
Normal file
23
tests/Parse/Option/CheckboxTest.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||||
|
|
||||||
|
use PSC\Library\Calc\Option\Parser;
|
||||||
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
|
use PSC\Library\Calc\Option\Type\Input;
|
||||||
|
use PSC\Library\Calc\PaperContainer\Container;
|
||||||
|
|
||||||
|
class CheckboxTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testIfCorrectType()
|
||||||
|
{
|
||||||
|
$parser = new Parser();
|
||||||
|
/** @var Parser\Checkbox $obj */
|
||||||
|
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/checkbox.xml')));
|
||||||
|
|
||||||
|
/** @var Checkbox $element */
|
||||||
|
$element = $obj->parse();
|
||||||
|
|
||||||
|
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Checkbox', $element);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
52
tests/TestFiles/Complex2/6.xml
Normal file
52
tests/TestFiles/Complex2/6.xml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<kalkulation>
|
||||||
|
<artikel>
|
||||||
|
<name>TEST Checkbox</name>
|
||||||
|
<kommentar/>
|
||||||
|
<uploads>
|
||||||
|
<upload id="inhalt" name="Druckdaten" description="Bitte laden sie eine PDF für den Druck hoch"/>
|
||||||
|
</uploads>
|
||||||
|
|
||||||
|
<!-- Beginn der Eingabemaske -->
|
||||||
|
|
||||||
|
<option id="auflage" name="Auflage" type="Select" default="1500">
|
||||||
|
<opt id="500" name="500 Exemplare"></opt>
|
||||||
|
<opt id="750" name="750 Exemplare"></opt>
|
||||||
|
<opt id="1000" name="1.000 Exemplare"></opt>
|
||||||
|
<opt id="1500" name="1.500 Exemplare"></opt>
|
||||||
|
<opt id="2000" name="2.000 Exemplare"></opt>
|
||||||
|
<opt id="3000" name="3.000 Exemplare"></opt>
|
||||||
|
<opt id="5000" name="5.000 Exemplare"></opt>
|
||||||
|
<opt id="7500" name="7.500 Exemplare"></opt>
|
||||||
|
<opt id="10000" name="10.000 Exemplare"></opt>
|
||||||
|
<opt id="12500" name="12.500 Exemplare"></opt>
|
||||||
|
<opt id="15000" name="15.000 Exemplare"></opt>
|
||||||
|
<opt id="20000" name="20.000 Exemplare"></opt>
|
||||||
|
<opt id="30000" name="30.000 Exemplare"></opt>
|
||||||
|
<opt id="40000" name="40.000 Exemplare"></opt>
|
||||||
|
<opt id="50000" name="50.000 Exemplare"></opt>
|
||||||
|
<opt id="100000" name="100.000 Exemplare"></opt>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="size" name="Wählen Sie eine Größe" type="Checkbox" width="3" default="a4h,a4q" require="true">
|
||||||
|
<opt id="a5h" name="DIN A5 Hochformat (210x148mm)"></opt>
|
||||||
|
<opt id="a5q" name="DIN A5 Querformat (148x210mm)"></opt>
|
||||||
|
<opt id="a4h" name="DIN A4 Hochformat (297 x 210 mm)"></opt>
|
||||||
|
<opt id="a4q" name="DIN A4 Querformat (210x297mm)"></opt>
|
||||||
|
<opt id="a3h" name="DIN A3 Hochformat (420x297mm)"></opt>
|
||||||
|
<opt id="a3q" name="DIN A3 Querformat (297x420mm)"></opt>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
|
||||||
|
<option id="calc" name="Calc" type="Hidden">
|
||||||
|
<size>
|
||||||
|
<grenze formel="$Vauflage$V*10">a5h</grenze>
|
||||||
|
<grenze formel="$Vauflage$V*12">a5q,a4h</grenze>
|
||||||
|
<grenze formel="$Vauflage$V*13">a4q,a3h</grenze>
|
||||||
|
<grenze formel="$Vauflage$V*15">a3q</grenze>
|
||||||
|
</size>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
|
||||||
|
</artikel>
|
||||||
|
</kalkulation>
|
||||||
9
tests/TestFiles/Option/checkbox.xml
Normal file
9
tests/TestFiles/Option/checkbox.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<option id="size" name="Wählen Sie eine Größe" type="Checkbox" width="3" default="a4h,a4q" require="true" help="Wählen Sie eine Größe">
|
||||||
|
<opt id="a5h" name="DIN A5 Hochformat (210x148mm)"></opt>
|
||||||
|
<opt id="a5q" name="DIN A5 Querformat (148x210mm)"></opt>
|
||||||
|
<opt id="a4h" name="DIN A4 Hochformat (297 x 210 mm)"></opt>
|
||||||
|
<opt id="a4q" name="DIN A4 Querformat (210x297mm)"></opt>
|
||||||
|
<opt id="a3h" name="DIN A3 Hochformat (420x297mm)"></opt>
|
||||||
|
<opt id="a3q" name="DIN A3 Querformat (297x420mm)"></opt>
|
||||||
|
</option>
|
||||||
Loading…
Reference in New Issue
Block a user