@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixUtils\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$productionId = $test->createVariable(2, 'Produktion', 1200.0);
|
||||
$feedInId = $test->createVariable(2, 'Einspeisung', 350.0);
|
||||
$gridId = $test->createVariable(2, 'Netzbezug', 180.0);
|
||||
|
||||
$moduleId = $test->createInstance(
|
||||
'{F73B8F8D-5E36-4B23-B379-4632A517A1D6}',
|
||||
'Energiediagramm',
|
||||
[
|
||||
'ProduktionZaehlerID' => $productionId,
|
||||
'EinspeisungZaehlerID' => $feedInId,
|
||||
'NetzbezugZaehlerID' => $gridId,
|
||||
'Standardzeitraum' => 'month',
|
||||
'FarbeEigenverbrauch' => '#1259A7',
|
||||
'FarbeAutarkie' => '#178A55',
|
||||
]
|
||||
);
|
||||
|
||||
$test->runCase('Instanz und Eigenschaften werden angelegt', static function (
|
||||
TestContext $test
|
||||
) use ($moduleId): void {
|
||||
$test->assertInstanceStatus($moduleId);
|
||||
$test->assertSame('month', IPS_GetProperty($moduleId, 'Standardzeitraum'));
|
||||
$test->assertSame('#1259A7', IPS_GetProperty($moduleId, 'FarbeEigenverbrauch'));
|
||||
$test->assertSame('#178A55', IPS_GetProperty($moduleId, 'FarbeAutarkie'));
|
||||
});
|
||||
|
||||
$test->runCase('Konfigurationsformular ist gültiges JSON', static function (
|
||||
TestContext $test
|
||||
) use ($moduleId): void {
|
||||
$form = json_decode(
|
||||
IPS_GetConfigurationForm($moduleId),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
$test->assertTrue(is_array($form));
|
||||
});
|
||||
|
||||
$test->runCase('Zeitraum und Datumsbereich werden angenommen', static function (
|
||||
TestContext $test
|
||||
) use ($moduleId): void {
|
||||
IPS_RequestAction($moduleId, 'SetRange', 'year');
|
||||
IPS_RequestAction(
|
||||
$moduleId,
|
||||
'SetCustomRange',
|
||||
json_encode(
|
||||
['start' => '2026-01-01', 'end' => '2026-01-31'],
|
||||
JSON_THROW_ON_ERROR
|
||||
)
|
||||
);
|
||||
IPS_RequestAction($moduleId, 'Refresh', true);
|
||||
$test->assertSame(102, (int) IPS_GetInstance($moduleId)['InstanceStatus']);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user