test(catalog) : cover RG-1.01 to RG-1.17 with 9 test classes (63 tests)
PHPUnit suite for the M0 Catalog module covering the 17 business rules of the spec : - CategoryPermissionsTest (RG-1.01) — 4 personas + admin + anonymous on GET / POST / PATCH / DELETE - CategoryValidationTest (RG-1.02 to RG-1.06) — name NotBlank + trim + length + categoryType required / must exist - CategoryUniqueTest (RG-1.07) — 409 case-insensitive, multi-type allowed, recreate after soft delete - CategoryListTest (RG-1.08 to RG-1.10) — soft-delete filter, includeDeleted flag, name ASC sort - CategoryGetTest (RG-1.11) — 404 on soft-deleted, 200 with flag, 404 on not found - CategoryDeleteTest (RG-1.12 / RG-1.13) — soft delete, deletedAt unwriteable via PATCH, 404 on already deleted - CategoryAuditTest — audit_log written on create / update / soft delete with correct performed_by - CategoryTimestampableBlamableTest (RG-1.15 / RG-1.16) — blame admin on POST, null in console context, frozen createdBy on PATCH, updated_* on soft delete - EntitiesAreTimestampableBlamableTest (RG-1.17) — stays green (already shipped in ERP-52) Side fixes uncovered by the suite : - Category.php : add normalizer 'trim' to NotBlank + Length so a whitespace-only name returns 422 (RG-1.02 + RG-1.03 alignment, the Processor trim was running after validation). - makefile : recreate the partial index uq_category_name_type_active in test-db-setup. doctrine:schema:update drops the unexpressable index after migrations, which made RG-1.07 silently pass (duplicate POST -> 201 instead of 409). The DDL is now restored after schema:update via dbal:run-sql. Tests : 311 total (248 + 63 new), 1071 assertions, 0 failure, 0 risky.
This commit is contained in:
@@ -200,12 +200,20 @@ migration-migrate:
|
||||
# en DB, le purger crash.
|
||||
# 3. fixtures -> sync-permissions : fixtures:load purge la table permission,
|
||||
# donc sync doit passer apres.
|
||||
# 4. recreation index `uq_category_name_type_active` : schema:update drop
|
||||
# les index orphelins du mapping ORM. L'index partiel (LOWER + WHERE) du
|
||||
# M0 Catalog n'est pas exprimable via les attributs Doctrine ORM 3
|
||||
# (fonctionnel + partiel), donc il disparait apres schema:update. On le
|
||||
# recree par dbal:run-sql pour que les tests RG-1.07 (unicite
|
||||
# case-insensitive) voient bien la contrainte SQL. Sans ce restore, les
|
||||
# POST doublons remontent 201 au lieu de 409.
|
||||
test-db-setup:
|
||||
$(SYMFONY_CONSOLE) doctrine:database:create --env=test --if-not-exists
|
||||
$(SYMFONY_CONSOLE) doctrine:migrations:migrate --env=test --no-interaction
|
||||
$(SYMFONY_CONSOLE) doctrine:schema:update --env=test --force
|
||||
$(SYMFONY_CONSOLE) --env=test --no-interaction doctrine:fixtures:load
|
||||
$(SYMFONY_CONSOLE) --env=test --no-interaction app:sync-permissions
|
||||
$(SYMFONY_CONSOLE) --env=test dbal:run-sql "CREATE UNIQUE INDEX IF NOT EXISTS uq_category_name_type_active ON category (LOWER(name), category_type_id) WHERE deleted_at IS NULL"
|
||||
|
||||
fixtures:
|
||||
$(SYMFONY_CONSOLE) --no-interaction doctrine:fixtures:load
|
||||
|
||||
Reference in New Issue
Block a user