Uhl
This commit is contained in:
parent
e154336cb7
commit
5cfcfdbf4b
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
48
tests/Customer/J/CalcTest.php
Normal file
48
tests/Customer/J/CalcTest.php
Normal 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
34
tests/Customer/J/calc.xml
Normal 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>
|
||||
2
tests/Customer/J/calcTemplates.xml
Normal file
2
tests/Customer/J/calcTemplates.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<root>
|
||||
</root>
|
||||
0
tests/Customer/J/formels.txt
Normal file
0
tests/Customer/J/formels.txt
Normal file
4
tests/Customer/J/papierContainer.xml
Normal file
4
tests/Customer/J/papierContainer.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<container>
|
||||
|
||||
</container>
|
||||
0
tests/Customer/J/parameters.txt
Normal file
0
tests/Customer/J/parameters.txt
Normal file
Loading…
Reference in New Issue
Block a user