34 lines
2.2 KiB
PHP
34 lines
2.2 KiB
PHP
<?php
|
|
|
|
it('syncs lane relay states when department self-serve enabled flag changes', function (): void {
|
|
$routeContent = file_get_contents(app_path('routes/departmentsRoute.php'));
|
|
|
|
expect($routeContent)->not->toBeFalse();
|
|
expect($routeContent)->toContain('/departments/self-serve/enabled');
|
|
expect($routeContent)->toContain('$this->syncDepartmentSelfServeRelayStates((int)$department->id, $enabled);');
|
|
expect($routeContent)->toContain('department_variables_o::withSelfServeTransitionLock');
|
|
expect($routeContent)->toContain('if (!$enabled) {');
|
|
expect($routeContent)->toContain('// Self-serve disabled: restore normal/manual relay operation.');
|
|
expect($routeContent)->toContain('setMachineProgramPickerRelayStatusForDepartmentOperation(true)');
|
|
expect($routeContent)->toContain('setMachineRelayStatusForDepartmentOperation(true)');
|
|
expect($routeContent)->toContain('!$department_lane->isSelfServeEnabled()');
|
|
expect($routeContent)->toContain('setMachineProgramPickerRelayStatus(false)');
|
|
expect($routeContent)->toContain('setMachineCleanerRelayStatusForDepartmentOperation(true)');
|
|
expect($routeContent)->toContain('setMachineRelayStatus(false)');
|
|
expect($routeContent)->not->toContain('setMachineProgramPickerRelayStatusHard(false)');
|
|
expect($routeContent)->not->toContain('setMachineCleanerRelayStatusHard(false)');
|
|
expect($routeContent)->not->toContain('setMachineRelayStatusHard(false)');
|
|
expect($routeContent)->not->toContain('setMachineCleanerRelayStatus(false)');
|
|
});
|
|
|
|
it('uses the supported prepared database API for the department transition lock', function (): void {
|
|
$variableObject = file_get_contents(app_path('objects/department_variables_o.php'));
|
|
|
|
expect($variableObject)->not->toBeFalse()
|
|
->and($variableObject)->not->toContain('$database->selectOne')
|
|
->and($variableObject)->toContain("\$db->prepare('SELECT GET_LOCK(?, ?) AS acquired')")
|
|
->and($variableObject)->toContain("\$statement->bind_param('si', \$lockName, \$timeoutSeconds)")
|
|
->and($variableObject)->toContain("\$db->prepare('SELECT RELEASE_LOCK(?) AS released')")
|
|
->and($variableObject)->toContain("\$statement->bind_param('s', \$lockName)");
|
|
});
|