49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Belevo\EnelixUtils\SymconTest\TestContext;
|
|
|
|
return static function (TestContext $test): void {
|
|
$instancesBefore = array_flip(IPS_GetInstanceList());
|
|
$mqttId = $test->createInstance(
|
|
'{C6D2AEB3-6E1F-4B2E-8E69-3A1A00246850}',
|
|
'MQTT-Testserver'
|
|
);
|
|
$ioId = (int) IPS_GetInstance($mqttId)['ConnectionID'];
|
|
if ($ioId > 0 && !isset($instancesBefore[$ioId])) {
|
|
IPS_SetParent($ioId, $test->rootId());
|
|
}
|
|
|
|
$moduleId = $test->createInstance(
|
|
'{4BA1A557-7970-4FB9-93B8-1F6ADA0A5A94}',
|
|
'VGT-Schnittstelle'
|
|
);
|
|
if ((int) IPS_GetInstance($moduleId)['ConnectionID'] !== $mqttId) {
|
|
IPS_DisconnectInstance($moduleId);
|
|
IPS_ConnectInstance($moduleId, $mqttId);
|
|
IPS_ApplyChanges($moduleId);
|
|
}
|
|
|
|
$test->runCase('MQTT-Elterninstanz wird verwendet', static function (
|
|
TestContext $test
|
|
) use ($moduleId, $mqttId): void {
|
|
$test->assertSame(
|
|
$mqttId,
|
|
(int) IPS_GetInstance($moduleId)['ConnectionID']
|
|
);
|
|
});
|
|
|
|
$test->runCase('Konfigurationsformular ist gueltiges 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));
|
|
});
|
|
};
|