This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Belevo\EnelixEMS\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class WaermepumpeModulstrukturTest extends TestCase
|
||||
{
|
||||
private const MODULPFAD = __DIR__ . '/../Waermepumpe/';
|
||||
private const MODULID = '{A31C9274-54F7-4BD2-9804-7AF23E86C4D1}';
|
||||
|
||||
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('VerbraucherWaermepumpe', $metadaten['name']);
|
||||
self::assertSame('Enelix', $metadaten['vendor']);
|
||||
self::assertSame(['Waermepumpe'], $metadaten['aliases']);
|
||||
self::assertSame(self::MODULID, $metadaten['id']);
|
||||
self::assertSame(3, $metadaten['type']);
|
||||
}
|
||||
|
||||
public function testAllePropertiesSindRegistriertUndImFormularEnthalten(): 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
|
||||
);
|
||||
$formular = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
||||
|
||||
foreach (array_values(array_unique($treffer[1])) as $property) {
|
||||
self::assertStringContainsString('"name": "' . $property . '"', $formular, $property);
|
||||
}
|
||||
}
|
||||
|
||||
public function testVertrag40UndBetriebsartabhaengigesAngebotWerdenVerwendet(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
|
||||
self::assertStringContainsString('implements VerbraucherSchnittstelle', $modul);
|
||||
self::assertStringContainsString('ManagerdatenEmpfangen(array $daten)', $modul);
|
||||
self::assertStringContainsString('Nachrichtenvertrag::pruefeManagerdaten', $modul);
|
||||
self::assertStringContainsString('Nachrichtenvertrag::pruefeVerbraucherdaten', $modul);
|
||||
self::assertStringContainsString("['Betriebsart']", $modul);
|
||||
self::assertStringNotContainsString("RegisterPropertyInteger('ManagerID'", $modul);
|
||||
self::assertStringNotContainsString("RegisterVariableString('PowerSteps'", $modul);
|
||||
}
|
||||
|
||||
public function testRegelungIstEreignisbasiertUndBegrenztSperrzeiten(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
|
||||
self::assertStringContainsString('public function MessageSink', $modul);
|
||||
self::assertStringContainsString('RegisterMessage($neueID, self::VM_UPDATE)', $modul);
|
||||
foreach ([
|
||||
'Meldezyklus',
|
||||
'MeldungVerzoegert',
|
||||
'Zustandspruefung',
|
||||
'VorgabeTimeout',
|
||||
] as $timer) {
|
||||
self::assertStringContainsString("'" . $timer . "'", $modul);
|
||||
}
|
||||
foreach ([
|
||||
'Mindestlaufzeit',
|
||||
'Mindestsperrzeit',
|
||||
'MaximaleSperrzeit',
|
||||
'MaximaleSperrzeit24h',
|
||||
'Anlaufwartezeit',
|
||||
'Wiederholsperre',
|
||||
] as $property) {
|
||||
self::assertStringContainsString("'" . $property . "'", $modul);
|
||||
}
|
||||
}
|
||||
|
||||
public function testKontakteWerdenBreakBeforeMakeGeschaltet(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
$aus = strpos($modul, '$this->setzeKontakt(1, false)');
|
||||
$ein = strpos($modul, '$this->setzeKontakt(1, true)');
|
||||
|
||||
self::assertIsInt($aus);
|
||||
self::assertIsInt($ein);
|
||||
self::assertLessThan($ein, $aus);
|
||||
}
|
||||
|
||||
public function testFachUndDiagnosevariablenSindVorhanden(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
foreach ([
|
||||
'Waermepumpenzustand',
|
||||
'WaermepumpeLaeuft',
|
||||
'SperreAktiv',
|
||||
'ErhoehungAktiv',
|
||||
'SGReadyZustand',
|
||||
'Laufzeit',
|
||||
'AnlaufAusstehend',
|
||||
'WiederholsperreAktiv',
|
||||
'SperrerholungAktiv',
|
||||
'Sperrzeit24h',
|
||||
] as $ident) {
|
||||
self::assertStringContainsString("'" . $ident . "'", $modul);
|
||||
}
|
||||
self::assertStringContainsString("ReadPropertyBoolean('DiagnosevariablenAnzeigen')", $modul);
|
||||
self::assertStringContainsString('UnregisterVariable($ident)', $modul);
|
||||
}
|
||||
|
||||
public function testManagerKenntDieModulIDGenauEinmal(): void
|
||||
{
|
||||
$manager = (string) file_get_contents(__DIR__ . '/../Manager/module.php');
|
||||
|
||||
self::assertSame(1, substr_count($manager, self::MODULID));
|
||||
}
|
||||
|
||||
public function testDokumentationBeschreibtImplementiertenStand(): void
|
||||
{
|
||||
$dokumentation = (string) file_get_contents(
|
||||
__DIR__ . '/../docs/module/Waermepumpe/README.md'
|
||||
);
|
||||
|
||||
self::assertStringContainsString('Status: Implementiert', $dokumentation);
|
||||
self::assertStringContainsString('nicht uebernommen', $dokumentation);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user