Fix customer restriction CI regressions

This commit is contained in:
Jeppe B
2026-07-16 12:06:42 +02:00
parent e1fb79d9b6
commit 9b2d5d5291
6 changed files with 25 additions and 9 deletions
@@ -187,7 +187,7 @@ class customer_rule_product_restriction_schema_bootstrap
$predicate = self::legacyPredicate($db, $attribute);
$activePredicate = self::columnExists($db, 'products', 'deleted_at')
? "(p.deleted_at IS NULL OR p.deleted_at = '')"
? 'p.deleted_at IS NULL'
: '1 = 1';
$insert = $db->query(
"INSERT IGNORE INTO customer_rule_product_collection_products (collection_id, product_id)
@@ -353,7 +353,7 @@ class customer_rule_product_restriction_service
{
global $db;
$activeExpression = $this->columnExists('products', 'deleted_at')
? "CASE WHEN p.deleted_at IS NULL OR p.deleted_at = '' THEN 1 ELSE 0 END"
? 'CASE WHEN p.deleted_at IS NULL THEN 1 ELSE 0 END'
: '1';
$result = $db->query(
"SELECT p.id, p.name, p.category AS category_id, c.name AS category_name,
+1 -1
View File
@@ -107,7 +107,7 @@ class order_items_o extends db
"SELECT order_id
FROM order_items
WHERE id = {$normalizedRelatedItemId}
AND (deleted_at IS NULL OR deleted_at = '')
AND deleted_at IS NULL
LIMIT 1"
);
if (!$result || $result->num_rows < 1) {
@@ -111,7 +111,8 @@ it('returns exact product restrictions for product-impact attributes and null fo
expect($byAttribute['restrictSpotFree']['product_restriction']['disabled_product_ids'] ?? [])
->toContain((int)$product['id'])
->and($byAttribute['restrictSpotFree']['product_restriction']['collections'] ?? [])->not->toBeEmpty()
->and($byAttribute['exemptFromAdministrationFee']['product_restriction'] ?? 'missing')->toBeNull();
->and($byAttribute['exemptFromAdministrationFee'])->toHaveKey('product_restriction')
->and($byAttribute['exemptFromAdministrationFee']['product_restriction'])->toBeNull();
});
it('keeps workflow-only customer attribute activation compatible', function (): void {
@@ -141,6 +142,7 @@ it('keeps workflow-only customer attribute activation compatible', function ():
api_client()->delete(
'/customer/attributes?user_id=' . (int)$customer['id'] . '&attribute=exemptFromAdministrationFee',
null,
$session['headers']
)
->assertStatus(200)
@@ -1,10 +1,12 @@
<?php
it('documents period invoice states and authenticated attachment content', function (): void {
$openApiFiles = [
app_path('openapi.yaml'),
dirname(app_path(), 3) . '/openapi.yaml',
];
$openApiFiles = [app_path('openapi.yaml')];
$rootOpenApiFile = dirname(app_path(), 3) . '/openapi.yaml';
if (is_file($rootOpenApiFile)) {
$openApiFiles[] = $rootOpenApiFile;
}
foreach ($openApiFiles as $openApiFile) {
expect($openApiFile)->toBeFile();
@@ -21,4 +23,3 @@ it('documents period invoice states and authenticated attachment content', funct
expect($content)->toContain('enum: [draft, booked, none]');
}
});
@@ -48,3 +48,16 @@ it('fails closed when configured restriction reads cannot be completed', functio
->toContain('foreach (self::PRODUCT_IMPACT_ATTRIBUTES as $attribute)')
->toContain('Unable to validate collection products');
});
it('uses strict datetime-safe deleted row predicates', function (): void {
$schema = file_get_contents(app_path('classes/customer_rule_product_restriction_schema_bootstrap.php'));
$service = file_get_contents(app_path('classes/customer_rule_product_restriction_service.php'));
$orderItems = file_get_contents(app_path('objects/order_items_o.php'));
expect($schema)->toContain('p.deleted_at IS NULL')
->not->toContain("p.deleted_at = ''")
->and($service)->toContain('p.deleted_at IS NULL')
->not->toContain("p.deleted_at = ''")
->and($orderItems)->toContain('AND deleted_at IS NULL')
->not->toContain("deleted_at = ''");
});