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

24 lines
1.2 KiB
PHP

<?php
it('forces machine and cleaner relays off when a self-serve wash session is completed', function (): void {
$washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));
expect($washFlow)->not->toBeFalse();
expect($washFlow)->toContain('$this->disableMachineRelayForCompletedWash($laneId);');
$methodOffset = strpos($washFlow, 'protected function disableMachineRelayForCompletedWash');
expect($methodOffset)->not->toBeFalse();
$methodBody = substr($washFlow, (int)$methodOffset, 1500);
expect($methodBody)->toContain('$this->turnOffRelayIfConfiguredAndOn($lane, selfserve_lane_relay::MACHINE);');
expect($methodBody)->toContain('$this->turnOffRelayIfConfiguredAndOn($lane, selfserve_lane_relay::MACHINE_CLEANER);');
$helperOffset = strpos($washFlow, 'protected function turnOffRelayIfConfiguredAndOn');
expect($helperOffset)->not->toBeFalse();
$helperBody = substr($washFlow, (int)$helperOffset, 1500);
expect($helperBody)->toContain('$status = $lane->getRelayStatus($relay);');
expect($helperBody)->toContain("if ((bool)(\$status['on'] ?? false) !== true)");
expect($helperBody)->toContain('$lane->setRelayStatusHard($relay, false);');
});