From 30e7839615c304e562a0c67f0bdc0fa254d50011 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Thu, 25 Jun 2026 14:20:52 +0200 Subject: [PATCH] =?UTF-8?q?fix(catalog)=20:=20retours=20review=20M6=20?= =?UTF-8?q?=E2=80=94=20default=20jsonb=20mort=20(states)=20+=20constante?= =?UTF-8?q?=20prefixe=20storage-type=20de=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/Version20260625110000.php | 4 +++- tests/Module/Catalog/Api/ProductExportControllerTest.php | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/migrations/Version20260625110000.php b/migrations/Version20260625110000.php index 341d004..ff769aa 100644 --- a/migrations/Version20260625110000.php +++ b/migrations/Version20260625110000.php @@ -128,7 +128,9 @@ final class Version20260625110000 extends AbstractMigration id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, code VARCHAR(50) NOT NULL, name VARCHAR(255) NOT NULL, - states JSONB DEFAULT '[]'::jsonb NOT NULL, + -- Pas de DEFAULT : un tableau vide violerait chk_product_states_not_empty + -- (RG-6.02). La colonne est toujours renseignee par l'app (Processor/ORM). + states JSONB NOT NULL, manufactured BOOLEAN DEFAULT FALSE NOT NULL, contains_molasses BOOLEAN DEFAULT FALSE NOT NULL, category_id INT NOT NULL, diff --git a/tests/Module/Catalog/Api/ProductExportControllerTest.php b/tests/Module/Catalog/Api/ProductExportControllerTest.php index 74c8c8d..99c9f1b 100644 --- a/tests/Module/Catalog/Api/ProductExportControllerTest.php +++ b/tests/Module/Catalog/Api/ProductExportControllerTest.php @@ -27,6 +27,9 @@ final class ProductExportControllerTest extends AbstractCatalogApiTestCase private const string XLSX_MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; private const string EXPORT_URL = '/api/products/export.xlsx'; + /** Prefixe des codes de types de stockage seedes par ce test (cible du cleanup tearDown). */ + private const string TEST_STORAGE_PREFIX = 'TEST_'; + /** * Purge des produits + types de stockage de test AVANT le cleanup parent : * product reference category / site / storage_type en FK ON DELETE RESTRICT, @@ -39,7 +42,7 @@ final class ProductExportControllerTest extends AbstractCatalogApiTestCase $em = $this->getEm(); $em->createQuery('DELETE FROM '.Product::class)->execute(); $em->createQuery('DELETE FROM '.StorageType::class.' s WHERE s.code LIKE :prefix') - ->setParameter('prefix', self::TEST_CATEGORY_TYPE_PREFIX.'%') + ->setParameter('prefix', self::TEST_STORAGE_PREFIX.'%') ->execute() ; @@ -200,7 +203,7 @@ final class ProductExportControllerTest extends AbstractCatalogApiTestCase $product->setContainsMolasses($containsMolasses); $product->setCategory($category ?? $this->createCategory()); $product->addSite($site ?? $this->firstSite()); - $product->addStorageType($storageType ?? $this->seedStorageType('TEST_'.strtoupper(substr(bin2hex(random_bytes(4)), 0, 8)))); + $product->addStorageType($storageType ?? $this->seedStorageType(self::TEST_STORAGE_PREFIX.strtoupper(substr(bin2hex(random_bytes(4)), 0, 8)))); $product->setDeletedAt($deletedAt); $em->persist($product);