Fix Calc php 8
This commit is contained in:
parent
b7d5623310
commit
d30779c3ce
@ -144,11 +144,15 @@ class Formel
|
|||||||
} else {
|
} else {
|
||||||
if ($variables [$foundvalue] == '') {
|
if ($variables [$foundvalue] == '') {
|
||||||
$formel = str_replace($found, 0, $formel);
|
$formel = str_replace($found, 0, $formel);
|
||||||
|
} else {
|
||||||
|
if(is_array($variables [$foundvalue])) {
|
||||||
|
$formel = str_replace($found, 0, $formel);
|
||||||
}else{
|
}else{
|
||||||
$formel = str_replace($found, $variables [$foundvalue], $formel);
|
$formel = str_replace($found, $variables [$foundvalue], $formel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$formel = str_replace($found, 0, $formel);
|
$formel = str_replace($found, 0, $formel);
|
||||||
}
|
}
|
||||||
|
|||||||
46
tests/Customer/U/CalcTest.php
Normal file
46
tests/Customer/U/CalcTest.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
namespace PSC\Library\Calc\Tests\Customer\U;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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 testIfDefaultPriceIsOk(): void
|
||||||
|
{
|
||||||
|
$this->engine->calc();
|
||||||
|
$this->assertEquals(202 , $this->engine->getPrice());
|
||||||
|
$this->assertEquals('135 g/m² Bilderdruck matt gestrichen', $this->engine->getArticle()->getOptionById('papier')->getValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
19
tests/Customer/U/calc.xml
Normal file
19
tests/Customer/U/calc.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- ACHTUNG STA+ PRÄ verwendet wegen "A < 682 cm2 Problem" hier IMMER den Fixwert von Fischer statt Tiegel -->
|
||||||
|
<kalkulation>
|
||||||
|
<artikel>
|
||||||
|
<name>Banderolen</name>
|
||||||
|
<kommentar/>
|
||||||
|
|
||||||
|
<option id="auflage" name="Auflage" type="Input" default="4" min="1" max="50000"/>
|
||||||
|
|
||||||
|
<option id="papier" name="Papier" type="Select" mode="papierdb" container="test_1" default="INM135ND">
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="calc_formel" name="calc_formel" type="Hidden" default="1">
|
||||||
|
<auflage>
|
||||||
|
<grenze formel="$Vauflage$V*$Vpapier_value$V">1-</grenze>
|
||||||
|
</auflage>
|
||||||
|
</option>
|
||||||
|
</artikel>
|
||||||
|
</kalkulation>
|
||||||
4
tests/Customer/U/calcTemplates.xml
Normal file
4
tests/Customer/U/calcTemplates.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<root>
|
||||||
|
|
||||||
|
|
||||||
|
</root>
|
||||||
0
tests/Customer/U/formels.txt
Normal file
0
tests/Customer/U/formels.txt
Normal file
8
tests/Customer/U/papierContainer.xml
Normal file
8
tests/Customer/U/papierContainer.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<container>
|
||||||
|
<papiercontainer id="test_1">
|
||||||
|
<papier id="INM135"/>
|
||||||
|
<papier id="INM115"/>
|
||||||
|
<papier id="INM135ND"/>
|
||||||
|
</papiercontainer>
|
||||||
|
</container>
|
||||||
0
tests/Customer/U/parameters.txt
Normal file
0
tests/Customer/U/parameters.txt
Normal file
Loading…
Reference in New Issue
Block a user