Providers are collected during test discovery, long before any setUp has run, so a provider touching the application container or the database fails.
public function invalidPayloads(): array
{
// Error: A facade root has not been set.
return [[Order::factory()->make()]];
}
// pass descriptors and build inside the test instead
public function invalidPayloads(): array
{
return [
'missing sku' => [['qty' => 1]],
'negative qty' => [['sku' => 'A', 'qty' => -1]],
];
}
String keys on the provider array are worth the extra characters, because a failure otherwise reports “with data set #3” and you count rows to find it. Keeping providers to plain scalars and arrays also makes them cheap during discovery, which matters on a large suite where every provider runs on every invocation — including one that only runs a single filtered test.