@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixUtils\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$typeProfileExisted = IPS_VariableProfileExists('BELEVO.TariffType');
|
||||
$priceProfileExisted = IPS_VariableProfileExists('BELEVO.TariffPrice');
|
||||
|
||||
$moduleId = $test->createInstance(
|
||||
'{9DAC29C7-F381-F2A4-7CE2-F391C4123F38}',
|
||||
'Verbrauchskostenreport'
|
||||
);
|
||||
$test->trackVariableProfile('BELEVO.TariffType', $typeProfileExisted);
|
||||
$test->trackVariableProfile('BELEVO.TariffPrice', $priceProfileExisted);
|
||||
|
||||
$test->runCase('Instanz, Bedienvariablen und Reportmedium werden angelegt', static function (
|
||||
TestContext $test
|
||||
) use ($moduleId): void {
|
||||
foreach ([
|
||||
'FromDate', 'ToDate', 'LastResult', 'VisuTariffOverview',
|
||||
'VisuTariffPayload', 'VisuUserOverview', 'CreateReport', 'ReportPDF',
|
||||
] as $ident) {
|
||||
$test->objectByIdent($ident, $moduleId);
|
||||
}
|
||||
$test->assertTrue(IPS_VariableProfileExists('BELEVO.TariffType'));
|
||||
$test->assertTrue(IPS_VariableProfileExists('BELEVO.TariffPrice'));
|
||||
});
|
||||
|
||||
$test->runCase('Datumsaktionen übernehmen Werte', static function (TestContext $test) use (
|
||||
$moduleId
|
||||
): void {
|
||||
$from = strtotime('2026-01-01 00:00:00');
|
||||
$to = strtotime('2026-01-31 23:59:59');
|
||||
IPS_RequestAction($moduleId, 'FromDate', $from);
|
||||
IPS_RequestAction($moduleId, 'ToDate', $to);
|
||||
$test->assertSame($from, GetValue($test->objectByIdent('FromDate', $moduleId)));
|
||||
$test->assertSame($to, GetValue($test->objectByIdent('ToDate', $moduleId)));
|
||||
});
|
||||
|
||||
$test->runCase('Tariftabelle wird validiert und gespeichert', static function (
|
||||
TestContext $test
|
||||
) use ($moduleId): void {
|
||||
$payload = json_encode([
|
||||
[
|
||||
'unit_type' => 'Netztarif',
|
||||
'start' => '2026-01-01',
|
||||
'end' => '2026-12-31',
|
||||
'price' => '18.500',
|
||||
],
|
||||
], JSON_THROW_ON_ERROR);
|
||||
IPS_RequestAction($moduleId, 'VisuTariffPayload', $payload);
|
||||
|
||||
$tariffs = json_decode(
|
||||
(string) IPS_GetProperty($moduleId, 'Tariffs'),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
);
|
||||
$test->assertSame(1, count($tariffs));
|
||||
$test->assertSame('Netztarif', $tariffs[0]['unit_type']);
|
||||
$status = (string) GetValue($test->objectByIdent('VisuTariffStatus', $moduleId));
|
||||
$test->assertTrue(str_contains($status, '1 Tarif'));
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user