Files
api/services/nginx/app/tests/Unit/Selfserve/SelfserveWashFlowMachineAllowedWiringTest.php
T
Jeppe Bundgaard 72df2244ca Add self-serve API fixtures and enhance session synchronization logic
- Implement `createSelfServeScenario` to generate comprehensive self-serve test fixtures, including departments, lanes, tasks, and sessions.
- Add `syncRelayState` parameter to `synchronizeSession` for decoupled relay hardware synchronization.
- Update relevant routes and tests to reflect changes in session synchronization methods.
- Enhance Shelly request handling by blocking real device interactions in test mode with detailed logging.
2026-04-28 12:28:29 +02:00

28 lines
1.4 KiB
PHP

<?php
it('reads machine allowed state from session summary payload safely', function (): void {
$washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));
expect($washFlow)->not->toBeFalse();
$methodOffset = strpos($washFlow, 'public function isMachineAllowedToStartWash');
expect($methodOffset)->not->toBeFalse();
$methodBody = substr($washFlow, (int)$methodOffset, 300);
expect($methodBody)->toContain("return (\$sessionSummary['session']['allowed'] ?? false) === true;");
expect($methodBody)->not->toContain("return \$sessionSummary['allowed'] === true;");
});
it('separates session synchronization from relay hardware synchronization', function (): void {
$washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));
$interface = file_get_contents(app_path('modules/selfserve/interfaces/selfserve_wash_flow_i.php'));
expect($washFlow)->not->toBeFalse();
expect($interface)->not->toBeFalse();
expect($interface)->toContain('bool $syncRelayState = true');
expect($washFlow)->toContain('bool $syncRelayState = true');
expect($washFlow)->toContain('if ($syncRelayState) {');
expect($washFlow)->toContain('$this->syncMachineRelayFromVisibleServices($snapshot, $session, $activateMachine);');
expect($washFlow)->toContain('$this->synchronizeSession($laneId, $normalizedReg, null, false, null, false);');
});