migration = new $class(); $this->context = new UpgradeContext( fromVersion: '1.0.0-beta.4', toVersion: '1.0.0', currentStep: '1.0.0', ); config(['app.locale' => 'ko']); } private function makeAddress(?string $memo): int { $order = OrderFactory::new()->create(); $address = OrderAddressFactory::new()->forOrder($order)->shipping()->create([ 'delivery_memo' => $memo, ]); // 백필 대상 상태로 라벨을 명시적으로 비운다 (생성 경로 라벨 스냅샷 우회) DB::table('ecommerce_order_addresses') ->where('id', $address->id) ->update(['delivery_memo_label' => null]); return $address->id; } public function test_backfills_preset_key_with_korean_label(): void { $id = $this->makeAddress('security'); $this->migration->run($this->context); $this->assertSame( '경비실에 맡겨주세요', DB::table('ecommerce_order_addresses')->where('id', $id)->value('delivery_memo_label') ); } public function test_backfills_custom_text_as_original(): void { $id = $this->makeAddress('문 앞 신발장 위에 두세요'); $this->migration->run($this->context); $this->assertSame( '문 앞 신발장 위에 두세요', DB::table('ecommerce_order_addresses')->where('id', $id)->value('delivery_memo_label') ); } public function test_skips_already_filled_label(): void { $order = OrderFactory::new()->create(); $address = OrderAddressFactory::new()->forOrder($order)->shipping()->create([ 'delivery_memo' => 'door', 'delivery_memo_label' => '기존 라벨 유지', ]); $this->migration->run($this->context); $this->assertSame( '기존 라벨 유지', DB::table('ecommerce_order_addresses')->where('id', $address->id)->value('delivery_memo_label') ); } public function test_skips_empty_memo(): void { $id = $this->makeAddress(null); $this->migration->run($this->context); $this->assertNull( DB::table('ecommerce_order_addresses')->where('id', $id)->value('delivery_memo_label') ); } }