supplierIndexes(); $companyNameIndexes = array_filter( $rows, static fn (array $r): bool => 'uq_supplier_company_name_active' === $r['indexname'], ); self::assertCount(1, $companyNameIndexes, 'Il doit exister exactement UN index uq_supplier_company_name_active.'); $def = strtolower((string) array_values($companyNameIndexes)[0]['indexdef']); self::assertStringContainsString('unique', $def); self::assertStringContainsString('lower', $def); self::assertStringContainsString('company_name', $def); self::assertStringContainsString('where', $def, 'L\'index doit etre partiel (clause WHERE sur les actifs).'); } public function testNoSirenOrEmailUniqueIndexOnSupplier(): void { $names = array_map(static fn (array $r): string => $r['indexname'], $this->supplierIndexes()); // § 2.6 : SIREN et email NON uniques sur le fournisseur. self::assertNotContains('uq_supplier_siren_active', $names); self::assertNotContains('uq_supplier_email_active', $names); } public function testFournisseurCategoryTypeExists(): void { self::bootKernel(); $count = (int) $this->getEm()->getConnection()->fetchOne( "SELECT COUNT(*) FROM category_type WHERE code = 'FOURNISSEUR'", ); self::assertSame(1, $count, 'Le type de categorie FOURNISSEUR doit etre present (migration + fixture).'); } /** * @return list */ private function supplierIndexes(): array { self::bootKernel(); /** @var list $rows */ return $this->getEm()->getConnection()->fetchAllAssociative( "SELECT indexname, indexdef FROM pg_indexes WHERE schemaname = 'public' AND tablename = 'supplier'", ); } }