app['env'] = 'production'; config(['finance_batch.container' => false]); // Laravel intentionally disables command events during PHPUnit boot. // Recreate the production event wiring before exercising real Artisan. $kernel = app(Kernel::class); $kernel->rerouteSymfonyCommandEvents(); $kernel->setArtisan(null); $blocked = false; try { Artisan::call('order-data:import-after-sales-cost', ['file' => '/does-not-exist.xlsx', '--dry-run' => true]); } catch (RuntimeException $exception) { $blocked = true; $this->assertStringContainsString('run-finance-batch.sh', $exception->getMessage()); $this->assertDatabaseCount('ops_after_sales_cost_rows', 0); } finally { $this->app['env'] = 'testing'; } $this->assertTrue($blocked, 'Production web runtime accepted a heavy import.'); } }