101 lines
3.0 KiB
PHP
101 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace PSC\Library\Calc\Tests\Customer\NN;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
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 TestCase
|
|
{
|
|
protected ?Engine $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 testPrice(): void
|
|
{
|
|
$this->engine->calc();
|
|
$this->assertSame(45.0, $this->engine->getPrice());
|
|
}
|
|
|
|
public function testChangeFolie(): void
|
|
{
|
|
$this->engine->calc();
|
|
$this->engine->setVariable('umschlagtyp', 4);
|
|
$this->assertSame(44.7, $this->engine->getPrice());
|
|
$this->assertSame(
|
|
'12',
|
|
$this->engine
|
|
->getArticle()
|
|
->getOptionById('umschlagvorn')
|
|
->getSelectedOption()
|
|
->getId(),
|
|
);
|
|
}
|
|
|
|
public function testChangeMatt(): void
|
|
{
|
|
$this->engine->setVariable('umschlagtyp', '4');
|
|
$this->assertSame(44.7, $this->engine->getPrice());
|
|
$this->assertSame(
|
|
'12',
|
|
$this->engine
|
|
->getArticle()
|
|
->getOptionById('umschlagvorn')
|
|
->getSelectedOption()
|
|
->getId(),
|
|
);
|
|
$this->engine->setVariable('umschlagvorn', '13');
|
|
$this->assertSame(44.7, $this->engine->getPrice());
|
|
$this->engine->calc();
|
|
$this->assertSame(
|
|
'13',
|
|
$this->engine
|
|
->getArticle()
|
|
->getOptionById('umschlagvorn')
|
|
->getSelectedOption()
|
|
->getId(),
|
|
);
|
|
}
|
|
|
|
public function testChangeComplete(): void
|
|
{
|
|
$this->engine->calc();
|
|
$this->engine->setVariable('umschlagtyp', '4');
|
|
$this->engine->setVariable('umschlagvorn', '13');
|
|
$this->engine->calc();
|
|
$this->assertSame(44.7, $this->engine->getPrice());
|
|
$this->assertSame(
|
|
'13',
|
|
$this->engine
|
|
->getArticle()
|
|
->getOptionById('umschlagvorn')
|
|
->getSelectedOption()
|
|
->getId(),
|
|
);
|
|
}
|
|
}
|