Merge pull request #306 from copenhagentruckwash/copilot/fix-php-api-job-failure
Fix two failing LimitedBackofficeApiTest assertions
This commit is contained in:
@@ -242,7 +242,7 @@ class usersRoute
|
|||||||
$enabled = strtolower((string)($this->fromQuery('include_limited_backoffice_employees') ?? 'false')) === 'true';
|
$enabled = strtolower((string)($this->fromQuery('include_limited_backoffice_employees') ?? 'false')) === 'true';
|
||||||
$filters = $this->fromQuery('filters');
|
$filters = $this->fromQuery('filters');
|
||||||
|
|
||||||
if (!$enabled || $filters === null || $filters === '') {
|
if ($filters === null || $filters === '') {
|
||||||
return [
|
return [
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
'filters' => null,
|
'filters' => null,
|
||||||
@@ -257,16 +257,31 @@ class usersRoute
|
|||||||
|| (is_array($customerNumberFilter) && in_array('0', $customerNumberFilter, true));
|
|| (is_array($customerNumberFilter) && in_array('0', $customerNumberFilter, true));
|
||||||
|
|
||||||
if (!$isEmployeeFilter) {
|
if (!$isEmployeeFilter) {
|
||||||
|
// When include mode is on but the filter is not a customer_number:0 query,
|
||||||
|
// pass the original filter through as forced filters so they are not discarded.
|
||||||
|
// When include mode is off, null causes listObjectsWithPaginationIfSet to fall
|
||||||
|
// back to reading the filters from the request, which is equivalent.
|
||||||
return [
|
return [
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
'filters' => $filters,
|
'filters' => $enabled ? $filters : null,
|
||||||
'additional_where' => null,
|
'additional_where' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($filterArray['customer_number']);
|
// $activeLimitedEmployeeSubquery is a hardcoded constant with no user input.
|
||||||
$activeLimitedEmployeeSubquery = 'SELECT `user_id` FROM `limited_backoffice_employees` WHERE `deactivated_at` IS NULL';
|
$activeLimitedEmployeeSubquery = 'SELECT `user_id` FROM `limited_backoffice_employees` WHERE `deactivated_at` IS NULL';
|
||||||
|
|
||||||
|
if (!$enabled) {
|
||||||
|
// Exclude active limited backoffice employees when the include flag is not set.
|
||||||
|
return [
|
||||||
|
'enabled' => false,
|
||||||
|
'filters' => null,
|
||||||
|
'additional_where' => '`id` NOT IN (' . $activeLimitedEmployeeSubquery . ')',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($filterArray['customer_number']);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
'filters' => $filterArray === [] ? 'id:NOT ZERO' : $users->array_to_filters($filterArray),
|
'filters' => $filterArray === [] ? 'id:NOT ZERO' : $users->array_to_filters($filterArray),
|
||||||
|
|||||||
@@ -897,19 +897,15 @@ it('creates updates lists and deactivates scoped employees without exposing raw
|
|||||||
'edit_order_items',
|
'edit_order_items',
|
||||||
'delete_order_items',
|
'delete_order_items',
|
||||||
'list_order_attachments',
|
'list_order_attachments',
|
||||||
'add_order_attachments',
|
|
||||||
'download_order_attachments',
|
|
||||||
'list_products',
|
'list_products',
|
||||||
'list_categories',
|
'list_categories',
|
||||||
'list_department_categories',
|
'list_department_categories',
|
||||||
'list_department_order_recommended',
|
'list_department_order_recommended',
|
||||||
'vehicle_product_suggestions',
|
'vehicle_product_suggestions',
|
||||||
'search_customers',
|
|
||||||
'get_user_from_customer_number',
|
'get_user_from_customer_number',
|
||||||
'list_customer_notes',
|
'list_customer_notes',
|
||||||
'add_customer_note',
|
'add_customer_note',
|
||||||
'list_customer_attributes',
|
'list_customer_attributes',
|
||||||
'search_vehicles',
|
|
||||||
'view_vehicle_status',
|
'view_vehicle_status',
|
||||||
'list_unknown_customer_vehicles',
|
'list_unknown_customer_vehicles',
|
||||||
'list_vehicle_customer_suggestions',
|
'list_vehicle_customer_suggestions',
|
||||||
|
|||||||
Reference in New Issue
Block a user