Radiobox
This commit is contained in:
parent
8d98e33712
commit
51016ad6c0
2141
composer.lock
generated
2141
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\Calc\Calc;
|
||||
use PSC\Library\Calc\Calc\CalcValues;
|
||||
use PSC\Library\Calc\Calc\Valid;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?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;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Parser;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||
use PSC\Library\Calc\Option\Parser\Select\Opt;
|
||||
use PSC\Library\Calc\PaperContainer;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Option\Parser;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\General\Parser\EdgeCollectionContainer;
|
||||
use PSC\Library\Calc\Option\Parser\Select\Opt;
|
||||
use PSC\Library\Calc\PaperContainer;
|
||||
|
||||
@ -27,9 +27,13 @@ class Radio extends Base
|
||||
*/
|
||||
public function processValue()
|
||||
{
|
||||
$option = $this->getSelectedOption();
|
||||
if($option) {
|
||||
$this->setValue($option->getLabel());
|
||||
if($this->rawValue != "") {
|
||||
/** @var \PSC\Library\Calc\Option\Type\Radio\Opt $item */
|
||||
foreach($this->options as $item) {
|
||||
if($item->getId() == $this->rawValue) {
|
||||
$item->setIsSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,4 +53,9 @@ class Radio extends Base
|
||||
}
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->getSelectedOption()->getLabel();
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
namespace PSC\Library\Calc;
|
||||
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\Option\Parser\Select;
|
||||
use PSC\Library\Calc\Option\Parser\Template;
|
||||
|
||||
|
||||
@ -41,6 +41,5 @@ class CalcTest extends \PHPUnit_Framework_TestCase
|
||||
$this->engine->setVariable('anz_ausfuhren', 2500);
|
||||
/** @var Select $option */
|
||||
$option = $this->engine->getArticle()->getOptionById('tarif');
|
||||
var_dump($option->getSelectedOption());
|
||||
}
|
||||
}
|
||||
53
tests/Customer/M/CalcTest.php
Normal file
53
tests/Customer/M/CalcTest.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc\Tests\Customer\M;
|
||||
|
||||
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 testDefaultOption()
|
||||
{
|
||||
$article = $this->engine->getArticle();
|
||||
$option = $article->getOptionById('lochbohrung');
|
||||
$this->assertEquals("ohne Lochbohrung", $option->getValue());
|
||||
}
|
||||
|
||||
public function testCalcValues()
|
||||
{
|
||||
$this->engine->setVariable('lochbohrung', 1);
|
||||
$article = $this->engine->getArticle();
|
||||
$option = $article->getOptionById('lochbohrung');
|
||||
$this->assertEquals("mit Lochbohrung (+2,50 Euro/Stück)", $option->getValue());
|
||||
}
|
||||
}
|
||||
23
tests/Customer/M/calc.xml
Normal file
23
tests/Customer/M/calc.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<kalkulation>
|
||||
<artikel>
|
||||
<name>Kalkulation EduPlaner</name>
|
||||
<kommentar>Gratis Schulplaner</kommentar>
|
||||
<uploads>
|
||||
<upload id="neutral" name="Druckdaten" description="Bitte laden sie eine PDF für den Druck hoch"/>
|
||||
</uploads>
|
||||
|
||||
<option id="auflage" name="Auflage" type="Input" width="3" require="true" default="1">
|
||||
<auflage>
|
||||
<grenze formel="(10*5)">1-</grenze>
|
||||
</auflage>
|
||||
</option>
|
||||
|
||||
<option id="lochbohrung" name="Lochbohrung in den Ecken" type="Radio" default="2">
|
||||
<opt id="2" name="ohne Lochbohrung"/>
|
||||
<opt id="1" name="mit Lochbohrung (+2,50 Euro/Stück)"/>
|
||||
</option>
|
||||
|
||||
|
||||
</artikel>
|
||||
</kalkulation>
|
||||
2
tests/Customer/M/calcTemplates.xml
Normal file
2
tests/Customer/M/calcTemplates.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<root>
|
||||
</root>
|
||||
0
tests/Customer/M/formels.txt
Normal file
0
tests/Customer/M/formels.txt
Normal file
4
tests/Customer/M/papierContainer.xml
Normal file
4
tests/Customer/M/papierContainer.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<container>
|
||||
|
||||
</container>
|
||||
0
tests/Customer/M/parameters.txt
Normal file
0
tests/Customer/M/parameters.txt
Normal file
@ -11,7 +11,7 @@
|
||||
*/
|
||||
namespace PSC\Library\Calc\Tests\Mock;
|
||||
|
||||
use Doctrine\Common\Persistence\ObjectRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
class PaperRepostory implements ObjectRepository
|
||||
{
|
||||
|
||||
23
tests/Parse/Option/RadioboxTest.php
Normal file
23
tests/Parse/Option/RadioboxTest.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 RadioboxTest 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/radiobox.xml')));
|
||||
|
||||
/** @var Checkbox $element */
|
||||
$element = $obj->parse();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Radio', $element);
|
||||
}
|
||||
|
||||
}
|
||||
5
tests/TestFiles/Option/radiobox.xml
Normal file
5
tests/TestFiles/Option/radiobox.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<option id="lochbohrung" name="Lochbohrung in den Ecken" type="Radio" default="2">
|
||||
<opt id="2" name="ohne Lochbohrung"/>
|
||||
<opt id="1" name="mit Lochbohrung (+2,50 Euro/Stück)"/>
|
||||
</option>
|
||||
Loading…
Reference in New Issue
Block a user