Fix customer restriction CI regressions
This commit is contained in:
@@ -187,7 +187,7 @@ class customer_rule_product_restriction_schema_bootstrap
|
|||||||
|
|
||||||
$predicate = self::legacyPredicate($db, $attribute);
|
$predicate = self::legacyPredicate($db, $attribute);
|
||||||
$activePredicate = self::columnExists($db, 'products', 'deleted_at')
|
$activePredicate = self::columnExists($db, 'products', 'deleted_at')
|
||||||
? "(p.deleted_at IS NULL OR p.deleted_at = '')"
|
? 'p.deleted_at IS NULL'
|
||||||
: '1 = 1';
|
: '1 = 1';
|
||||||
$insert = $db->query(
|
$insert = $db->query(
|
||||||
"INSERT IGNORE INTO customer_rule_product_collection_products (collection_id, product_id)
|
"INSERT IGNORE INTO customer_rule_product_collection_products (collection_id, product_id)
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ class customer_rule_product_restriction_service
|
|||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
$activeExpression = $this->columnExists('products', 'deleted_at')
|
$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';
|
: '1';
|
||||||
$result = $db->query(
|
$result = $db->query(
|
||||||
"SELECT p.id, p.name, p.category AS category_id, c.name AS category_name,
|
"SELECT p.id, p.name, p.category AS category_id, c.name AS category_name,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class order_items_o extends db
|
|||||||
"SELECT order_id
|
"SELECT order_id
|
||||||
FROM order_items
|
FROM order_items
|
||||||
WHERE id = {$normalizedRelatedItemId}
|
WHERE id = {$normalizedRelatedItemId}
|
||||||
AND (deleted_at IS NULL OR deleted_at = '')
|
AND deleted_at IS NULL
|
||||||
LIMIT 1"
|
LIMIT 1"
|
||||||
);
|
);
|
||||||
if (!$result || $result->num_rows < 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'] ?? [])
|
expect($byAttribute['restrictSpotFree']['product_restriction']['disabled_product_ids'] ?? [])
|
||||||
->toContain((int)$product['id'])
|
->toContain((int)$product['id'])
|
||||||
->and($byAttribute['restrictSpotFree']['product_restriction']['collections'] ?? [])->not->toBeEmpty()
|
->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 {
|
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(
|
api_client()->delete(
|
||||||
'/customer/attributes?user_id=' . (int)$customer['id'] . '&attribute=exemptFromAdministrationFee',
|
'/customer/attributes?user_id=' . (int)$customer['id'] . '&attribute=exemptFromAdministrationFee',
|
||||||
|
null,
|
||||||
$session['headers']
|
$session['headers']
|
||||||
)
|
)
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('documents period invoice states and authenticated attachment content', function (): void {
|
it('documents period invoice states and authenticated attachment content', function (): void {
|
||||||
$openApiFiles = [
|
$openApiFiles = [app_path('openapi.yaml')];
|
||||||
app_path('openapi.yaml'),
|
$rootOpenApiFile = dirname(app_path(), 3) . '/openapi.yaml';
|
||||||
dirname(app_path(), 3) . '/openapi.yaml',
|
|
||||||
];
|
if (is_file($rootOpenApiFile)) {
|
||||||
|
$openApiFiles[] = $rootOpenApiFile;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($openApiFiles as $openApiFile) {
|
foreach ($openApiFiles as $openApiFile) {
|
||||||
expect($openApiFile)->toBeFile();
|
expect($openApiFile)->toBeFile();
|
||||||
@@ -21,4 +23,3 @@ it('documents period invoice states and authenticated attachment content', funct
|
|||||||
expect($content)->toContain('enum: [draft, booked, none]');
|
expect($content)->toContain('enum: [draft, booked, none]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+13
@@ -48,3 +48,16 @@ it('fails closed when configured restriction reads cannot be completed', functio
|
|||||||
->toContain('foreach (self::PRODUCT_IMPACT_ATTRIBUTES as $attribute)')
|
->toContain('foreach (self::PRODUCT_IMPACT_ATTRIBUTES as $attribute)')
|
||||||
->toContain('Unable to validate collection products');
|
->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 = ''");
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user