Skip to content

Commit

Permalink
CC-30854: Fixed invalid data helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
abitskil committed Oct 25, 2023
1 parent 71c2b6e commit aecd2f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function buildFixtures(CheckoutApiTester $I): FixturesContainerInterface
ShipmentMethodDataHelper::DEFAULT_PRICE_LIST,
[$storeTransfer->getIdStoreOrFail()],
);
$I->addShipmentTypeToShipmentMethod($this->pickableShipmentMethodTransfer, $I->havePickableShipmentType());
$I->addShipmentTypeToShipmentMethod($this->pickableShipmentMethodTransfer, $I->havePickableShipmentType($storeTransfer));

$this->nonPickableShipmentMethodTransfer = $I->haveShipmentMethod(
[
Expand Down
18 changes: 12 additions & 6 deletions tests/PyzTest/Glue/Checkout/_support/CheckoutApiTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,19 +602,25 @@ public function havePaymentMethodWithStore(
}

/**
* @param \Generated\Shared\Transfer\StoreTransfer $storeTransfer
*
* @return \Generated\Shared\Transfer\ShipmentTypeTransfer
*/
public function havePickableShipmentType(): ShipmentTypeTransfer
public function havePickableShipmentType(StoreTransfer $storeTransfer): ShipmentTypeTransfer
{
$shipmentTypeEntity = SpyShipmentTypeQuery::create()
->filterByKey(static::SHIPMENT_TYPE_KEY_PICKUP)
->findOneOrCreate();
if ($shipmentTypeEntity->isNew()) {
$shipmentTypeEntity->setName(ucfirst(static::SHIPMENT_TYPE_KEY_PICKUP));
$shipmentTypeEntity->save();
->findOne();

if ($shipmentTypeEntity !== null) {
return (new ShipmentTypeTransfer())->fromArray($shipmentTypeEntity->toArray());
}

return (new ShipmentTypeTransfer())->fromArray($shipmentTypeEntity->toArray());
return $this->haveShipmentType([
ShipmentTypeTransfer::IS_ACTIVE => true,
ShipmentTypeTransfer::KEY => static::SHIPMENT_TYPE_KEY_PICKUP,
ShipmentTypeTransfer::STORE_RELATION => (new StoreRelationTransfer())->addStores($storeTransfer),
]);
}

/**
Expand Down

0 comments on commit aecd2f0

Please sign in to comment.