32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\EcommerceFinance;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Tests\TestCase;
|
|
|
|
class ShippingMergedColumnsMigrationTest extends TestCase
|
|
{
|
|
public function test_reconciliation_repairs_missing_columns_and_can_run_again(): void
|
|
{
|
|
$schema = DB::connection('business_mirror')->getSchemaBuilder();
|
|
$columns = ['m_name', 'm_volume_cm3', 'm_length_cm', 'm_width_cm', 'm_height_cm'];
|
|
$schema->table('jst_oms_shipping', fn ($table) => $table->dropColumn($columns));
|
|
$migration = require base_path('database/migrations/2026_10_07_150000_reconcile_shipping_merged_columns.php');
|
|
$migration->up();
|
|
$migration->up();
|
|
foreach ($columns as $column) {
|
|
$this->assertTrue($schema->hasColumn('jst_oms_shipping', $column));
|
|
}
|
|
}
|
|
|
|
public function test_missing_target_is_reported_instead_of_marked_complete(): void
|
|
{
|
|
DB::connection('business_mirror')->getSchemaBuilder()->drop('jst_oms_shipping');
|
|
$migration = require base_path('database/migrations/2026_10_07_150000_reconcile_shipping_merged_columns.php');
|
|
$this->expectException(\RuntimeException::class);
|
|
$this->expectExceptionMessage('发货镜像表不存在');
|
|
$migration->up();
|
|
}
|
|
}
|