Fixes
This commit is contained in:
parent
3e559ecfae
commit
2a0ca40ed7
10826
cobertura.xml
10826
cobertura.xml
File diff suppressed because it is too large
Load Diff
@ -6,20 +6,24 @@ use PSC\Library\Calc\Option\Parser\Checkbox;
|
||||
use PSC\Library\Calc\Option\Parser\Headline;
|
||||
use PSC\Library\Calc\Option\Parser\Hidden;
|
||||
use PSC\Library\Calc\Option\Parser\Input;
|
||||
use PSC\Library\Calc\Option\Parser\Media;
|
||||
use PSC\Library\Calc\Option\Parser\Radio;
|
||||
use PSC\Library\Calc\Option\Parser\Row;
|
||||
use PSC\Library\Calc\Option\Parser\Row\Column;
|
||||
use PSC\Library\Calc\Option\Parser\Select;
|
||||
use PSC\Library\Calc\Option\Parser\Template;
|
||||
use PSC\Library\Calc\Option\Parser\Text;
|
||||
use PSC\Library\Calc\Option\Parser\Media;
|
||||
use PSC\Library\Calc\Option\Parser\Textarea;
|
||||
|
||||
class Parser
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private $paperContainer,
|
||||
private $paperRepository,
|
||||
private $templates,
|
||||
) {}
|
||||
|
||||
public function getOptByJsonType(int $type, ?string $mode = null)
|
||||
public function getOptByJsonType(int $type, null|string $mode = null)
|
||||
{
|
||||
$obj = false;
|
||||
switch ($type) {
|
||||
@ -42,20 +46,26 @@ class Parser
|
||||
$obj = new Headline();
|
||||
break;
|
||||
case 7:
|
||||
$obj = new Checkbox();
|
||||
$obj = new Row($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
break;
|
||||
case 8:
|
||||
$obj = new Radio();
|
||||
$obj = new Column($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
break;
|
||||
case 9:
|
||||
$obj = new Media();
|
||||
break;
|
||||
case 10:
|
||||
$obj = new Checkbox();
|
||||
break;
|
||||
case 11:
|
||||
$obj = new Radio();
|
||||
break;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function getOptByType(string $type, ?string $mode = null)
|
||||
public function getOptByType(string $type, null|string $mode = null)
|
||||
{
|
||||
$obj = false;
|
||||
switch (strtolower($type)) {
|
||||
@ -86,12 +96,17 @@ class Parser
|
||||
case 'template':
|
||||
$obj = new Template();
|
||||
break;
|
||||
case 'row':
|
||||
$obj = new Row($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
break;
|
||||
case 'column':
|
||||
$obj = new Column($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
break;
|
||||
case 'media':
|
||||
$obj = new Media();
|
||||
break;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace PSC\Library\Calc;
|
||||
|
||||
namespace PSC\Library\Calc;
|
||||
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use PSC\Library\Calc\Option\Parser\Row;
|
||||
@ -21,13 +21,15 @@ class Parser
|
||||
/** @var \SimpleXMLElement $templates */
|
||||
protected $templates;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
public function __construct() {}
|
||||
|
||||
public function parseJson(array $json): Article
|
||||
{
|
||||
$optionParser = new \PSC\Library\Calc\Option\Parser($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
$optionParser = new \PSC\Library\Calc\Option\Parser(
|
||||
$this->paperContainer,
|
||||
$this->paperRepository,
|
||||
$this->templates,
|
||||
);
|
||||
$this->article = new Article($json['name'], $json['uuid'] ?? null);
|
||||
|
||||
foreach ($json['options'] as $option) {
|
||||
@ -45,7 +47,7 @@ class Parser
|
||||
$node = $this->templates->xpath('//option[@id="' . $element->getSelect() . '"]');
|
||||
$obj = $optionParser->getOptByType($node[0]);
|
||||
$element = $obj->parseJson();
|
||||
if($default != "") {
|
||||
if ($default != '') {
|
||||
$element->setDefault($default);
|
||||
}
|
||||
} else {
|
||||
@ -55,22 +57,28 @@ class Parser
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->article;
|
||||
}
|
||||
|
||||
public function parseXML(\SimpleXMLElement $node): Article
|
||||
{
|
||||
$optionParser = new \PSC\Library\Calc\Option\Parser($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
$optionParser = new \PSC\Library\Calc\Option\Parser(
|
||||
$this->paperContainer,
|
||||
$this->paperRepository,
|
||||
$this->templates,
|
||||
);
|
||||
|
||||
$this->article = new Article((string)$node->name, (string)$node->uuid?? null);
|
||||
$this->article = new Article((string) $node->name, ((string) $node->uuid) ?? null);
|
||||
|
||||
if (isset($node->kommentar)) {
|
||||
$this->article->setComment((string) $node->kommentar);
|
||||
}
|
||||
if (isset($node->precalc)) {
|
||||
if(isset($node->precalc['type']) && isset($node->precalc['select']) && strtolower($node->precalc['type']) == 'template') {
|
||||
$nodePreCalc = $this->templates->xpath('//precalc[@id="' . (string)$node->precalc['select'] . '"]');
|
||||
if (
|
||||
isset($node->precalc['type'], $node->precalc['select']) &&
|
||||
strtolower($node->precalc['type']) == 'template'
|
||||
) {
|
||||
$nodePreCalc = $this->templates->xpath('//precalc[@id="' . ((string) $node->precalc['select']) . '"]');
|
||||
if (isset($nodePreCalc[0])) {
|
||||
$parser = new PreCalc($nodePreCalc[0]);
|
||||
$this->article->setPreCalc($parser->parse());
|
||||
@ -82,7 +90,6 @@ class Parser
|
||||
}
|
||||
|
||||
if (isset($node->displaygroups)) {
|
||||
|
||||
foreach ($node->displaygroups->group as $group) {
|
||||
$this->article->addDisplayGroup(new DisplayGroup((string) $group['id'], (string) $group['name']));
|
||||
}
|
||||
@ -105,7 +112,7 @@ class Parser
|
||||
$obj = $optionParser->getOptByType($node[0]['type']);
|
||||
$obj->fromXML($node[0]);
|
||||
$element = $obj->parseXML();
|
||||
if($default != "") {
|
||||
if ($default != '') {
|
||||
$element->setDefault($default);
|
||||
}
|
||||
} else {
|
||||
@ -113,11 +120,6 @@ class Parser
|
||||
}
|
||||
$this->article->addOption($element);
|
||||
}
|
||||
}elseif($key == 'row') {
|
||||
$obj = new Row($this->paperContainer, $this->paperRepository, $this->templates);
|
||||
$obj->fromXML($option);
|
||||
$element = $obj->parseXML();
|
||||
$this->article->addOption($element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,5 +162,4 @@ class Parser
|
||||
{
|
||||
$this->templates = $templates;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<row>
|
||||
|
||||
<option id="auflage1" type="Input" default="100" />
|
||||
<row id="row1">
|
||||
<option type="Row" id="row1">
|
||||
<column id="col1">
|
||||
<option id="text3" type="Text" default="Text3">
|
||||
</option>
|
||||
@ -22,10 +22,10 @@
|
||||
</option>
|
||||
<option id="papier" type="Select" mode="paperdb" />
|
||||
</column>
|
||||
</row>
|
||||
<row id="row2">
|
||||
</option>
|
||||
<option type="Row" id="row2">
|
||||
<column id="col3">
|
||||
<row id="row21">
|
||||
<option type="Row" id="row21">
|
||||
<column id="col31">
|
||||
<option id="auflage31" type="Input" default="100">
|
||||
<auflage1>
|
||||
@ -47,7 +47,7 @@
|
||||
</auflage1>
|
||||
</option>
|
||||
</column>
|
||||
</row>
|
||||
</option>
|
||||
<option id="text7" type="Text" default="Text7">
|
||||
</option>
|
||||
</column>
|
||||
@ -62,7 +62,7 @@
|
||||
</auflage1>
|
||||
</option>
|
||||
</column>
|
||||
</row>
|
||||
</option>
|
||||
<option id="text1" type="Text">
|
||||
<data><![CDATA[Text1]]></data>
|
||||
</option>
|
||||
|
||||
26
tests/Json/ParserTest.php
Normal file
26
tests/Json/ParserTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Json;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PSC\Library\Calc\Engine;
|
||||
use PSC\Library\Calc\Option\Parser\Row;
|
||||
use Spatie\ArrayToXml\ArrayToXml;
|
||||
|
||||
class ParserTest extends TestCase
|
||||
{
|
||||
public function testFromJson()
|
||||
{
|
||||
$engine1 = new Engine();
|
||||
|
||||
self::assertTrue($engine1->loadJson(file_get_contents(__DIR__ . '/fromRowCol.json')));
|
||||
self::assertXmlStringEqualsXmlFile(__DIR__ . '/fromRowCol.xml', $engine1->generateXML());
|
||||
}
|
||||
|
||||
public function testFromXML()
|
||||
{
|
||||
$engine1 = new Engine();
|
||||
self::assertTrue($engine1->loadString(file_get_contents(__DIR__ . '/fromRowCol.xml')));
|
||||
self::assertJsonStringEqualsJsonFile(__DIR__ . '/fromRowCol.json', $engine1->generateJson());
|
||||
}
|
||||
}
|
||||
64
tests/Json/fromRowCol.json
Normal file
64
tests/Json/fromRowCol.json
Normal file
@ -0,0 +1,64 @@
|
||||
[
|
||||
{
|
||||
"uuid": "df2df718-b28e-482d-bf0c-67d246f05d32",
|
||||
"name": "Test Artikel",
|
||||
"options": [
|
||||
{
|
||||
"id": "dee2007d-1ffe-430e-b75f-4f32a30b6a6d",
|
||||
"type": 7,
|
||||
"dependencys": [],
|
||||
"columns": [
|
||||
{
|
||||
"id": "1",
|
||||
"dependencys": [],
|
||||
"type": 8,
|
||||
"options": [
|
||||
{
|
||||
"id": "auflage",
|
||||
"name": "Auflage",
|
||||
"default": "100",
|
||||
"dependencys": [],
|
||||
"placeHolder": "Placeholder",
|
||||
"required": false,
|
||||
"type": 2
|
||||
},
|
||||
{
|
||||
"id": "seiten_umschlag",
|
||||
"name": "Seiten Umschlag",
|
||||
"default": "2",
|
||||
"dependencys": [],
|
||||
"placeHolder": "Placeholder",
|
||||
"required": false,
|
||||
"type": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"type": 8,
|
||||
"dependencys": [],
|
||||
"options": [
|
||||
{
|
||||
"id": "farbe1",
|
||||
"name": "Farbe1",
|
||||
"default": "142",
|
||||
"container": "pantone+-solid-uncoated",
|
||||
"mode": "colordb",
|
||||
"dependencys": [],
|
||||
"required": true,
|
||||
"options": [
|
||||
{
|
||||
"dependencys": [],
|
||||
"id": "142",
|
||||
"name": "142"
|
||||
}
|
||||
],
|
||||
"type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
23
tests/Json/fromRowCol.xml
Normal file
23
tests/Json/fromRowCol.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<kalkulation>
|
||||
<artikel>
|
||||
<name>Test Artikel</name>
|
||||
<uuid>df2df718-b28e-482d-bf0c-67d246f05d32</uuid>
|
||||
<kommentar></kommentar>
|
||||
|
||||
<option id="dee2007d-1ffe-430e-b75f-4f32a30b6a6d" type="Row">
|
||||
<column id="1">
|
||||
<option default="100" id="auflage" name="Auflage" placeholder="Placeholder"
|
||||
type="Input" />
|
||||
<option default="2" id="seiten_umschlag" name="Seiten Umschlag"
|
||||
placeholder="Placeholder" type="Input" />
|
||||
</column>
|
||||
<column id="2">
|
||||
<option container="pantone+-solid-uncoated" default="142" id="farbe1" mode="colordb"
|
||||
name="Farbe1" require="true" type="Select" />
|
||||
</column>
|
||||
</option>
|
||||
|
||||
</artikel>
|
||||
</kalkulation>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -8,13 +9,14 @@ class CheckboxTest extends TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/checkbox.xml'))['type']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/checkbox.xml'))['type'],
|
||||
);
|
||||
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/checkbox.xml')));
|
||||
$element = $obj->parseXML();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Checkbox', $element);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -10,9 +11,11 @@ class InputTest extends TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$parser = new Parser(null, null, null);
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml'))['type']);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml'))['type'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml')));
|
||||
$element = $obj->parseXML();
|
||||
|
||||
@ -21,9 +24,11 @@ class InputTest extends TestCase
|
||||
|
||||
public function testIfCorrectAttributes()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$parser = new Parser(null, null, null);
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml'))['type']);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml'))['type'],
|
||||
);
|
||||
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/input.xml')));
|
||||
$element = $obj->parseXML();
|
||||
@ -34,5 +39,4 @@ class InputTest extends TestCase
|
||||
$this->assertEquals('auflage', $element->getId());
|
||||
$this->assertEquals('Auflage', $element->getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -11,12 +12,15 @@ class RadioboxTest extends TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/radiobox.xml'))['type']);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/radiobox.xml'))['type']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/radiobox.xml'))['type'],
|
||||
);
|
||||
$obj->fromXML(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/radiobox.xml'))['type'],
|
||||
);
|
||||
$element = $obj->parseXML();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Radio', $element);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -12,8 +13,11 @@ class SelectTest extends TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml'))['type'], simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml'))['mode']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml'))['type'],
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml'))['mode'],
|
||||
);
|
||||
$obj->setPaperContainer(new PaperContainer());
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml')));
|
||||
$element = $obj->parseXML();
|
||||
@ -23,8 +27,10 @@ class SelectTest extends TestCase
|
||||
|
||||
public function testIfCorrectAttributes()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml'))['type']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml'))['type'],
|
||||
);
|
||||
$obj->setPaperContainer(new PaperContainer());
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/select.xml')));
|
||||
$element = $obj->parseXML();
|
||||
@ -39,7 +45,8 @@ class SelectTest extends TestCase
|
||||
public function testIfPaperContainerReturnsCorrectItems()
|
||||
{
|
||||
$paperContainer = new PaperContainer();
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
|
||||
$this->assertEquals(2, $paperContainer->getContainer()->count());
|
||||
|
||||
@ -59,16 +66,22 @@ class SelectTest extends TestCase
|
||||
|
||||
public function testIfSelectWithPaperContainerModeReturnsCorrectOpt()
|
||||
{
|
||||
|
||||
$repository = new PaperRepostory();
|
||||
|
||||
$paperContainer = new PaperContainer();
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/papierContainer.xml')));
|
||||
|
||||
$parser = new Parser();
|
||||
$parser = new Parser($paperContainer, $repository, null);
|
||||
/** @var Parser\Select $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectPaperDB.xml'))['type'], simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectPaperDB.xml'))['mode']);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectPaperDB.xml')));
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectPaperDB.xml'))['type'],
|
||||
simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectPaperDB.xml'))['mode'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectPaperDB.xml')));
|
||||
$obj->setPaperContainer($paperContainer);
|
||||
$obj->setPaperRepository($repository);
|
||||
|
||||
@ -82,9 +95,15 @@ class SelectTest extends TestCase
|
||||
|
||||
public function testIfSelectWithColorModePantoneReturnsCorrectOpt()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectColorDBPantone.xml'))['type'], simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectColorDBPantone.xml'))['mode']);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectColorDBPantone.xml')));
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectColorDBPantone.xml'))['type'],
|
||||
simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectColorDBPantone.xml'))['mode'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectColorDBPantone.xml')));
|
||||
$element = $obj->parseXML();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Select', $element);
|
||||
@ -93,14 +112,19 @@ class SelectTest extends TestCase
|
||||
|
||||
public function testIfSelectWithColorModeReturnsCorrectOpt()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectColorDBHKS.xml'))['type'], simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectColorDBHKS.xml'))['mode']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectColorDBHKS.xml'))['type'],
|
||||
simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectColorDBHKS.xml'))['mode'],
|
||||
);
|
||||
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/Select/selectColorDBHKS.xml')));
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ .
|
||||
'/../../TestFiles/Option/Select/selectColorDBHKS.xml')));
|
||||
$element = $obj->parseXML();
|
||||
|
||||
$this->assertInstanceOf('PSC\Library\Calc\Option\Type\Select', $element);
|
||||
$this->assertEquals(86, $element->getOptions()->count());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -10,9 +11,11 @@ class TextTest extends TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$parser = new Parser(null, null, null);
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml'))['type']);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml'))['type'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml')));
|
||||
/** @var Input $element */
|
||||
$element = $obj->parseXML();
|
||||
@ -22,9 +25,11 @@ class TextTest extends TestCase
|
||||
|
||||
public function testIfCorrectAttributes()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$parser = new Parser(null, null, null);
|
||||
/** @var Parser\Input $obj */
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml'))['type']);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml'))['type'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/text.xml')));
|
||||
/** @var Input $element */
|
||||
$element = $obj->parseXML();
|
||||
@ -34,5 +39,4 @@ class TextTest extends TestCase
|
||||
$this->assertEquals('t60', $element->getId());
|
||||
$this->assertEquals('', $element->getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace PSC\Library\Calc\Tests\Option\Type;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -10,8 +11,10 @@ class TextareaTest extends TestCase
|
||||
{
|
||||
public function testIfCorrectType()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/textarea.xml'))['type']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/textarea.xml'))['type'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/textarea.xml')));
|
||||
$element = $obj->parseXML();
|
||||
|
||||
@ -20,8 +23,10 @@ class TextareaTest extends TestCase
|
||||
|
||||
public function testIfCorrectAttributes()
|
||||
{
|
||||
$parser = new Parser();
|
||||
$obj = $parser->getOptByType(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/textarea.xml'))['type']);
|
||||
$parser = new Parser(null, null, null);
|
||||
$obj = $parser->getOptByType(
|
||||
simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/textarea.xml'))['type'],
|
||||
);
|
||||
$obj->fromXML(simplexml_load_string(file_get_contents(__DIR__ . '/../../TestFiles/Option/textarea.xml')));
|
||||
$element = $obj->parseXML();
|
||||
|
||||
@ -30,5 +35,4 @@ class TextareaTest extends TestCase
|
||||
$this->assertEquals('t60', $element->getId());
|
||||
$this->assertEquals('', $element->getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user