costLines([ $this->row('platform', '955859844397', '3767501840732782900', 20, 2800), $this->row('internal', 'DSG005016N11V01', '3767501840732782900', 20, 2800), ]); $this->assertSame(1, $placeholders); $this->assertSame(0, $bundles); $this->assertSame('DSG005016N11V01', $lines[0]['sku']); $this->assertSame(20.0, $lines[0]['qty']); } public function test_bundle_parent_is_removed_but_component_remains(): void { [$lines, $placeholders, $bundles] = $this->costLines([ $this->row('bundle-parent', '运营组合套装12994', '3832980288011632985', 2, 696), $this->row( 'bundle-child', 'SJ038017N1410V02', '3832980288011632985', 2, 625.26, '运营组合套装12994', ), ]); $this->assertSame(0, $placeholders); $this->assertSame(1, $bundles); $this->assertSame('SJ038017N1410V02', $lines[0]['sku']); $this->assertSame(2.0, $lines[0]['qty']); } /** @return array{0:list>,1:int,2:int} */ private function costLines(array $rows): array { $command = new SyncStoreReceiptProductCost(); $method = new ReflectionMethod($command, 'costLines'); $method->setAccessible(true); $placeholders = 0; $bundles = 0; $lines = $method->invokeArgs($command, [$rows, &$placeholders, &$bundles]); return [$lines, $placeholders, $bundles]; } /** @return array */ private function row( string $rowKey, string $sku, string $shopItemId, float $quantity, float $amount, string $bundleParent = '', ): array { return [ 'source' => 'jst', 'sku' => $sku, 'qty' => $quantity, 'amount' => $amount, 'warehouse' => '简尚-新苏北仓', 'o_id' => '8986587', 'parent_o_id' => '', 'row_key' => $rowKey, 'status' => 'Sent', 'shop_i_id' => $shopItemId, 'src_combine_sku_id' => $bundleParent, ]; } }