Files
api/services/nginx/app/tests/Unit/Selfserve/SelfserveStartCleanerRelayWiringTest.php
T

32 lines
1.7 KiB
PHP

<?php
it('enables cleaner relay on wash start command and webhook flow', function (): void {
$commandTrait = file_get_contents(app_path('modules/selfserve/traits/selfserve_lane_command_t.php'));
$washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));
expect($commandTrait)->not->toBeFalse();
expect($commandTrait)->toContain('turnOnCleanerRelayForWashStart()');
expect($commandTrait)->toContain('setMachineCleanerRelayStatusHard(true)');
expect($washFlow)->not->toBeFalse();
expect($washFlow)->toContain('enableCleanerRelayForStartedWash(');
expect($washFlow)->toContain('setMachineCleanerRelayStatusHard(true)');
});
it('keeps cleaner relay enable wired into machine relay start paths', function (): void {
$washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));
$moduleRoute = file_get_contents(app_path('routes/moduleSelfServeRoute.php'));
expect($washFlow)->not->toBeFalse();
$enableMachineRelayMethodOffset = strpos($washFlow, 'protected function enableMachineRelayIfAllowed');
expect($enableMachineRelayMethodOffset)->not->toBeFalse();
$enableMachineRelayMethod = substr($washFlow, (int)$enableMachineRelayMethodOffset, 1200);
expect($enableMachineRelayMethod)->toContain('$this->enableCleanerRelayForStartedWash($lane);');
expect($moduleRoute)->not->toBeFalse();
$machineEnableRouteOffset = strpos($moduleRoute, '/modules/self-serve/lane/relay/machine/enable');
expect($machineEnableRouteOffset)->not->toBeFalse();
$machineEnableRoute = substr($moduleRoute, (int)$machineEnableRouteOffset, 1800);
expect($machineEnableRoute)->toContain('$lane->setMachineCleanerRelayStatusHard(true);');
});