34 lines
1.3 KiB
PHP
34 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Business;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use RuntimeException;
|
|
use Tests\Feature\FeatureTestCase;
|
|
|
|
class FinanceImportIsolationTest extends FeatureTestCase
|
|
{
|
|
public function test_actual_artisan_import_is_blocked_before_reading_files_in_production_web_runtime(): void
|
|
{
|
|
$this->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.');
|
|
}
|
|
}
|