Files
Enelix-EMS/tests/EaseeModuleStrukturTest.php
T
dh ccecc437e9
Tests / test (push) Successful in 45s
fix(easee): wartende Ladevorgaenge starten
2026-09-29 09:34:37 +00:00

92 lines
3.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Belevo\EnelixEMS\Tests;
use PHPUnit\Framework\TestCase;
final class EaseeModuleStrukturTest extends TestCase
{
public function testGatewayUndLadestationSindVollstaendigeModule(): void
{
foreach (['EaseeGateway', 'LadestationGateway'] as $modul) {
foreach (['module.json', 'form.json', 'module.php'] as $datei) {
self::assertFileExists(__DIR__ . '/../' . $modul . '/' . $datei);
}
}
}
public function testDatenSchnittstellenPassenZusammen(): void
{
$gateway = $this->module('EaseeGateway');
$ladestation = $this->module('LadestationGateway');
self::assertContains(
'{7AEF3DF7-DA5B-47C5-BCDC-0110D06DDC04}',
$gateway['implemented']
);
self::assertContains(
'{107D5CFA-8F3D-4E38-8643-90DDFE6A3B4D}',
$gateway['childRequirements']
);
self::assertContains(
'{7AEF3DF7-DA5B-47C5-BCDC-0110D06DDC04}',
$ladestation['parentRequirements']
);
self::assertContains(
'{107D5CFA-8F3D-4E38-8643-90DDFE6A3B4D}',
$ladestation['implemented']
);
}
public function testZugangsdatenLiegenNurImGateway(): void
{
$gatewayForm = (string) file_get_contents(
__DIR__ . '/../EaseeGateway/form.json'
);
$ladestationForm = (string) file_get_contents(
__DIR__ . '/../LadestationGateway/form.json'
);
self::assertStringContainsString('PasswordTextBox', $gatewayForm);
self::assertStringNotContainsString('PasswordTextBox', $ladestationForm);
self::assertStringNotContainsString('Username', $ladestationForm);
}
public function testLadestationVerwendetApiStatusUndGemeinsamenVertrag(): void
{
$modul = (string) file_get_contents(
__DIR__ . '/../LadestationGateway/module.php'
);
self::assertStringContainsString('implements VerbraucherSchnittstelle', $modul);
self::assertStringContainsString('EaseeLadestatus::ausBeobachtungen', $modul);
self::assertStringContainsString(
"RegisterPropertyBoolean('Ladefreigabe', true)",
$modul
);
self::assertStringContainsString("'FahrzeugVerbunden'", $modul);
self::assertStringContainsString("'Phasenzahl'", $modul);
self::assertStringNotContainsString('7500', $modul);
self::assertStringNotContainsString('Abfrageintervall', $modul);
self::assertStringContainsString("'action' => 'StartCharging'", $modul);
$gateway = (string) file_get_contents(
__DIR__ . '/../EaseeGateway/module.php'
);
self::assertStringContainsString('/commands/start_charging', $gateway);
}
/** @return array<string, mixed> */
private function module(string $name): array
{
return json_decode(
(string) file_get_contents(__DIR__ . '/../' . $name . '/module.json'),
true,
512,
JSON_THROW_ON_ERROR
);
}
}