44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace PSC\Library\Calc\Tests\Graph\Simple;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PSC\Library\Calc\Graph\Graph;
|
|
use PSC\Library\Calc\Model\Part;
|
|
use PSC\Library\Calc\Model\PartType;
|
|
|
|
use function PHPUnit\Framework\assertJsonStringEqualsJsonFile;
|
|
use function PHPUnit\Framework\assertSame;
|
|
use function PHPUnit\Framework\assertTrue;
|
|
|
|
class SimpleTest extends TestCase
|
|
{
|
|
private Graph $graph;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$this->graph = new Graph(
|
|
file_get_contents(__DIR__ . '/formel.txt'),
|
|
file_get_contents(__DIR__ . '/parameter.txt'),
|
|
);
|
|
}
|
|
|
|
public function testGraph(): void
|
|
{
|
|
$this->graph->addCalcFormel(new Part(
|
|
type: PartType::CalcFormel,
|
|
name: 'calcFormat',
|
|
unParsed: '$Ftest1$F+$Ftest2$F+10',
|
|
));
|
|
|
|
$this->graph->addCalcFormel(new Part(
|
|
type: PartType::CalcFormel,
|
|
name: 'calcAnzahlNutzen',
|
|
unParsed: '$Ftest5$F+$Ftest8$F',
|
|
));
|
|
|
|
assertSame(6186, $this->graph->getSum());
|
|
assertJsonStringEqualsJsonFile(__DIR__ . '/test.json', $this->graph->generateJsonGraph());
|
|
}
|
|
}
|