Add tests for customer-scoped vehicle conditions and property gate permissions
- Introduced tests for `SelfserveNonOwnedVehicleWashAccess` to validate customer-scoped conditions for non-owned vehicles. - Added `SelfservePropertyGatePermissionBypassTest` to ensure proper permission handling for lanes and departments. - Updated `department_selfserve_vehicle_conditions_o` and routes to prevent cross-customer answer persistence. - Enhanced `selfserve_wash_flow` with customer-scoped persisted answer logic and improved method parameters for vehicle eligibility and session synchronization. - Adjusted OpenAPI spec and unit tests to reflect new customer-scoping behavior in self-serve operations.
This commit is contained in:
@@ -53,8 +53,10 @@ class department_selfserve_vehicle_conditions_o extends db
|
||||
$question = (int)$question;
|
||||
$value = (bool)$value;
|
||||
$customer_id = $customer_id !== null ? (int)$customer_id : null;
|
||||
// Remove any existing entry for the same department, lane, reg and question
|
||||
$sql = "DELETE FROM $this->table WHERE department = $department AND lane = $lane AND reg = '$reg' AND question = $question";
|
||||
// Remove any existing entry for the same department, lane, customer, reg and question.
|
||||
// Saved answers must not bleed across customers that temporarily wash the same plate.
|
||||
$customer_filter = $customer_id === null ? 'customer_id IS NULL' : 'customer_id = ' . $customer_id;
|
||||
$sql = "DELETE FROM $this->table WHERE department = $department AND lane = $lane AND $customer_filter AND reg = '$reg' AND question = $question";
|
||||
$db->query($sql);
|
||||
// Add the object
|
||||
$tmp_id = self::add_object([
|
||||
@@ -105,11 +107,16 @@ class department_selfserve_vehicle_conditions_o extends db
|
||||
];
|
||||
}
|
||||
|
||||
public function getAnswerMapForVehicle(int $departmentId, int $laneId, string $reg): array
|
||||
public function getAnswerMapForVehicle(int $departmentId, int $laneId, string $reg, ?int $customerId = null): array
|
||||
{
|
||||
if ($customerId === null || $customerId <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = self::getFieldsWhere([
|
||||
'department' => $departmentId,
|
||||
'lane' => $laneId,
|
||||
'customer_id' => $customerId,
|
||||
'reg' => selfserve::standardize_registration($reg),
|
||||
'deleted_at' => null,
|
||||
], ['question', 'value']);
|
||||
|
||||
Reference in New Issue
Block a user