This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Belevo\EnelixEMS\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class PufferspeicherModulstrukturTest extends TestCase
|
||||
{
|
||||
private const MODULPFAD = __DIR__ . '/../Pufferspeicher/';
|
||||
|
||||
public function testModulIstVollstaendigUndMetadatenSindGueltig(): void
|
||||
{
|
||||
foreach (['module.json', 'form.json', 'module.php'] as $datei) {
|
||||
self::assertFileExists(self::MODULPFAD . $datei);
|
||||
}
|
||||
$metadaten = json_decode(
|
||||
(string) file_get_contents(self::MODULPFAD . 'module.json'),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
|
||||
self::assertSame('VerbraucherPufferspeicher', $metadaten['name']);
|
||||
self::assertSame('Enelix', $metadaten['vendor']);
|
||||
self::assertSame(['Pufferspeicher'], $metadaten['aliases']);
|
||||
self::assertSame(3, $metadaten['type']);
|
||||
}
|
||||
|
||||
public function testPropertiesSindRegistriertUndInGewuenschterReihenfolgeImFormular(): void
|
||||
{
|
||||
$basis = (string) file_get_contents(__DIR__ . '/../libs/VerbraucherBasisTrait.php');
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
preg_match_all(
|
||||
'/RegisterProperty(?:Integer|Float|Boolean|String)\(\'([^\']+)\'/',
|
||||
$basis . $modul,
|
||||
$treffer
|
||||
);
|
||||
$properties = array_values(array_unique($treffer[1]));
|
||||
$formularText = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
||||
foreach ($properties as $property) {
|
||||
self::assertStringContainsString('"name": "' . $property . '"', $formularText, $property);
|
||||
}
|
||||
|
||||
$formular = json_decode($formularText, true, 512, JSON_THROW_ON_ERROR);
|
||||
self::assertSame(
|
||||
[
|
||||
'Manager und Zeitverhalten',
|
||||
'Pufferspeicher',
|
||||
'Heizkurve',
|
||||
'Erweiterte Einstellungen',
|
||||
],
|
||||
array_column($formular['elements'], 'caption')
|
||||
);
|
||||
}
|
||||
|
||||
public function testModulVerwendetVertrag40UndBetriebsartabhaengigesAngebot(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
|
||||
self::assertStringContainsString('implements VerbraucherSchnittstelle', $modul);
|
||||
self::assertStringContainsString('ManagerdatenEmpfangen(array $daten)', $modul);
|
||||
self::assertStringContainsString("['Betriebsart']", $modul);
|
||||
self::assertStringContainsString('BETRIEBSART_PEAK', $modul);
|
||||
self::assertStringContainsString("'Betriebsart' =>", $modul);
|
||||
self::assertStringNotContainsString("RegisterVariableString('PowerSteps'", $modul);
|
||||
self::assertStringNotContainsString("RegisterPropertyInteger('ManagerID'", $modul);
|
||||
}
|
||||
|
||||
public function testEinAusLoggingVariablenUndWaermepumpenaktionSindEnthalten(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
$formular = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
||||
|
||||
self::assertStringContainsString("case 'Aktiv':", $modul);
|
||||
self::assertStringContainsString("ReadPropertyBoolean('LoggingEin')", $modul);
|
||||
foreach ([
|
||||
'Puffertemperatur',
|
||||
'Aussentemperatur',
|
||||
'Solltemperatur',
|
||||
'Heizbedarf',
|
||||
] as $ident) {
|
||||
self::assertStringContainsString("RegisterVariable", $modul);
|
||||
self::assertStringContainsString("'" . $ident . "'", $modul);
|
||||
}
|
||||
self::assertStringContainsString('HeizkurveVonWaermepumpeUebernehmen', $modul);
|
||||
self::assertStringContainsString('Wert von Waermepumpe uebernehmen', $formular);
|
||||
}
|
||||
|
||||
public function testSchaltfolgeIstBreakBeforeMake(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
$aus = strpos($modul, "RequestAction(\$stufe['KontaktID'], false)");
|
||||
$ein = strpos($modul, "RequestAction(\$stufe['KontaktID'], true)");
|
||||
|
||||
self::assertIsInt($aus);
|
||||
self::assertIsInt($ein);
|
||||
self::assertLessThan($ein, $aus);
|
||||
}
|
||||
|
||||
public function testManagerKenntDieModulIDGenauEinmal(): void
|
||||
{
|
||||
$manager = (string) file_get_contents(__DIR__ . '/../Manager/module.php');
|
||||
|
||||
self::assertSame(1, substr_count(
|
||||
$manager,
|
||||
'{C92D5EEF-9632-47A5-9659-4B02BF40FBE9}'
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user