Tests / test (push) Failing after 49s
Merge the V4 development history with current manager, SDL and setpoint fixes. Retain guarded trial behavior and consolidate controls in Prognose / Forecast. Exclude the unverified accounting-evidence change; no runtime deployment or new dispatch permission. Validated: 357 PHPUnit tests / 1758 assertions, 150 PHP syntax checks, 310 backend tests, 16 portal tests and isolated UI/receiver checks. develop and beta publication explicitly approved by Daniel Haefliger.
162 lines
6.8 KiB
PHP
162 lines
6.8 KiB
PHP
<?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 testV4StoppUndSollwertVerwerfenBleibenGemeinsamErhalten(): void
|
|
{
|
|
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
|
self::assertMatchesRegularExpression(
|
|
"/case 'SichererZustand':\\s*\\\$this->V4BatterieTestStoppen\\(\\);"
|
|
. "\\s*\\\$this->verwerfeSollwert\\(\\);\\s*\\\$this->schreibeRegister\\(0, true\\);/",
|
|
$modul
|
|
);
|
|
self::assertSame(1, preg_match(
|
|
'/private function ManagerdatenEmpfangenIntern\\(array \\$daten\\): void(.*?)private function aktualisiere\\(/s',
|
|
$modul,
|
|
$empfang
|
|
));
|
|
self::assertStringContainsString('$this->verwerfeSollwert();', $empfang[1]);
|
|
self::assertStringContainsString('$this->aktualisiereIntern(false);', $empfang[1]);
|
|
self::assertStringNotContainsString('$this->aktualisiere(', $empfang[1]);
|
|
}
|
|
|
|
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 testNachladebegrenzungIstImFormularKonfigurierbar(): void
|
|
{
|
|
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
|
$formular = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
|
|
|
self::assertStringContainsString(
|
|
"RegisterPropertyBoolean('NachladenMitMaximalleistung', true)",
|
|
$modul
|
|
);
|
|
self::assertStringContainsString(
|
|
"RegisterPropertyInteger('MaximaleNachladeleistung', 0)",
|
|
$modul
|
|
);
|
|
self::assertStringContainsString(
|
|
"'FormNachladenMitMaximalleistung'",
|
|
$formular
|
|
);
|
|
self::assertStringContainsString(
|
|
'"name": "MaximaleNachladeleistung"',
|
|
$formular
|
|
);
|
|
self::assertStringContainsString('"suffix": " W"', $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}')
|
|
);
|
|
}
|
|
|
|
public function testBatterieformularHatKeinenSeparatenV4Bereich(): void
|
|
{
|
|
$modul = (string) file_get_contents(self::MODULPFAD . 'module.php');
|
|
$formular = (string) file_get_contents(self::MODULPFAD . 'form.json');
|
|
self::assertStringNotContainsString('V4 physische Rueckmeldung', $modul);
|
|
self::assertStringNotContainsString('NetzfahrplanV4RueckmeldungKonfiguration', $formular);
|
|
self::assertStringNotContainsString("'name'=>'NetzfahrplanV4RueckmeldungKonfiguration'", $modul);
|
|
|
|
$rueckmeldung = (string) file_get_contents(__DIR__ . '/../libs/BatterieNetzfahrplanV4RueckmeldungTrait.php');
|
|
self::assertStringContainsString("RegisterPropertyString('NetzfahrplanV4RueckmeldungKonfiguration'", $rueckmeldung);
|
|
self::assertStringContainsString('$this->konfiguriereV4Rueckmeldung();', $modul);
|
|
}
|
|
}
|