diff --git a/src/Carrier/Service/CarrierBuilder.php b/src/Carrier/Service/CarrierBuilder.php index 79cfe5ea..52d9b1fa 100644 --- a/src/Carrier/Service/CarrierBuilder.php +++ b/src/Carrier/Service/CarrierBuilder.php @@ -179,7 +179,6 @@ private function createCarrier(): void $psCarrier->name = $psCarrier->name ?? $this->myParcelCarrier->human; $psCarrier->active = $this->psCarrierService->carrierIsActive($this->myParcelCarrier); - $psCarrier->id_reference = $this->createCarrierIdReference(); $psCarrier->deleted = false; $psCarrier->external_module_name = $module->name; $psCarrier->is_module = true; @@ -200,16 +199,6 @@ private function createCarrier(): void $this->psCarrier = $psCarrier; } - /** - * @return int - */ - private function createCarrierIdReference(): int - { - $carrierId = str_pad((string) $this->myParcelCarrier->id, 3, '0'); - - return (int) ($carrierId . $this->myParcelCarrier->subscriptionId); - } - /** * @return null|\Carrier */ @@ -223,6 +212,6 @@ private function getExistingPsCarrier(): ?PsCarrier return $this->psCarrierService->get($mapping->getCarrierId()); } - return $this->psCarrierService->getByReference($this->createCarrierIdReference()); + return null; } } diff --git a/tests/Unit/Service/PsCarrierServiceTest.php b/tests/Unit/Service/PsCarrierServiceTest.php index 862360ea..b02c4153 100644 --- a/tests/Unit/Service/PsCarrierServiceTest.php +++ b/tests/Unit/Service/PsCarrierServiceTest.php @@ -10,7 +10,6 @@ use MyParcelNL\Pdk\Base\Support\Collection; use MyParcelNL\Pdk\Carrier\Collection\CarrierCollection; use MyParcelNL\Pdk\Carrier\Model\Carrier; -use MyParcelNL\Pdk\Carrier\Model\CarrierFactory; use MyParcelNL\Pdk\Facade\Actions; use MyParcelNL\Pdk\Facade\Pdk; use MyParcelNL\Pdk\Tests\Api\Response\ExampleAclResponse; @@ -189,47 +188,6 @@ function doSnapshotTest(Collection $carrierMappings, Collection $psCarriers): vo ]); }); -it('uses existing carrier if reference id matches', function (CarrierFactory $factory) { - setupAccountAndCarriers(factory(CarrierCollection::class)->push($factory)); - - $carrier = $factory->make(); - - /** @see \MyParcelNL\PrestaShop\Carrier\Service\CarrierBuilder::createCarrierIdReference() */ - $referenceId = (int) (str_pad((string) $carrier->id, 3, '0') . $carrier->subscriptionId); - - psFactory(PsCarrier::class) - ->withIdReference($referenceId) - ->store(); - - /** @var PsCarrierServiceInterface $service */ - $service = Pdk::get(PsCarrierServiceInterface::class); - $service->updateCarriers(); - - $psCarriers = new Collection(PsCarrier::getCarriers(0)); - - expect($psCarriers->count()) - ->toBe(1) - ->and($psCarriers->first()) - ->toHaveKeysAndValues([ - 'id' => 1, - 'id_reference' => $referenceId, - 'name' => $carrier->human, - ]); -})->with([ - 'only id' => function () { - return factory(Carrier::class) - ->fromPostNL() - ->withHuman('Carrier'); - }, - - 'id and subscription id' => function () { - return factory(Carrier::class) - ->fromDhlForYou() - ->withHuman('Carrier') - ->withSubscriptionId(8123); - }, -]); - it('enables carriers based on settings', function (array $settings, bool $result) { setupCarrierActiveSettings($settings)->store();