This commit is contained in:
Thomas Peterson 2021-01-04 10:37:41 +01:00
parent e154336cb7
commit 5cfcfdbf4b
7 changed files with 99 additions and 0 deletions

View File

@ -91,4 +91,15 @@ class Select extends Base
} }
} }
public function getValidOptions()
{
$tmp = [];
/** @var Opt $opt */
foreach($this->getOptions() as $opt) {
if($opt->isValid()) $tmp[] = $opt;
}
return $tmp;
}
} }

View File

@ -0,0 +1,48 @@
<?php
namespace PSC\Library\Calc\Tests\Customer\J;
use PSC\Library\Calc\Article;
use PSC\Library\Calc\Engine;
use PSC\Library\Calc\Option\Type\Select;
use PSC\Library\Calc\PaperContainer;
use PSC\Library\Calc\Tests\Mock\PaperRepostory;
class CalcTest 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__ . '/papierContainer.xml')));
$this->engine = new Engine();
$this->engine->setPaperContainer($paperContainer);
$this->engine->setPaperRepository($repository);
$this->engine->setFormulas(file_get_contents(__DIR__ . '/formels.txt'));
$this->engine->setParameters(file_get_contents(__DIR__ . '/parameters.txt'));
$this->engine->setTemplates(file_get_contents(__DIR__ . '/calcTemplates.xml'));
$this->engine->loadString(file_get_contents(__DIR__ . '/calc.xml'));
}
public function tearDown()
{
$this->engine = null;
}
public function testIfDefaultPriceIsOk()
{
/** @var Select $option */
$option = $this->engine->getArticle()->getOptionById('auflage');
foreach($option->getValidOptions() as $option) {
$this->assertTrue($option->isValid());
}
}
}

34
tests/Customer/J/calc.xml Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<kalkulation>
<artikel>
<name>Visitenkarten CCEP</name>
<kommentar>Visitenkarten</kommentar>
<option id="auflage" name="Auflage" type="Select" default="100" require="true" help="Wählen Sie hier bitte Ihre Auflage">
<opt id="100" name="100 Stück">
<auflage>
<grenze pauschale="40.85">1-100</grenze>
</auflage>
</opt>
<opt id="200" name="200 Stück">
<auflage>
<grenze pauschale="51.30">101-200</grenze>
</auflage>
</opt>
<opt id="300" name="300 Stück">
<auflage>
<grenze pauschale="66.09">201-300</grenze>
</auflage>
</opt>
<opt id="400" name="400 Stück">
<auflage>
<grenze pauschale="77.20">301-</grenze>
</auflage>
</opt>
</option>
</artikel>
</kalkulation>

View File

@ -0,0 +1,2 @@
<root>
</root>

View File

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<container>
</container>

View File