- Add `DepartmentLaneDynamicImageRouteTest` to verify dynamic image preview handling for studio lanes. - Introduce `selfserve_machine_signal` class to standardize signal normalization, recording, and gateway signal management workflows. - Add `selfserve_virtual_hardware` class to handle virtual hardware configurations, including gateway and binding management. - Enhance structure with auxiliary methods for payload normalization, workspace merging, and validation warnings.
52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
|
|
app_require('modules/selfserve/classes/selfserve_machine_signal.php');
|
|
|
|
use modules\selfserve\classes\selfserve_machine_signal;
|
|
|
|
it('normalizes Shelly input toggle ON events as machine start signals', function (): void {
|
|
$signal = (new selfserve_machine_signal())->normalizeShellyPayload([
|
|
'event' => 'input.toggle_on',
|
|
'component' => 'input:0',
|
|
'state' => true,
|
|
'relay_id' => 'M-1',
|
|
]);
|
|
|
|
expect($signal['recognized'])->toBeTrue()
|
|
->and($signal['on'])->toBeTrue()
|
|
->and($signal['component'])->toBe('input')
|
|
->and($signal['relay_id'])->toBe('M-1');
|
|
});
|
|
|
|
it('normalizes Shelly switch ON events and nested status payloads', function (): void {
|
|
$service = new selfserve_machine_signal();
|
|
|
|
$switchSignal = $service->normalizeShellyPayload([
|
|
'event' => 'switch.on',
|
|
'component' => 'switch:0',
|
|
'output' => true,
|
|
]);
|
|
$statusSignal = $service->normalizeShellyPayload([
|
|
'status' => [
|
|
'input:0' => ['state' => true],
|
|
],
|
|
]);
|
|
|
|
expect($switchSignal['recognized'])->toBeTrue()
|
|
->and($switchSignal['on'])->toBeTrue()
|
|
->and($switchSignal['component'])->toBe('switch')
|
|
->and($statusSignal['recognized'])->toBeTrue()
|
|
->and($statusSignal['on'])->toBeTrue();
|
|
});
|
|
|
|
it('recognizes Shelly OFF events but does not treat them as billable machine starts', function (): void {
|
|
$signal = (new selfserve_machine_signal())->normalizeShellyPayload([
|
|
'event' => 'input.toggle_off',
|
|
'component' => 'input:0',
|
|
'state' => false,
|
|
]);
|
|
|
|
expect($signal['recognized'])->toBeTrue()
|
|
->and($signal['on'])->toBeFalse();
|
|
});
|