92 lines
2.7 KiB
PHP
92 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Belevo\EnelixUtils\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class NeueModuleStrukturTest extends TestCase
|
|
{
|
|
/** @dataProvider module */
|
|
public function testMetadatenUndFormulareSindGueltig(
|
|
string $ordner,
|
|
string $name,
|
|
string $prefix
|
|
): void {
|
|
$metadata = json_decode(
|
|
(string) file_get_contents(
|
|
__DIR__ . '/../' . $ordner . '/module.json'
|
|
),
|
|
true,
|
|
512,
|
|
JSON_THROW_ON_ERROR
|
|
);
|
|
self::assertSame($name, $metadata['name']);
|
|
self::assertSame($prefix, $metadata['prefix']);
|
|
self::assertSame(3, $metadata['type']);
|
|
self::assertMatchesRegularExpression(
|
|
'/^\{[0-9A-F-]{36}\}$/',
|
|
$metadata['id']
|
|
);
|
|
|
|
$formular = json_decode(
|
|
(string) file_get_contents(
|
|
__DIR__ . '/../' . $ordner . '/form.json'
|
|
),
|
|
true,
|
|
512,
|
|
JSON_THROW_ON_ERROR
|
|
);
|
|
self::assertNotEmpty($formular['elements']);
|
|
}
|
|
|
|
/** @return array<string, array{string, string, string}> */
|
|
public function module(): array
|
|
{
|
|
return [
|
|
'Virtuelle Batterie' => [
|
|
'VirtuelleBatterie',
|
|
'Virtuelle Batterie',
|
|
'ENLVB',
|
|
],
|
|
'VGT-Schnittstelle' => [
|
|
'VGTSchnittstelle',
|
|
'VGTSchnittstelle',
|
|
'ENLVGT',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function testVirtuelleBatterieStelltEVProxyregisterBereit(): void
|
|
{
|
|
$modul = (string) file_get_contents(
|
|
__DIR__ . '/../VirtuelleBatterie/module.php'
|
|
);
|
|
foreach ([
|
|
"'EVManagement'",
|
|
"'EVModus'",
|
|
"'EVLadeleistung'",
|
|
"'EVEntladeleistung'",
|
|
"'SDLSollleistung'",
|
|
'VirtuelleBatterieRegler::kombiniere',
|
|
] as $bestandteil) {
|
|
self::assertStringContainsString($bestandteil, $modul);
|
|
}
|
|
}
|
|
|
|
public function testPhysischeSollwerteWerdenNurPerActionGeschrieben(): void
|
|
{
|
|
$modul = (string) file_get_contents(
|
|
__DIR__ . '/../VirtuelleBatterie/module.php'
|
|
);
|
|
$anfang = strpos($modul, 'private function schreibeVerteilung');
|
|
$ende = strpos($modul, 'private function sichererZustand');
|
|
self::assertNotFalse($anfang);
|
|
self::assertNotFalse($ende);
|
|
$funktion = substr($modul, $anfang, $ende - $anfang);
|
|
self::assertStringContainsString('RequestAction(', $funktion);
|
|
self::assertStringNotContainsString('SetValue($zielID', $funktion);
|
|
}
|
|
}
|