422 porte sur foundedAt (et pas un 400 generique). */ public function testFoundedAtNonParsableEst422(): void { $seed = $this->seedSupplier('Founded Format Negoce'); $credentials = $this->createUserWithPermission('commercial.suppliers.manage'); $client = $this->authenticatedClient($credentials['username'], $credentials['password']); $body = $client->request('PATCH', '/api/suppliers/'.$seed->getId(), [ 'headers' => ['Content-Type' => self::MERGE], 'json' => ['foundedAt' => '32/13/2026'], ])->toArray(false); self::assertResponseStatusCodeSame(422); self::assertArrayHasKey('foundedAt', $this->violationsByPath($body)); } /** * Cas piege : « 12/25/2026 » est invalide cote front (JJ/MM/AAAA -> mois 25) * mais PHP DateTime l'accepterait en M/J/AAAA. Le format d'entree strict ISO * `Y-m-d` (Context sur foundedAt) doit le rejeter -> 422. */ public function testFoundedAtFormatAmbiguUsEst422(): void { $seed = $this->seedSupplier('Founded Ambigu Negoce'); $credentials = $this->createUserWithPermission('commercial.suppliers.manage'); $client = $this->authenticatedClient($credentials['username'], $credentials['password']); $body = $client->request('PATCH', '/api/suppliers/'.$seed->getId(), [ 'headers' => ['Content-Type' => self::MERGE], 'json' => ['foundedAt' => '12/25/2026'], ])->toArray(false); self::assertResponseStatusCodeSame(422); self::assertArrayHasKey('foundedAt', $this->violationsByPath($body)); } /** Non-regression : une date ISO valide reste acceptee (200). */ public function testFoundedAtIsoValideEst200(): void { $seed = $this->seedSupplier('Founded Ok Negoce'); $credentials = $this->createUserWithPermission('commercial.suppliers.manage'); $client = $this->authenticatedClient($credentials['username'], $credentials['password']); $data = $client->request('PATCH', '/api/suppliers/'.$seed->getId(), [ 'headers' => ['Content-Type' => self::MERGE], 'json' => ['foundedAt' => '2010-05-01'], ])->toArray(); self::assertResponseStatusCodeSame(200); self::assertStringStartsWith('2010-05-01', $data['foundedAt']); } }