Fix Test
This commit is contained in:
parent
7486301b88
commit
b7d5623310
File diff suppressed because one or more lines are too long
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Parser;
|
||||
|
||||
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||
|
||||
class Text extends Base
|
||||
{
|
||||
|
||||
@ -16,6 +18,11 @@ class Text extends Base
|
||||
{
|
||||
parent::parse();
|
||||
|
||||
if($this->node->children()) {
|
||||
$edgeCollectionContainerParser = new EdgeCollectionContainer($this->node);
|
||||
$this->element->setEdgesCollectionContainer($edgeCollectionContainerParser->parse());
|
||||
}
|
||||
|
||||
return $this->element;
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,12 @@ class Select extends Base
|
||||
}
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
$this->processValue();
|
||||
return parent::getValue(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
|
||||
54
tests/Type/Text/CalcTest.php
Normal file
54
tests/Type/Text/CalcTest.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Type\Text;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PSC\Library\Calc\Article;
|
||||
use PSC\Library\Calc\Engine;
|
||||
use PSC\Library\Calc\PaperContainer;
|
||||
use PSC\Library\Calc\Tests\Mock\PaperRepostory;
|
||||
use function Symfony\Component\String\s;
|
||||
|
||||
class CalcTest extends TestCase
|
||||
{
|
||||
|
||||
/** @var Engine */
|
||||
protected $engine = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$this->engine = null;
|
||||
}
|
||||
|
||||
public function testTextGrenzen(): void
|
||||
{
|
||||
$this->engine->calc();
|
||||
self::assertFalse($this->engine->getArticle()->getOptionById('text_1')->isValid());
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('text_2')->isValid());
|
||||
}
|
||||
|
||||
public function testTextGrenzenChanges(): void
|
||||
{
|
||||
$this->engine->setVariable('auflage', 1000);
|
||||
$this->engine->calc();
|
||||
self::assertTrue($this->engine->getArticle()->getOptionById('text_1')->isValid());
|
||||
self::assertFalse($this->engine->getArticle()->getOptionById('text_2')->isValid());
|
||||
}
|
||||
}
|
||||
22
tests/Type/Text/calc.xml
Normal file
22
tests/Type/Text/calc.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<kalkulation>
|
||||
<artikel>
|
||||
<name>Banderolen</name>
|
||||
<kommentar/>
|
||||
|
||||
|
||||
<option id="auflage" name="Auflage" type="Input" default="1" min="100" max="50000"/>
|
||||
|
||||
<option id="text_1" name="Text 1" type="Text" default="Test 1">
|
||||
<auflage>
|
||||
<grenze>100-</grenze>
|
||||
</auflage>
|
||||
</option>
|
||||
|
||||
<option id="text_2" name="Text 2" type="Text" default="Test 1">
|
||||
<auflage>
|
||||
<grenze>1-99</grenze>
|
||||
</auflage>
|
||||
</option>
|
||||
</artikel>
|
||||
</kalkulation>
|
||||
0
tests/Type/Text/calcTemplates.xml
Normal file
0
tests/Type/Text/calcTemplates.xml
Normal file
0
tests/Type/Text/formels.txt
Normal file
0
tests/Type/Text/formels.txt
Normal file
6
tests/Type/Text/papierContainer.xml
Normal file
6
tests/Type/Text/papierContainer.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<container>
|
||||
<papiercontainer id="banderolen">
|
||||
<papier id="sm150g"/>
|
||||
</papiercontainer>
|
||||
</container>
|
||||
0
tests/Type/Text/parameters.txt
Normal file
0
tests/Type/Text/parameters.txt
Normal file
Loading…
Reference in New Issue
Block a user