row('958530694526', '3768947181063635112', '3768947181063635112'), $this->row('SG006367N1028V01', 'SG0063', '3768947181063635112'), $this->row('SG006367N1028V01', 'SG0063', '3768947181063635112'), ]); $result = $mapper->resolve('3533103677164802', '3768947181063635112'); $this->assertSame('unique', $result['status']); $this->assertSame('SG006367N1028V01', $result['internal_sku']); $this->assertSame(2, $result['history_rows']); $this->assertSame(['经典北美黑胡桃色'], $result['internal_properties']); } public function test_multiple_internal_skus_remain_ambiguous(): void { $mapper = new StoreReceiptPlatformSkuMapper([ $this->row('SG001', 'SGSTYLE1', '3768947181063635112'), $this->row('SG002', 'SGSTYLE2', '3768947181063635112'), ]); $result = $mapper->resolve('3533103677164802', '3768947181063635112'); $this->assertSame('ambiguous', $result['status']); $this->assertNull($result['internal_sku']); $this->assertSame(['SG001', 'SG002'], $result['candidates']); } public function test_missing_history_stays_unmapped(): void { $mapper = new StoreReceiptPlatformSkuMapper([ $this->row('958530694526', '3768947181063635112', '3768947181063635112'), ]); $result = $mapper->resolve('3533103677164802', '3768947181063635112'); $this->assertSame('missing', $result['status']); $this->assertNull($result['internal_sku']); $this->assertSame([], $result['candidates']); } public function test_mapping_requires_the_same_platform_spec_id(): void { $mapper = new StoreReceiptPlatformSkuMapper([ $this->row( 'SG006367N1028V01', 'SG0063', '3768947181063635112', '3533103677164802', ), ]); $result = $mapper->resolve('3533103677164999', '3768947181063635112'); $this->assertSame('missing', $result['status']); $this->assertNull($result['internal_sku']); } /** @return array */ private function row( string $skuId, string $itemId, string $shopItemId, string $shopSkuId = '3533103677164802', ): array { return [ 'shop_sku_id' => $shopSkuId, 'shop_i_id' => $shopItemId, 'sku_id' => $skuId, 'i_id' => $itemId, 'properties_value' => $itemId === 'SG0063' ? '经典北美黑胡桃色' : '', ]; } }