This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Belevo\EnelixEMS\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class BatterieModulstrukturTest extends TestCase
|
||||
{
|
||||
private const MODULPFAD = __DIR__ . '/../Batterie/';
|
||||
|
||||
public function testModulIstVollstaendigUndMetadatenSindGueltig(): void
|
||||
{
|
||||
foreach (['module.json', 'form.json', 'module.php', 'README.md'] 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('{437FB683-517F-4FEC-8CCB-FE6B0A62B69E}', $metadaten['id']);
|
||||
self::assertSame('Batterie', $metadaten['name']);
|
||||
self::assertSame('Enelix', $metadaten['vendor']);
|
||||
self::assertSame(3, $metadaten['type']);
|
||||
}
|
||||
|
||||
public function testAllePropertiesSindImFormularEnthalten(): 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 testModulIstEreignisbasiertUndVerwendetVertrag40(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
|
||||
self::assertStringContainsString('implements VerbraucherSchnittstelle', $modul);
|
||||
self::assertStringContainsString('ManagerdatenEmpfangen(array $daten)', $modul);
|
||||
self::assertStringContainsString('public function MessageSink(', $modul);
|
||||
self::assertStringContainsString('RegisterMessage($neueID, self::VM_UPDATE)', $modul);
|
||||
self::assertStringContainsString("'Betriebsart' =>", $modul);
|
||||
self::assertStringNotContainsString('Timer_Do_UserCalc_Battery', $modul);
|
||||
self::assertStringNotContainsString("RegisterTimer('Regelzyklus'", $modul);
|
||||
self::assertStringNotContainsString("RegisterVariableString('PowerSteps'", $modul);
|
||||
}
|
||||
|
||||
public function testRegisterWerdenUeberAusgewaehlteAktionsvariablenGeschrieben(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
$formular = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
||||
|
||||
self::assertStringContainsString(
|
||||
'RequestAction($this->ReadPropertyInteger($property), $wert)',
|
||||
$modul
|
||||
);
|
||||
self::assertStringContainsString('FormBatterietyp', $modul);
|
||||
self::assertStringContainsString('UpdateFormField', $modul);
|
||||
foreach ([
|
||||
'ManagementRegisterVariableID',
|
||||
'ModusRegisterVariableID',
|
||||
'LeistungsRegisterVariableID',
|
||||
'LadeleistungRegisterVariableID',
|
||||
'EntladeleistungRegisterVariableID',
|
||||
] as $property) {
|
||||
self::assertStringContainsString('"name": "' . $property . '"', $formular);
|
||||
}
|
||||
}
|
||||
|
||||
public function testLoggingDiagnoseUndAktionsbuttonsSindVorhanden(): void
|
||||
{
|
||||
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
||||
$formular = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
||||
|
||||
self::assertStringContainsString("ReadPropertyBoolean('LoggingEin')", $modul);
|
||||
self::assertStringContainsString('"name": "DiagnosevariablenAnzeigen"', $formular);
|
||||
self::assertStringContainsString('Messwerte und Angebot aktualisieren', $formular);
|
||||
self::assertStringContainsString('Register auf sicheren Zustand setzen', $formular);
|
||||
}
|
||||
|
||||
public function testManagerKenntDieBatterieModulIDGenauEinmal(): void
|
||||
{
|
||||
$manager = (string) file_get_contents(__DIR__ . '/../Manager/module.php');
|
||||
|
||||
self::assertSame(
|
||||
1,
|
||||
substr_count($manager, '{437FB683-517F-4FEC-8CCB-FE6B0A62B69E}')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user