55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
namespace PSC\Library\Calc\Tests\Customer\H;
|
|
|
|
use PSC\Library\Calc\Article;
|
|
use PSC\Library\Calc\Engine;
|
|
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()
|
|
{
|
|
$this->assertEquals(33 , $this->engine->getPrice());
|
|
}
|
|
|
|
public function testIfDisplayValues()
|
|
{
|
|
$this->assertEquals(33 , $this->engine->getPrice());
|
|
$this->assertCount(0 , $this->engine->getDisplayVariables());
|
|
}
|
|
|
|
public function testIfAjaxValues()
|
|
{
|
|
$this->engine->setVariable('sap_plugin', 1);
|
|
$this->assertEquals(258 , $this->engine->getPrice());
|
|
$this->assertCount(6 , $this->engine->getAjaxVariables());
|
|
}
|
|
} |