diff --git a/src/Adapter/Carrier/CommandHandler/AddCarrierHandler.php b/src/Adapter/Carrier/CommandHandler/AddCarrierHandler.php index d850cf0241f89..e07e17d25f864 100644 --- a/src/Adapter/Carrier/CommandHandler/AddCarrierHandler.php +++ b/src/Adapter/Carrier/CommandHandler/AddCarrierHandler.php @@ -62,7 +62,6 @@ public function handle(AddCarrierCommand $command): CarrierId $carrier->name = $command->getName(); $carrier->grade = $command->getGrade(); $carrier->url = $command->getTrackingUrl(); - $carrier->position = $command->getPosition(); $carrier->active = $command->getActive(); $carrier->delay = $command->getLocalizedDelay(); $carrier->max_width = $command->getMaxWidth(); @@ -70,6 +69,12 @@ public function handle(AddCarrierCommand $command): CarrierId $carrier->max_weight = $command->getMaxWeight(); $carrier->max_depth = $command->getMaxDepth(); + if (null !== $command->getPosition()) { + $carrier->position = $command->getPosition(); + } else { + $this->carrierRepository->getLastPosition() + 1; + } + // Shipping information $carrier->shipping_handling = $command->hasAdditionalHandlingFee(); $carrier->is_free = $command->isFree(); diff --git a/src/Adapter/Carrier/QueryHandler/GetCarrierForEditingHandler.php b/src/Adapter/Carrier/QueryHandler/GetCarrierForEditingHandler.php index d293bb527c4a2..6faadf0fa323f 100644 --- a/src/Adapter/Carrier/QueryHandler/GetCarrierForEditingHandler.php +++ b/src/Adapter/Carrier/QueryHandler/GetCarrierForEditingHandler.php @@ -76,7 +76,7 @@ public function handle(GetCarrierForEditing $query): EditableCarrier (int) $carrier->range_behavior, $carrier->getAssociatedShops(), $logoPath, - $this->carrierRepository->ordersCount($query->getCarrierId()), + $this->carrierRepository->getOrdersCount($query->getCarrierId()), ); } } diff --git a/src/Adapter/Carrier/Repository/CarrierRangeRepository.php b/src/Adapter/Carrier/Repository/CarrierRangeRepository.php index b198dd01efb09..585773f3bb36b 100644 --- a/src/Adapter/Carrier/Repository/CarrierRangeRepository.php +++ b/src/Adapter/Carrier/Repository/CarrierRangeRepository.php @@ -149,6 +149,15 @@ public function set(CarrierId $carrierId, CarrierRangesCollection $rangesCollect ] ); } + + // We add the association between the carrier and the zone. + $this->connection->insert( + $this->dbPrefix . 'carrier_zone', + [ + 'id_carrier' => $carrierId->getValue(), + 'id_zone' => $idZone, + ] + ); } // Commit transaction @@ -186,6 +195,14 @@ private function reset(CarrierId $carrierId, ShopConstraint $shopConstraint): vo ->setParameter('carrierId', $carrierId->getValue()) ->executeQuery(); } + + // Then , we delete carriers association with zones + $this->connection->delete( + $this->dbPrefix . 'carrier_zone', + [ + 'id_carrier' => $carrierId->getValue(), + ] + ); } private function getRangeMethodTable(int $calculatingMethod): string diff --git a/src/Adapter/Carrier/Repository/CarrierRepository.php b/src/Adapter/Carrier/Repository/CarrierRepository.php index a0344f66a9d1f..cbd604acaf664 100644 --- a/src/Adapter/Carrier/Repository/CarrierRepository.php +++ b/src/Adapter/Carrier/Repository/CarrierRepository.php @@ -172,7 +172,7 @@ public function getAssociatedShopIdsFromGroup(CarrierId $carrierId, ShopGroupId public function getEditableOrNewVersion(CarrierId $carrierId): Carrier { // If the carrier don't have orders linked, we can return it as is - if ($this->ordersCount($carrierId) === 0) { + if ($this->getOrdersCount($carrierId) === 0) { return $this->get($carrierId); } @@ -278,7 +278,7 @@ private function deleteTaxRulesGroup(CarrierId $carrierId, array $shopIds): void $qb->executeStatement(); } - public function ordersCount(CarrierId $carrierId): int + public function getOrdersCount(CarrierId $carrierId): int { $qb = $this->connection->createQueryBuilder(); @@ -291,4 +291,17 @@ public function ordersCount(CarrierId $carrierId): int return $count; } + + public function getLastPosition(): int + { + $qb = $this->connection->createQueryBuilder(); + + return $qb->select('c.position') + ->from($this->prefix . 'carrier', 'c') + ->orderBy('c.position', 'DESC') + ->setMaxResults(1) + ->executeQuery() + ->fetchOne() + ; + } } diff --git a/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php b/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php index 8c88434ed4970..a5959e243a54e 100644 --- a/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php +++ b/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php @@ -68,7 +68,6 @@ public function handle(UpdateCartCarrierCommand $command) $cart->setDeliveryOption([ (int) $cart->id_address_delivery => $this->formatLegacyDeliveryOptionFromCarrierId($command->getNewCarrierId()), ]); - $cart->update(); } finally { $this->contextStateManager->restorePreviousContext(); diff --git a/src/Core/Domain/Carrier/Command/AddCarrierCommand.php b/src/Core/Domain/Carrier/Command/AddCarrierCommand.php index e0f809f5ac520..b80199b2ec9be 100644 --- a/src/Core/Domain/Carrier/Command/AddCarrierCommand.php +++ b/src/Core/Domain/Carrier/Command/AddCarrierCommand.php @@ -46,6 +46,8 @@ class AddCarrierCommand */ private array $associatedShopIds; + private ?int $position = null; + /** * @throws CarrierConstraintException */ @@ -55,7 +57,6 @@ public function __construct( private array $localizedDelay, private int $grade, private string $trackingUrl, - private int $position, private bool $active, private array $associatedGroupIds, private bool $hasAdditionalHandlingFee, @@ -95,11 +96,16 @@ public function getTrackingUrl(): string return $this->trackingUrl; } - public function getPosition(): int + public function getPosition(): ?int { return $this->position; } + public function setPosition(int $position): void + { + $this->position = $position; + } + public function getActive(): bool { return $this->active; diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CarrierFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CarrierFormDataHandler.php index bd9c1b546b80c..5e82712c95ed0 100644 --- a/src/Core/Form/IdentifiableObject/DataHandler/CarrierFormDataHandler.php +++ b/src/Core/Form/IdentifiableObject/DataHandler/CarrierFormDataHandler.php @@ -57,7 +57,6 @@ public function create(array $data) $data['general_settings']['localized_delay'], $data['general_settings']['grade'], $data['general_settings']['tracking_url'] ?? '', - 0, // @todo: should not be in the add command but auto-computed or at least be optional (bool) $data['general_settings']['active'], $data['general_settings']['group_access'], (bool) $data['shipping_settings']['has_additional_handling_fee'], diff --git a/tests/Integration/Behaviour/Features/Context/CarrierFeatureContext.php b/tests/Integration/Behaviour/Features/Context/CarrierFeatureContext.php index 8a94b6106ff41..ce7216e51f6c1 100644 --- a/tests/Integration/Behaviour/Features/Context/CarrierFeatureContext.php +++ b/tests/Integration/Behaviour/Features/Context/CarrierFeatureContext.php @@ -35,9 +35,7 @@ use Context; use Country; use Exception; -use Group; use RangePrice; -use RangeWeight; use RuntimeException; use State; use Zone; @@ -97,31 +95,11 @@ public function before(BeforeScenarioScope $scope) $this->customerFeatureContext = $customerFeatureContext; } - /** - * @Given /^there is a zone named "(.+)"$/ - */ - public function createZone($zoneName) - { - $zone = new Zone(); - $zone->name = $zoneName; - $zone->add(); - $this->zones[$zoneName] = $zone; - } - - /** - * @param string $zoneName - */ - public function checkZoneWithNameExists(string $zoneName): void - { - $this->checkFixtureExists($this->zones, 'Zone', $zoneName); - } - /** * @Given /^there is a country named "(.+)" and iso code "(.+)" in zone "(.+)"$/ */ public function createCountry($countryName, $isoCode, $zoneName) { - $this->checkZoneWithNameExists($zoneName); $countryId = Country::getByIso($isoCode, false); if (!$countryId) { throw new Exception('Country not found with iso code = ' . $isoCode); @@ -130,7 +108,7 @@ public function createCountry($countryName, $isoCode, $zoneName) // clone country to be able to properly reset previous data $this->previousCountries[$countryName] = clone $country; $this->countries[$countryName] = $country; - $country->id_zone = $this->zones[$zoneName]->id; + $country->id_zone = $this->getSharedStorage()->get($zoneName)->id; $country->active = true; $country->save(); @@ -160,15 +138,15 @@ public function checkCountryWithNameExists(string $countryName): void */ public function createState($stateName, $stateIsoCode, $countryName, $zoneName) { - $this->checkZoneWithNameExists($zoneName); - $this->checkCountryWithNameExists($countryName); $state = new State(); $state->name = $stateName; $state->iso_code = $stateIsoCode; - $state->id_zone = $this->zones[$zoneName]->id; - $state->id_country = $this->countries[$countryName]->id; + $state->id_zone = $this->getSharedStorage()->get($zoneName)->id; + $state->id_country = $this->getSharedStorage()->get($countryName); $state->add(); $this->states[$stateName] = $state; + + $this->getSharedStorage()->set($stateName, (int) $state->id); } /** @@ -229,114 +207,6 @@ public function checkAddressWithNameExists(string $addressName): void $this->checkFixtureExists($this->addresses, 'Address', $addressName); } - /** - * @Given /^there is a carrier named "(.+)"$/ - */ - public function createCarrier($carrierName) - { - $carrier = new Carrier(null, (int) Configuration::get('PS_LANG_DEFAULT')); - $carrier->name = $carrierName; - $carrier->shipping_method = Carrier::SHIPPING_METHOD_PRICE; - $carrier->delay = '28 days later'; - $carrier->active = true; - $carrier->add(); - $this->carriers[$carrierName] = $carrier; - SharedStorage::getStorage()->set($carrierName, (int) $carrier->id); - - $groups = Group::getGroups(Context::getContext()->language->id); - $groupIds = []; - foreach ($groups as $group) { - $groupIds[] = $group['id_group']; - } - $carrier->setGroups($groupIds); - } - - /** - * @Given /^carrier "(.+)" ships to all groups$/ - */ - public function setCarrierShipsToAllGroups($carrierName) - { - $this->checkCarrierWithNameExists($carrierName); - $carrier = $this->carriers[$carrierName]; - - $groups = Group::getGroups(Context::getContext()->language->id); - $groupIds = []; - foreach ($groups as $group) { - $groupIds[] = $group['id_group']; - } - $carrier->setGroups($groupIds); - } - - /** - * @Given /^the carrier "(.+)" uses "(.+)" as tracking url$/ - */ - public function setCarrierTrackingUrl(string $carrierName, string $url): void - { - $this->checkCarrierWithNameExists($carrierName); - $carrier = $this->carriers[$carrierName]; - $carrier->url = $url; - $carrier->save(); - } - - /** - * @param string $carrierName - */ - public function checkCarrierWithNameExists(string $carrierName): void - { - $this->checkFixtureExists($this->carriers, 'Carrier', $carrierName); - } - - /** - * @param string $carrierName - * - * @return Carrier - */ - public function getCarrierWithName(string $carrierName): Carrier - { - return $this->carriers[$carrierName]; - } - - /** - * Be careful: this method REPLACES shipping fees for carrier - * - * @Given /^carrier "(.+)" applies shipping fees of (\d+\.\d+) in zone "(.+)" for (weight|price) between (\d+) and (\d+)$/ - */ - public function setCarrierFees($carrierName, $shippingPrice, $zoneName, $rangeType, $from, $to) - { - $this->checkCarrierWithNameExists($carrierName); - $this->checkZoneWithNameExists($zoneName); - if (empty($this->carriers[$carrierName]->getZone((int) $this->zones[$zoneName]->id))) { - $this->carriers[$carrierName]->addZone((int) $this->zones[$zoneName]->id); - } - $rangeClass = $rangeType == 'weight' ? RangeWeight::class : RangePrice::class; - $primary = $rangeType == 'weight' ? 'id_range_weight' : 'id_range_price'; - $rangeRows = $rangeClass::getRanges($this->carriers[$carrierName]->id); - $rangeId = false; - foreach ($rangeRows as $rangeRow) { - if ($rangeRow['delimiter1'] == $from) { - $rangeId = $rangeRow[$primary]; - } - } - if (!empty($rangeId)) { - $range = new $rangeClass($rangeId); - } else { - $range = new $rangeClass(); - $range->id_carrier = $this->carriers[$carrierName]->id; - $range->delimiter1 = $from; - $range->delimiter2 = $to; - $range->add(); - $this->priceRanges[] = $range; - } - $carrierPriceRange = [ - 'id_range_price' => (int) $range->id, - 'id_range_weight' => null, - 'id_carrier' => (int) $this->carriers[$carrierName]->id, - 'id_zone' => (int) $this->zones[$zoneName]->id, - 'price' => $shippingPrice, - ]; - $this->carriers[$carrierName]->addDeliveryPrice([$carrierPriceRange], true); - } - /** * @AfterScenario */ @@ -374,10 +244,9 @@ public function cleanFixtures() /** * @When /^I select carrier "(.+)" in my cart$/ */ - public function setCartCarrier($carrierName) + public function setCartCarrier(string $carrierReference) { - $this->checkCarrierWithNameExists($carrierName); - $this->getCurrentCart()->id_carrier = $this->carriers[$carrierName]->id; + $this->getCurrentCart()->id_carrier = $this->getSharedStorage()->get($carrierReference); $this->getCurrentCart()->update(); @@ -417,33 +286,4 @@ public function checkExistingCarrier(string $carrierReference, string $carrierNa $carrierName )); } - - /** - * @Given I enable carrier :carrierReference - * - * @param string $carrierReference - */ - public function enableCarrier(string $carrierReference) - { - $carrierId = SharedStorage::getStorage()->get($carrierReference); - $carrier = new Carrier($carrierId); - $carrier->active = true; - $carrier->save(); - // Reset cache so that the carrier becomes selectable - Carrier::resetStaticCache(); - } - - /** - * @Then I associate the tax rule group :taxRulesGroupReference to carrier :carrierReference - * - * @param string $taxRulesGroupReference - * @param string $carrierReference - */ - public function associateCarrierTaxRulesGroup(string $taxRulesGroupReference, string $carrierReference) - { - $carrierId = SharedStorage::getStorage()->get($carrierReference); - $taxRulesGroupId = SharedStorage::getStorage()->get($taxRulesGroupReference); - $carrier = new Carrier($carrierId); - $carrier->setTaxRulesGroup($taxRulesGroupId); - } } diff --git a/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierFeatureContext.php b/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierFeatureContext.php index 6a3908f542ea9..6a72fdd8cff4e 100644 --- a/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierFeatureContext.php +++ b/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierFeatureContext.php @@ -30,8 +30,6 @@ use Behat\Gherkin\Node\TableNode; use Carrier; -use Configuration; -use Context; use Exception; use Group; use PHPUnit\Framework\Assert; @@ -44,7 +42,6 @@ use PrestaShop\PrestaShop\Core\Domain\Carrier\ValueObject\OutOfRangeBehavior; use PrestaShop\PrestaShop\Core\Domain\Carrier\ValueObject\ShippingMethod; use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; -use PrestaShopException; use Tests\Integration\Behaviour\Features\Context\Domain\AbstractDomainFeatureContext; use Tests\Integration\Behaviour\Features\Context\Domain\TaxRulesGroupFeatureContext; use Tests\Resources\DummyFileUploader; @@ -60,40 +57,6 @@ public static function restoreCarrierTablesAfterSuite(): void CarrierResetter::resetCarrier(); } - /** - * @todo: It is a temporary method to use sharedStorage and should be improved once Carrier creation is migrated. - * - * @Given carrier :carrierReference named :carrierName exists - * - * @param string $carrierReference - * @param string $carrierName - * - * @throws PrestaShopException - */ - public function createDefaultIfNotExists(string $carrierReference, string $carrierName): void - { - if ($this->getSharedStorage()->exists($carrierReference)) { - return; - } - - $carrier = new Carrier(null, (int) Configuration::get('PS_LANG_DEFAULT')); - $carrier->name = $carrierName; - $carrier->shipping_method = Carrier::SHIPPING_METHOD_PRICE; - $carrier->delay = '28 days later'; - $carrier->active = true; - $carrier->add(); - - $groups = Group::getGroups(Context::getContext()->language->id); - $groupIds = []; - foreach ($groups as $group) { - $groupIds[] = $group['id_group']; - } - - $carrier->setGroups($groupIds); - - $this->getSharedStorage()->set($carrierReference, (int) $carrier->id); - } - /** * @When I create carrier :reference with specified properties: */ @@ -112,24 +75,36 @@ public function createCarrier(string $reference, TableNode $node): void $associatedShops = [$this->getDefaultShopId()]; } + if (!empty($properties['delay'])) { + $delay = $properties['delay']; + } else { + $delay = [$this->getDefaultLangId() => 'Shipping delay']; + } + + if (!empty($properties['group_access'])) { + $groupIds = $this->referencesToIds($properties['group_access']); + } else { + $groupIds = Group::getAllGroupIds(); + } + $carrierId = $this->createCarrierUsingCommand( $properties['name'], - $properties['delay'], - (int) $properties['grade'], - $properties['trackingUrl'], - (int) $properties['position'], - filter_var($properties['active'], FILTER_VALIDATE_BOOLEAN), - (int) $properties['max_width'], - (int) $properties['max_height'], - (int) $properties['max_depth'], - (int) $properties['max_weight'], - $this->referencesToIds($properties['group_access']), - filter_var($properties['shippingHandling'], FILTER_VALIDATE_BOOLEAN), - filter_var($properties['isFree'], FILTER_VALIDATE_BOOLEAN), - $properties['shippingMethod'], - $properties['rangeBehavior'], + $delay, + (int) ($properties['grade'] ?? 0), + $properties['trackingUrl'] ?? '', + filter_var($properties['active'] ?? true, FILTER_VALIDATE_BOOLEAN), + (int) ($properties['max_width'] ?? 0), + (int) ($properties['max_height'] ?? 0), + (int) ($properties['max_depth'] ?? 0), + (int) ($properties['max_weight'] ?? 0), + $groupIds, + filter_var($properties['shippingHandling'] ?? true, FILTER_VALIDATE_BOOLEAN), + filter_var($properties['isFree'] ?? false, FILTER_VALIDATE_BOOLEAN), + $properties['shippingMethod'] ?? 'price', + $properties['rangeBehavior'] ?? 'highest_range', $properties['logoPathName'] ?? null, $associatedShops, + isset($properties['position']) ? (int) $properties['position'] : null, ); if (isset($tmpLogo)) { @@ -148,21 +123,41 @@ public function createCarrier(string $reference, TableNode $node): void public function editCarrierWithoutUpdate(string $reference, TableNode $node): void { try { + $initialCarrierId = $this->getSharedStorage()->get($reference); $carrierId = $this->editCarrier($reference, null, $node); - Assert::assertEquals($this->getSharedStorage()->get($reference), $carrierId->getValue()); + Assert::assertEquals($initialCarrierId, $carrierId->getValue(), 'Carrier ID was expected the remain the same'); } catch (CarrierConstraintException $e) { $this->setLastException($e); } } /** - * @When I edit carrier :reference with specified properties I get a new carrier called :newReference: + * @When I edit carrier :reference with specified properties I get a new carrier referenced as :newReference: */ public function editCarrierWithUpdate(string $reference, string $newReference, TableNode $node): void { try { + $initialCarrierId = $this->getSharedStorage()->get($reference); $carrierId = $this->editCarrier($reference, $newReference, $node); - Assert::assertNotEquals($this->getSharedStorage()->get($reference), $carrierId->getValue()); + Assert::assertNotEquals($initialCarrierId, $carrierId->getValue(), 'Carrier ID was expected to be updated'); + } catch (CarrierConstraintException $e) { + $this->setLastException($e); + } + } + + /** + * The carrier ID may be changed after an update if it was already associated to an order, to help write + * scenarios more easily this step automatically updates the ID referenced so that following steps can keep + * using the same reference. + * + * @When I edit carrier :reference with specified properties and update its reference: + */ + public function editCarrierWithPotentialUpdate(string $reference, TableNode $node): void + { + // We update carrier and references but without checking if it was modified + try { + $this->getSharedStorage()->get($reference); + $this->editCarrier($reference, $reference, $node); } catch (CarrierConstraintException $e) { $this->setLastException($e); } @@ -255,7 +250,12 @@ private function editCarrier(string $reference, ?string $newReference, TableNode if (isset($tmpLogo)) { $this->fakeUploadLogo($tmpLogo, $newCarrierId->getValue()); } - $this->getSharedStorage()->set($newReference, $newCarrierId->getValue()); + if ($newReference) { + $this->getSharedStorage()->set($newReference, $newCarrierId->getValue()); + } + + // Reset cache so that the carrier becomes selectable + Carrier::resetStaticCache(); return $newCarrierId; } @@ -393,7 +393,6 @@ private function createCarrierUsingCommand( array $delay, int $grade, string $trackingUrl, - int $position, bool $active, int $max_width, int $max_height, @@ -406,13 +405,13 @@ private function createCarrierUsingCommand( string $rangeBehavior, ?string $logoPathName, array $associatedShops, + ?int $position, ): CarrierId { $command = new AddCarrierCommand( $name, $delay, $grade, $trackingUrl, - $position, $active, $group_access, $hasAdditionalHandlingFee, @@ -427,6 +426,10 @@ private function createCarrierUsingCommand( $logoPathName, ); + if (null !== $position) { + $command->setPosition($position); + } + return $this->getCommandBus()->handle($command); } diff --git a/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierRangesFeatureContext.php b/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierRangesFeatureContext.php index e6a2317ccb6f3..f4b85f6d4463d 100644 --- a/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierRangesFeatureContext.php +++ b/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierRangesFeatureContext.php @@ -30,24 +30,45 @@ use Behat\Gherkin\Node\TableNode; use Carrier; +use Db; +use DbQuery; use PHPUnit\Framework\Assert; use PrestaShop\PrestaShop\Core\Domain\Carrier\Command\SetCarrierRangesCommand; +use PrestaShop\PrestaShop\Core\Domain\Carrier\Exception\CarrierConstraintException; use PrestaShop\PrestaShop\Core\Domain\Carrier\Exception\CarrierException; use PrestaShop\PrestaShop\Core\Domain\Carrier\Query\GetCarrierRanges; use PrestaShop\PrestaShop\Core\Domain\Carrier\QueryResult\CarrierRangesCollection; use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; +use RuntimeException; use Tests\Integration\Behaviour\Features\Context\Domain\AbstractDomainFeatureContext; +use Zone; class CarrierRangesFeatureContext extends AbstractDomainFeatureContext { /** - * @Then I set ranges for carrier :reference called :newReference with specified properties for all shops: + * @Then I set ranges for carrier :reference with specified properties for all shops: + */ + public function setCarrierRangesAllShopsWithoutIdUpdate(string $reference, TableNode $node): void + { + $this->setCarrierRanges($reference, null, ShopConstraint::allShops(), $node); + } + + /** + * @Then I set ranges for carrier :reference with specified properties for all shops I get a new carrier referenced as :newReference: */ public function setCarrierRangesAllShops(string $reference, string $newReference, TableNode $node): void { $this->setCarrierRanges($reference, $newReference, ShopConstraint::allShops(), $node); } + /** + * @Then I set ranges for carrier :reference with specified properties for shop :shopReference: + */ + public function setCarrierRangesShopWithoutIdUpdate(string $reference, string $shopReference, TableNode $node): void + { + $this->setCarrierRanges($reference, null, $this->getShopConstraint($shopReference), $node); + } + /** * @Then I set ranges for carrier :reference called :newReference with specified properties for shop :shopReference: */ @@ -72,15 +93,37 @@ public function getCarrierRangesShop(string $reference, string $shopReference, T $this->getCarrierRanges($reference, $this->getShopConstraint($shopReference), $node); } - private function setCarrierRanges(string $reference, string $newReference, ShopConstraint $shopConstraint, TableNode $node): void + private function setCarrierRanges(string $reference, ?string $newReference, ShopConstraint $shopConstraint, TableNode $node): void { try { - $carrierId = $this->referenceToId($reference); + $initialCarrierId = $this->referenceToId($reference); + $data = $node->getColumnsHash(); + + foreach ($data as &$range) { + try { + /** @var Zone $zone */ + $zone = $this->getSharedStorage()->get($range['id_zone']); + $range['id_zone'] = $zone->id; + } catch (RuntimeException $e) { + $this->setLastException(new CarrierConstraintException( + sprintf('Invalid zone id reference %d supplied. Zone id must be a positive integer.', $range['id_zone']), + CarrierConstraintException::INVALID_ZONE_ID + )); + } + } - $command = new SetCarrierRangesCommand($carrierId, $node->getColumnsHash(), $shopConstraint); + $command = new SetCarrierRangesCommand($initialCarrierId, $data, $shopConstraint); $carrierId = $this->getCommandBus()->handle($command); - $this->getSharedStorage()->set($newReference, $carrierId->getValue()); + if ($newReference) { + Assert::assertNotEquals($initialCarrierId, $carrierId->getValue(), 'Carrier ID was expected to be updated'); + $this->getSharedStorage()->set($newReference, $carrierId->getValue()); + } else { + Assert::assertEquals($initialCarrierId, $carrierId->getValue(), 'Carrier ID was expected the remain the same'); + } + + // Reset cache so that the carrier becomes selectable + Carrier::resetStaticCache(); } catch (CarrierException $e) { $this->setLastException($e); } @@ -94,9 +137,31 @@ private function getCarrierRanges(string $reference, ShopConstraint $shopConstra $command = new GetCarrierRanges($carrierId, $shopConstraint); $rangesDatabase = $this->getCommandBus()->handle($command); - $rangesExpected = new CarrierRangesCollection($node->getColumnsHash()); + $data = $node->getColumnsHash(); + $zoneIds = []; + foreach ($data as &$range) { + /** @var Zone $zone */ + $zone = $this->referencesToIds($range['id_zone'])[0]; + $range['id_zone'] = $zone->id; + $zoneIds[] = $zone->id; + } + $rangesExpected = new CarrierRangesCollection($data); Assert::assertEquals($rangesExpected, $rangesDatabase); + + // Automatically checks that the carrier_zone association is properly set + $query = new DbQuery(); + $query->select('(cz.id_zone)'); + $query->from('carrier_zone', 'cz'); + $query->where('id_carrier = \'' . pSQL((string) $carrierId) . '\''); + $zonesFromDB = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query->build()); + + $zoneIds = array_unique($zoneIds); + sort($zoneIds); + $zonesFromDB = array_map(fn ($row) => $row['id_zone'], $zonesFromDB); + sort($zonesFromDB); + + Assert::assertEquals($zoneIds, $zonesFromDB); } catch (CarrierException $e) { $this->setLastException($e); } diff --git a/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierTaxRuleGroupFeatureContext.php b/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierTaxRuleGroupFeatureContext.php index 7231d6607ce82..2bfbfd80e7071 100644 --- a/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierTaxRuleGroupFeatureContext.php +++ b/tests/Integration/Behaviour/Features/Context/Domain/Carrier/CarrierTaxRuleGroupFeatureContext.php @@ -26,47 +26,64 @@ namespace Tests\Integration\Behaviour\Features\Context\Domain\Carrier; -use Behat\Gherkin\Node\TableNode; +use Carrier; use Exception; +use PHPUnit\Framework\Assert; use PrestaShop\PrestaShop\Core\Domain\Carrier\Command\SetCarrierTaxRuleGroupCommand; +use PrestaShop\PrestaShop\Core\Domain\Carrier\ValueObject\CarrierId; use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupNotFoundException; use Tests\Integration\Behaviour\Features\Context\Domain\AbstractDomainFeatureContext; -use Tests\Integration\Behaviour\Features\Context\Domain\TaxRulesGroupFeatureContext; class CarrierTaxRuleGroupFeatureContext extends AbstractDomainFeatureContext { /** - * @When I set tax rule for carrier :reference with specified properties: + * @When I set tax rule :taxRulesGroupReference for carrier :reference */ - public function editTaxRule(string $reference, TableNode $node): void + public function editTaxRuleWithoutIdUpdate(string $reference, string $taxRulesGroupReference): void + { + $initialCarrierId = $this->getSharedStorage()->get($reference); + $carrierId = $this->editCarrierTaxRule($reference, null, $taxRulesGroupReference); + if ($carrierId) { + Assert::assertEquals($initialCarrierId, $carrierId->getValue(), 'Carrier ID was expected the remain the same'); + } + } + + /** + * @When I set tax rule :taxRulesGroupReference for carrier :reference I get a new carrier referenced as :newReference + */ + public function editTaxRuleWithIdUpdate(string $reference, string $newReference, string $taxRulesGroupReference): void + { + $initialCarrierId = $this->getSharedStorage()->get($reference); + $carrierId = $this->editCarrierTaxRule($reference, $newReference, $taxRulesGroupReference); + if ($carrierId) { + Assert::assertNotEquals($initialCarrierId, $carrierId->getValue(), 'Carrier ID was expected to be updated'); + } + } + + protected function editCarrierTaxRule(string $reference, ?string $newReference, string $taxRulesGroupReference): ?CarrierId { - $properties = $this->localizeByRows($node); $carrierId = $this->referenceToId($reference); try { - if (isset($properties['taxRuleGroup'])) { - $command = new SetCarrierTaxRuleGroupCommand( - $carrierId, - (int) TaxRulesGroupFeatureContext::getTaxRulesGroupByName($properties['taxRuleGroup'])->id, - ShopConstraint::allShops() - ); + $command = new SetCarrierTaxRuleGroupCommand( + $carrierId, + 'wrong-tax-rules' === $taxRulesGroupReference ? 4242 : $this->referenceToId($taxRulesGroupReference), + ShopConstraint::allShops() + ); - $newCarrierId = $this->getCommandBus()->handle($command); - $this->getSharedStorage()->set($reference, $newCarrierId->getValue()); + /** @var CarrierId $carrierIdVO */ + $carrierIdVO = $this->getCommandBus()->handle($command); + if ($newReference) { + $this->getSharedStorage()->set($newReference, $carrierIdVO->getValue()); } + // Reset cache so that the carrier becomes selectable + Carrier::resetStaticCache(); + + return $carrierIdVO; } catch (Exception $e) { $this->setLastException($e); } - } - /** - * @Then I should get error that tax rules group does not exist - */ - public function checkCartRuleError(): void - { - $this->assertLastErrorIs( - TaxRulesGroupNotFoundException::class - ); + return null; } } diff --git a/tests/Integration/Behaviour/Features/Context/TaxFeatureContext.php b/tests/Integration/Behaviour/Features/Context/TaxFeatureContext.php index 2bf60b5729ffc..975b6781f6090 100644 --- a/tests/Integration/Behaviour/Features/Context/TaxFeatureContext.php +++ b/tests/Integration/Behaviour/Features/Context/TaxFeatureContext.php @@ -193,17 +193,6 @@ public function setProductTaxRuleGroup($productName, $taxName) Cache::clean('product_id_tax_rules_group_*'); } - /** - * @Given /^carrier "(.+)" belongs to tax group "(.+)"$/ - */ - public function setCarrierTaxRuleGroup($carrierName, $taxName) - { - $this->carrierFeatureContext->checkCarrierWithNameExists($carrierName); - $this->checkTaxRuleWithNameExists($taxName); - $carrier = $this->carrierFeatureContext->getCarrierWithName($carrierName); - $carrier->setTaxRulesGroup($this->taxRuleGroups[$taxName]->id); - } - /** * @Given /^Ecotax belongs to tax group "(.+)"$/ */ diff --git a/tests/Integration/Behaviour/Features/Scenario/Carrier/Ranges/carrier_ranges.feature b/tests/Integration/Behaviour/Features/Scenario/Carrier/Ranges/carrier_ranges.feature index 0f0a6c999da73..0adabd0700453 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Carrier/Ranges/carrier_ranges.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Carrier/Ranges/carrier_ranges.feature @@ -12,123 +12,73 @@ Feature: Carrier ranges Given group "guest" named "Guest" exists And language "en" with locale "en-US" exists And language with iso code "en" is the default one + Given I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | + Given I add new zone "zone2" with following properties: + | name | zone2 | + | enabled | true | Scenario: Adding prices ranges in carrier When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | price | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for all shops: + Then I set ranges for carrier "carrier1" with specified properties for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 20 | - | 1 | 200 | 300 | 30 | - | 1 | 300 | 400 | 40 | - | 2 | 0 | 100 | 15 | - | 2 | 100 | 200 | 25 | - Then carrier "newCarrier1" should have the following ranges for all shops: + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 20 | + | zone1 | 200 | 300 | 30 | + | zone1 | 300 | 400 | 40 | + | zone2 | 0 | 100 | 15 | + | zone2 | 100 | 200 | 25 | + Then carrier "carrier1" should have the following ranges for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 20 | - | 1 | 200 | 300 | 30 | - | 1 | 300 | 400 | 40 | - | 2 | 0 | 100 | 15 | - | 2 | 100 | 200 | 25 | + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 20 | + | zone1 | 200 | 300 | 30 | + | zone1 | 300 | 400 | 40 | + | zone2 | 0 | 100 | 15 | + | zone2 | 100 | 200 | 25 | Scenario: Adding weight ranges in carrier When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | weight | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for all shops: + Then I set ranges for carrier "carrier1" with specified properties for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 20 | - | 1 | 200 | 300 | 30 | - | 1 | 300 | 400 | 40 | - | 2 | 0 | 100 | 15 | - | 2 | 100 | 200 | 25 | - Then carrier "newCarrier1" should have the following ranges for all shops: + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 20 | + | zone1 | 200 | 300 | 30 | + | zone1 | 300 | 400 | 40 | + | zone2 | 0 | 100 | 15 | + | zone2 | 100 | 200 | 25 | + And carrier "carrier1" should have the following ranges for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 20 | - | 1 | 200 | 300 | 30 | - | 1 | 300 | 400 | 40 | - | 2 | 0 | 100 | 15 | - | 2 | 100 | 200 | 25 | + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 20 | + | zone1 | 200 | 300 | 30 | + | zone1 | 300 | 400 | 40 | + | zone2 | 0 | 100 | 15 | + | zone2 | 100 | 200 | 25 | Scenario: Adding overlapping ranges in carrier When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | weight | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for all shops: + Then I set ranges for carrier "carrier1" with specified properties for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 200 | 300 | 30 | - | 1 | 0 | 100 | 10 | - | 1 | 50 | 200 | 20 | - | 1 | 300 | 400 | 40 | - | 2 | 0 | 100 | 15 | - | 2 | 100 | 200 | 25 | + | zone1 | 200 | 300 | 30 | + | zone1 | 0 | 100 | 10 | + | zone1 | 50 | 200 | 20 | + | zone1 | 300 | 400 | 40 | + | zone2 | 0 | 100 | 15 | + | zone2 | 100 | 200 | 25 | Then carrier edit should throw an error with error code "INVALID_RANGES_OVERLAPPING" Scenario: Get ranges for not all shops When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | weight | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | Then carrier "carrier1" should have the following ranges for shop "shop1": | range_from | range_to | id_zone | range_price | | 0 | 100 | 1 | 10 | @@ -137,111 +87,55 @@ Feature: Carrier ranges Scenario: Set ranges for not all shops When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | weight | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for shop "shop1": + Then I set ranges for carrier "carrier1" with specified properties for shop "shop1": | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | + | zone1 | 0 | 100 | 10 | Then carrier edit should throw an error with error code "INVALID_SHOP_CONSTRAINT" Scenario: Set ranges with invalid zone When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | weight | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for all shops: + Then I set ranges for carrier "carrier1" with specified properties for all shops: | id_zone | range_from | range_to | range_price | - | 0 | 0 | 100 | 10 | + | zone0 | 0 | 100 | 10 | Then carrier edit should throw an error with error code "INVALID_ZONE_ID" Scenario: Adding prices ranges in carrier with random sorting of ranges When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | price | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for all shops: + Then I set ranges for carrier "carrier1" with specified properties for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 300 | 400 | 40 | - | 1 | 100 | 200 | 20 | - | 1 | 200 | 300 | 30 | - | 2 | 100 | 200 | 25 | - | 2 | 0 | 100 | 15 | - Then carrier "newCarrier1" should have the following ranges for all shops: + | zone1 | 0 | 100 | 10 | + | zone1 | 300 | 400 | 40 | + | zone1 | 100 | 200 | 20 | + | zone1 | 200 | 300 | 30 | + | zone2 | 100 | 200 | 25 | + | zone2 | 0 | 100 | 15 | + Then carrier "carrier1" should have the following ranges for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 20 | - | 1 | 200 | 300 | 30 | - | 1 | 300 | 400 | 40 | - | 2 | 0 | 100 | 15 | - | 2 | 100 | 200 | 25 | + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 20 | + | zone1 | 200 | 300 | 30 | + | zone1 | 300 | 400 | 40 | + | zone2 | 0 | 100 | 15 | + | zone2 | 100 | 200 | 25 | Scenario: Adding prices ranges in carrier with different ranges by zones When I create carrier "carrier1" with specified properties: | name | Carrier 1 | - | grade | 1 | - | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | - | active | true | - | max_width | 1454 | - | max_height | 1234 | - | max_depth | 1111 | - | max_weight | 3864 | - | group_access | visitor, guest | - | delay[en-US] | Shipping delay | - | shippingHandling | false | - | isFree | true | | shippingMethod | price | - | taxRuleGroup | US-AL Rate (4%) | - | rangeBehavior | disabled | - Then I set ranges for carrier "carrier1" called "newCarrier1" with specified properties for all shops: + Then I set ranges for carrier "carrier1" with specified properties for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 40 | - | 2 | 0 | 20 | 15 | - | 2 | 20 | 50 | 20 | - Then carrier "newCarrier1" should have the following ranges for all shops: + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 40 | + | zone2 | 0 | 20 | 15 | + | zone2 | 20 | 50 | 20 | + Then carrier "carrier1" should have the following ranges for all shops: | id_zone | range_from | range_to | range_price | - | 1 | 0 | 100 | 10 | - | 1 | 100 | 200 | 40 | - | 2 | 0 | 20 | 15 | - | 2 | 20 | 50 | 20 | + | zone1 | 0 | 100 | 10 | + | zone1 | 100 | 200 | 40 | + | zone2 | 0 | 20 | 15 | + | zone2 | 20 | 50 | 20 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_management.feature b/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_management.feature index 603ce7d91253a..d546ba175a35a 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_management.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_management.feature @@ -21,7 +21,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -38,7 +37,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 4 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -74,7 +73,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -90,21 +88,20 @@ Feature: Carrier management | rangeBehavior | disabled | When I update order "bo_order1" Tracking number to "TEST1234" and Carrier to "carrier1" Then order "bo_order1" has Tracking number "TEST1234" - When I edit carrier "carrier1" with specified properties I get a new carrier called "newCarrier1": + When I edit carrier "carrier1" with specified properties I get a new carrier referenced as "newCarrier1": | name | Carrier 1 new | Then carrier "carrier1" should have the following properties: - | name | Carrier 1 | - | ordersCount | 1 | + | name | Carrier 1 | + | ordersCount | 1 | Then carrier "newCarrier1" should have the following properties: - | name | Carrier 1 new | - | ordersCount | 0 | + | name | Carrier 1 new | + | ordersCount | 0 | Scenario: Partially editing carrier with name and without an order linked When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -123,7 +120,7 @@ Feature: Carrier management | name | Carrier 1 new | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 6 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -140,7 +137,7 @@ Feature: Carrier management | name | Carrier 1 new | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 6 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -159,7 +156,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -178,7 +174,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 2 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 7 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -197,7 +193,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -216,7 +211,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://prestashop-project.org/track.php?num=@ | - | position | 2 | + | position | 8 | | active | 1 | | max_width | 1454 | | max_height | 1234 | @@ -230,7 +225,7 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | - Scenario: Partially editing carrier with position + Scenario: Partially editing carrier with position (and forced position on creation) When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | @@ -248,6 +243,23 @@ Feature: Carrier management | isFree | true | | shippingMethod | weight | | rangeBehavior | disabled | + Then carrier "carrier1" should have the following properties: + | name | Carrier 1 | + | grade | 1 | + | trackingUrl | http://example.com/track.php?num=@ | + | position | 2 | + | active | true | + | max_width | 1454 | + | max_height | 1234 | + | max_depth | 1111 | + | max_weight | 3864 | + | group_access | visitor, guest | + | delay[en-US] | Shipping delay | + | delay[fr-FR] | Délai de livraison | + | shippingHandling | false | + | isFree | true | + | shippingMethod | weight | + | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: | position | 4 | Then carrier "carrier1" should have the following properties: @@ -273,7 +285,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -292,7 +303,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 9 | | active | false | | max_width | 1454 | | max_height | 1234 | @@ -311,7 +322,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -331,7 +341,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 10 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -350,7 +360,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -372,7 +381,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 11 | | active | true | | max_width | 3333 | | max_height | 4444 | @@ -391,7 +400,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -410,7 +418,7 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | + | position | 12 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -429,7 +437,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -443,17 +450,16 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | shippingHandling | true | + | shippingHandling | true | Then carrier "carrier1" should have the following properties: - | name | Carrier 1 | - | shippingHandling | true | + | name | Carrier 1 | + | shippingHandling | true | Scenario: Partially editing carrier with free shipping When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -467,17 +473,16 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | isFree | true | + | isFree | true | Then carrier "carrier1" should have the following properties: - | name | Carrier 1 | - | isFree | true | + | name | Carrier 1 | + | isFree | true | Scenario: Partially editing carrier with shipping method When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -493,15 +498,14 @@ Feature: Carrier management When I edit carrier "carrier1" with specified properties: | shippingMethod | price | Then carrier "carrier1" should have the following properties: - | name | Carrier 1 | - | shippingMethod | price | + | name | Carrier 1 | + | shippingMethod | price | Scenario: Partially editing carrier with invalid shipping method When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -515,7 +519,7 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | shippingMethod | invalid | + | shippingMethod | invalid | Then carrier edit should throw an error with error code "INVALID_SHIPPING_METHOD" # @debug @@ -549,7 +553,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -563,17 +566,16 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | rangeBehavior | highest_range | + | rangeBehavior | highest_range | Then carrier "carrier1" should have the following properties: - | name | Carrier 1 | - | rangeBehavior | highest_range | + | name | Carrier 1 | + | rangeBehavior | highest_range | Scenario: Partially editing carrier with invalid range behavior When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -587,7 +589,7 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | rangeBehavior | invalid | + | rangeBehavior | invalid | Then carrier edit should throw an error with error code "INVALID_RANGE_BEHAVIOR" Scenario: Partially editing carrier with additional fees and is free already true @@ -595,7 +597,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -609,17 +610,16 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | shippingHandling | true | + | shippingHandling | true | Then carrier "carrier1" should have the following properties: - | shippingHandling | true | - | isFree | false | + | shippingHandling | true | + | isFree | false | Scenario: Partially editing carrier with is free and additional fees already true When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -633,17 +633,16 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | isFree | true | + | isFree | true | Then carrier "carrier1" should have the following properties: - | shippingHandling | false | - | isFree | true | + | shippingHandling | false | + | isFree | true | Scenario: Partially editing carrier with is free and additional fees at true When I create carrier "carrier1" with specified properties: | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -657,8 +656,8 @@ Feature: Carrier management | shippingMethod | weight | | rangeBehavior | disabled | When I edit carrier "carrier1" with specified properties: - | isFree | true | - | shippingHandling | true | + | isFree | true | + | shippingHandling | true | Then carrier edit should throw an error with error code "INVALID_HAS_ADDITIONAL_HANDLING_FEE_WITH_FREE_SHIPPING" Scenario: Upload logo for carrier @@ -666,7 +665,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | @@ -687,7 +685,6 @@ Feature: Carrier management | name | Carrier 1 | | grade | 1 | | trackingUrl | http://example.com/track.php?num=@ | - | position | 2 | | active | true | | max_width | 1454 | | max_height | 1234 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_tax_rule_group_management.feature b/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_tax_rule_group_management.feature index 1e4de42e6cdca..b78c81219c5b6 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_tax_rule_group_management.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Carrier/carrier_tax_rule_group_management.feature @@ -29,8 +29,8 @@ Feature: Carrier Tax Rule Group management | isFree | false | | shippingMethod | weight | | rangeBehavior | disabled | - When I set tax rule for carrier "carrier1" with specified properties: - | taxRuleGroup | US-AZ Rate (6.6%) | + And I identify tax rules group named "US-AZ Rate (6.6%)" as "us-az-tax-rate" + When I set tax rule "us-az-tax-rate" for carrier "carrier1" Then carrier "carrier1" should have the following properties: | name | Carrier 1 | | taxRuleGroup | US-AZ Rate (6.6%) | @@ -52,6 +52,5 @@ Feature: Carrier Tax Rule Group management | isFree | false | | shippingMethod | weight | | rangeBehavior | disabled | - When I set tax rule for carrier "carrier1" with specified properties: - | taxRuleGroup | wrongTaxId | + When I set tax rule "wrong-tax-rules" for carrier "carrier1" Then I should get error that tax rules group does not exist diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_carrier_restriction.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_carrier_restriction.feature index 74dbbec83f4f8..b263c246fc334 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_carrier_restriction.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_carrier_restriction.feature @@ -11,21 +11,32 @@ Feature: Cart calculation with carrier specific cart rules And I have an empty default cart And shipping handling fees are set to 2.0 And shop configuration for "PS_CART_RULE_FEATURE_ACTIVE" is set to 1 - And there is a zone named "zone1" - And there is a zone named "zone2" + And I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | + And I add new zone "zone2" with following properties: + | name | zone2 | + | enabled | true | And there is a country named "country1" and iso code "FR" in zone "zone1" And there is a country named "country2" and iso code "US" in zone "zone2" And there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" And there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" And there is an address named "address1" with postcode "1" in state "state1" And there is an address named "address2" with postcode "1" in state "state2" - And there is a carrier named "carrier1" - And carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - And carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - And there is a carrier named "carrier2" - And carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - And carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 - And there is a carrier named "carrier3" + And I create carrier "carrier1" with specified properties: + | name | Carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 3.1 | + | zone2 | 0 | 10000 | 4.3 | + And I create carrier "carrier2" with specified properties: + | name | Carrier 2 | + Then I set ranges for carrier "carrier2" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.7 | + | zone2 | 0 | 10000 | 6.2 | + And I create carrier "carrier3" with specified properties: + | name | Carrier 3 | And there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock And there is a product in the catalog named "product2" with a price of 32.388 and 1000 items in stock And there is a product in the catalog named "product3" with a price of 31.188 and 1000 items in stock @@ -139,8 +150,10 @@ Feature: Cart calculation with carrier specific cart rules And my cart total should be 17.5 tax included Scenario: one product in cart, quantity 1, can apply corresponding cart rule - Given carrier "carrier3" applies shipping fees of 6.7 in zone "zone1" for price between 0 and 10000 - And carrier "carrier3" applies shipping fees of 7.2 in zone "zone2" for price between 0 and 10000 + Given I set ranges for carrier "carrier3" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 6.7 | + | zone2 | 0 | 10000 | 7.2 | And there is a cart rule "cartrule3" with following properties: | name[en-US] | cartrule3 | | total_quantity | 1000 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_country_restriction.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_country_restriction.feature index 02f2306ccd379..c7e1b5232136b 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_country_restriction.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/Restrictions/cart_rule_country_restriction.feature @@ -1,5 +1,4 @@ # ./vendor/bin/behat -c tests/Integration/Behaviour/behat.yml -s cart --tags fo-cart-rule-country-restriction - @restore-all-tables-before-feature @fo-cart-rule-country-restriction Feature: Cart calculation with country specific cart rules @@ -11,17 +10,24 @@ Feature: Cart calculation with country specific cart rules And I have an empty default cart And shipping handling fees are set to 2.0 And shop configuration for "PS_CART_RULE_FEATURE_ACTIVE" is set to 1 - And there is a zone named "Europe" - And there is a zone named "North America" - And there is a country named "France" and iso code "FR" in zone "Europe" - And there is a country named "United States of America" and iso code "US" in zone "North America" - And there is a state named "state-fr" with iso code "TEST-FR" in country "France" and zone "Europe" - And there is a state named "state-us" with iso code "TEST-US" in country "United States of America" and zone "North America" + And I add new zone "zone1" with following properties: + | name | Europe | + | enabled | true | + And I add new zone "zone2" with following properties: + | name | North America | + | enabled | true | + And there is a country named "France" and iso code "FR" in zone "zone1" + And there is a country named "United States of America" and iso code "US" in zone "zone2" + And there is a state named "state-fr" with iso code "TEST-FR" in country "France" and zone "zone1" + And there is a state named "state-us" with iso code "TEST-US" in country "United States of America" and zone "zone2" And there is an address named "address-fr" with postcode "1" in state "state-fr" And there is an address named "address-us" with postcode "1" in state "state-us" - And there is a carrier named "carrier1" - And carrier "carrier1" applies shipping fees of 12.3 in zone "Europe" for price between 0 and 10000 - And carrier "carrier1" applies shipping fees of 45.6 in zone "North America" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | Carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 12.3 | + | zone2 | 0 | 10000 | 45.6 | And there is a cart rule "cartrule1" with following properties: | name[en-US] | cartrule1 | | priority | 1 | @@ -30,10 +36,10 @@ Feature: Cart calculation with country specific cart rules | discount_currency | usd | | discount_includes_tax | false | And I restrict following countries for cart rule cartrule1: - | restricted countries | France | + | restricted countries | France | And I save all the restrictions for cart rule cartrule1 And cart rule cartrule1 should have the following properties: - | restricted countries | France | + | restricted countries | France | And there is a product in the catalog named "Product1" with a price of 90.12 and 100 items in stock Scenario: Cart with a Product And address restricted by cart rule diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/carrier.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/carrier.feature index 0e15f99aa9569..92590a4583177 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/carrier.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/carrier.feature @@ -11,27 +11,42 @@ Feature: Cart calculation with cart rules and different carriers And there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock And there is a product in the catalog named "product4" with a price of 149.0 and 1000 items in stock And there is a product in the catalog named "product5" with a price of 151.0 and 1000 items in stock - And there is a carrier named "carrier1" - And there is a zone named "zone1" - And there is a zone named "zone2" + And I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | + And I add new zone "zone2" with following properties: + | name | zone2 | + | enabled | true | And there is a country named "country1" and iso code "FR" in zone "zone1" And there is a country named "country2" and iso code "US" in zone "zone2" And there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" And there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" And there is an address named "address1" with postcode "1" in state "state1" And there is an address named "address2" with postcode "2" in state "state2" - And there is a carrier named "carrier1" - And there is a carrier named "carrier2" - And there is a carrier named "carrier3" - And there is a carrier named "carrier4" - And carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - And carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - And carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - And carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 - And carrier "carrier3" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - And carrier "carrier3" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 - And carrier "carrier4" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 150 - And carrier "carrier4" applies shipping fees of 0.0 in zone "zone1" for price between 150 and 1000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + And I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 1000 | 3.1 | + | zone2 | 0 | 1000 | 4.3 | + And I create carrier "carrier2" with specified properties: + | name | carrier 2 | + And I set ranges for carrier "carrier2" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 1000 | 5.7 | + | zone2 | 0 | 1000 | 6.2 | + And I create carrier "carrier3" with specified properties: + | name | carrier 3 | + And I set ranges for carrier "carrier3" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 1000 | 5.7 | + | zone2 | 0 | 1000 | 6.2 | + And I create carrier "carrier4" with specified properties: + | name | carrier 4 | + And I set ranges for carrier "carrier4" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 150 | 5.0 | + | zone1 | 150 | 1000 | 0.0 | And shipping handling fees are set to 2.0 And there is a cart rule "cartrule5" with following properties: | name[en-US] | cartrule5 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/cart_rule_validation.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/cart_rule_validation.feature index d3d853dc39550..a7ae20d451e08 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/cart_rule_validation.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/cart_rule_validation.feature @@ -63,11 +63,11 @@ Feature: Cart rule application is validated before it is applied to cart Given I have an empty default cart And there is a cart rule "cart_rule_4" with following properties: | name[en-US] | cart_rule_4 | - | free_shipping | false | | free_shipping | true | | code | rule_carrier1 | | discount_percentage | 50 | - And there is a carrier named "carrier1" + And I create carrier "carrier1" with specified properties: + | name | Carrier 1 | And I restrict following carriers for cart rule cart_rule_4: | restricted carriers | carrier1 | And I save all the restrictions for cart rule cart_rule_4 diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/ecotax.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/ecotax.feature index 864d1c7829ac7..df08aa4e36656 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/ecotax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/CartRule/FrontOffice/ecotax.feature @@ -8,7 +8,9 @@ Feature: Cart rule (percent) calculation with one cart rule Background: Given I have an empty default cart - And there is a zone named "zone1" + And I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | And there is a country named "country1" and iso code "FR" in zone "zone1" And there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" And there is an address named "address1" with postcode "1" in state "state1" diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/carrier.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/carrier.feature index 2c9da04865850..897a41720228b 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/carrier.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/carrier.feature @@ -1,24 +1,38 @@ +# ./vendor/bin/behat -c tests/Integration/Behaviour/behat.yml -s cart --tags fo-cart-carrier @restore-all-tables-before-feature +@fo-cart-carrier Feature: Cart calculation with carriers As a customer I must be able to have correct cart total when selecting carriers - Scenario: Empty cart, carrier 1 - Given I have an empty default cart - Given there is a zone named "zone1" - Given there is a zone named "zone2" + Background: + Given I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | + Given I add new zone "zone2" with following properties: + | name | zone2 | + | enabled | true | + Given I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Given I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 3.1 | + | zone2 | 0 | 10000 | 4.3 | + Given I create carrier "carrier2" with specified properties: + | name | carrier 2 | + Given I set ranges for carrier "carrier2" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.7 | + | zone2 | 0 | 10000 | 6.2 | Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a country named "country2" and iso code "US" in zone "zone2" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" Given there is an address named "address1" with postcode "1" in state "state1" Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 + + Scenario: Empty cart, carrier 1 + Given I have an empty default cart When I select address "address1" in my cart When I select carrier "carrier1" in my cart Then cart shipping fees should be 0.0 @@ -28,20 +42,6 @@ Feature: Cart calculation with carriers Scenario: one product in cart, quantity 1, carrier 1 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I add 1 items of product "product1" in my cart When I select address "address1" in my cart When I select carrier "carrier1" in my cart @@ -52,20 +52,6 @@ Feature: Cart calculation with carriers Scenario: one product in cart, quantity 3, carrier 1 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I add 3 items of product "product1" in my cart When I select address "address1" in my cart When I select carrier "carrier1" in my cart @@ -78,20 +64,6 @@ Feature: Cart calculation with carriers Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock Given there is a product in the catalog named "product2" with a price of 32.388 and 1000 items in stock Given there is a product in the catalog named "product3" with a price of 31.188 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I add 2 items of product "product2" in my cart When I add 3 items of product "product1" in my cart When I add 1 items of product "product3" in my cart @@ -104,20 +76,6 @@ Feature: Cart calculation with carriers Scenario: Empty cart, carrier 2 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I select address "address1" in my cart When I select carrier "carrier2" in my cart Then cart shipping fees should be 0.0 @@ -127,20 +85,6 @@ Feature: Cart calculation with carriers Scenario: one product in cart, quantity 1, carrier 2 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I add 1 items of product "product1" in my cart When I select address "address1" in my cart When I select carrier "carrier2" in my cart @@ -151,20 +95,6 @@ Feature: Cart calculation with carriers Scenario: one product in cart, quantity 3, carrier 2 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I add 3 items of product "product1" in my cart When I select address "address1" in my cart When I select carrier "carrier2" in my cart @@ -177,20 +107,6 @@ Feature: Cart calculation with carriers Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock Given there is a product in the catalog named "product2" with a price of 32.388 and 1000 items in stock Given there is a product in the catalog named "product3" with a price of 31.188 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a zone named "zone2" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a country named "country2" and iso code "US" in zone "zone2" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is a state named "state2" with iso code "TEST-2" in country "country2" and zone "zone2" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is an address named "address2" with postcode "1" in state "state2" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 3.1 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier1" applies shipping fees of 4.3 in zone "zone2" for price between 0 and 10000 - Given there is a carrier named "carrier2" - Given carrier "carrier2" applies shipping fees of 5.7 in zone "zone1" for price between 0 and 10000 - Given carrier "carrier2" applies shipping fees of 6.2 in zone "zone2" for price between 0 and 10000 When I add 2 items of product "product2" in my cart When I add 3 items of product "product1" in my cart When I add 1 items of product "product3" in my cart @@ -203,16 +119,15 @@ Feature: Cart calculation with carriers Scenario: free carrier in price range Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 151.0 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 150 - Given carrier "carrier1" applies shipping fees of 0.0 in zone "zone1" for price between 150 and 1000 + Given I create carrier "carrier3" with specified properties: + | name | carrier 3 | + Given I set ranges for carrier "carrier3" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 150 | 5.0 | + | zone1 | 150 | 1000 | 0.0 | When I add 1 item of product "product1" in my cart When I select address "address1" in my cart - When I select carrier "carrier1" in my cart + When I select carrier "carrier3" in my cart Then cart shipping fees should be 2.0 Then my cart total should be 153.0 tax included Then my cart total using previous calculation method should be 153.0 tax included diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/cart_to_order.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/cart_to_order.feature index 0c024d04f731f..c9fc8c522a4d2 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/cart_to_order.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/cart_to_order.feature @@ -17,12 +17,14 @@ Feature: Check cart to order data copy | free_shipping | false | | code | foo1 | | discount_percentage | 50 | + And I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | Scenario: 1 product in cart, 1 cart rule Given I have an empty default cart Given email sending is disabled Given shipping handling fees are set to 2.0 - Given there is a zone named "zone1" Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -31,9 +33,11 @@ Feature: Check cart to order data copy Given product "product1" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product1" in my cart When I use the discount "cartrule1" @@ -60,7 +64,6 @@ Feature: Check cart to order data copy | free_shipping | false | | code | foo2 | | discount_percentage | 50 | - Given there is a zone named "zone1" Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -69,9 +72,11 @@ Feature: Check cart to order data copy Given product "product1" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product1" in my cart When I use the discount "cartrule1" @@ -93,7 +98,6 @@ Feature: Check cart to order data copy Given I have an empty default cart Given email sending is disabled Given shipping handling fees are set to 2.0 - Given there is a zone named "zone1" Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -104,9 +108,11 @@ Feature: Check cart to order data copy Given product "product3" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product2" in my cart When I add 1 items of product "product1" in my cart @@ -134,7 +140,6 @@ Feature: Check cart to order data copy | free_shipping | false | | code | foo2 | | discount_percentage | 50 | - Given there is a zone named "zone1" Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -145,9 +150,11 @@ Feature: Check cart to order data copy Given product "product3" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product2" in my cart When I add 1 items of product "product1" in my cart @@ -178,7 +185,6 @@ Feature: Check cart to order data copy | discount_currency | usd | | discount_includes_tax | false | | code | foo5 | - Given there is a zone named "zone1" Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -187,9 +193,11 @@ Feature: Check cart to order data copy Given product "product1" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product1" in my cart When I use the discount "cartrule5" @@ -212,12 +220,11 @@ Feature: Check cart to order data copy Given email sending is disabled Given shipping handling fees are set to 2.0 Given there is a cart rule cartrule13 with following properties: - | name[en-US] | cartrule13 | - | priority | 13 | - | free_shipping | false | - | gift_product | product4 | - | code | foo13 | - Given there is a zone named "zone1" + | name[en-US] | cartrule13 | + | priority | 13 | + | free_shipping | false | + | gift_product | product4 | + | code | foo13 | Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -227,9 +234,11 @@ Feature: Check cart to order data copy Given product "product4" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product1" in my cart When I use the discount "cartrule13" @@ -250,12 +259,11 @@ Feature: Check cart to order data copy Given email sending is disabled Given shipping handling fees are set to 2.0 Given there is a cart rule cartrule13 with following properties: - | name[en-US] | cartrule13 | - | priority | 13 | - | free_shipping | false | - | gift_product | product4 | - | code | foo13 | - Given there is a zone named "zone1" + | name[en-US] | cartrule13 | + | priority | 13 | + | free_shipping | false | + | gift_product | product4 | + | code | foo13 | Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -265,9 +273,11 @@ Feature: Check cart to order data copy Given product "product4" belongs to tax group "taxrule1" Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + And I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | When I am logged in as "customer1" When I add 1 items of product "product1" in my cart When I add 1 items of product "product4" in my cart diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/delivery_options.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/delivery_options.feature index b3ea8f0d595da..71070515d2f60 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/delivery_options.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/delivery_options.feature @@ -1,5 +1,4 @@ # ./vendor/bin/behat -c tests/Integration/Behaviour/behat.yml -s cart --tags delivery-options - @restore-all-tables-before-feature @delivery-options @clear-cache-after-feature @@ -28,7 +27,9 @@ Feature: Compute correct delivery options | free_shipping | true | | discount_percentage | 50 | # Standard location settings - Given there is a zone named "zone1" + And I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | Given there is a country named "country1" and iso code "FR" in zone "zone1" Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" Given there is an address named "address1" with postcode "1" in state "state1" @@ -38,9 +39,11 @@ Feature: Compute correct delivery options Given there is a customer named "customer1" whose email is "fake@prestashop.com" Given address "address1" is associated to customer "customer1" # One standard carrier - Given there is a carrier named "carrier1" - Given carrier "carrier1" ships to all groups - Given carrier "carrier1" applies shipping fees of 5.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | Carrier 1 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 5.0 | # Checkout begins When I am logged in as "customer1" When I add 1 items of product "product1" in my cart diff --git a/tests/Integration/Behaviour/Features/Scenario/Cart/tax.feature b/tests/Integration/Behaviour/Features/Scenario/Cart/tax.feature index 701e1241553dd..154de70d31857 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Cart/tax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Cart/tax.feature @@ -1,14 +1,20 @@ +# ./vendor/bin/behat -c tests/Integration/Behaviour/behat.yml -s cart --tags fo-cart-tax @restore-all-tables-before-feature +@fo-cart-tax Feature: Cart calculation with tax As a customer I must be able to have correct cart total when using taxes + Background: + Given I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | + And there is a country named "country1" and iso code "FR" in zone "zone1" + And there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" + And there is an address named "address1" with postcode "1" in state "state1" + Scenario: empty cart Given I have an empty default cart - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" When I select address "address1" in my cart Then my cart total should be 0.0 tax included Then my cart total using previous calculation method should be 0.0 tax included @@ -23,10 +29,6 @@ Feature: Cart calculation with tax Scenario: tax #1: one product in cart, quantity 1 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" Given there is a tax named "tax1" and rate 4.0% Given there is a tax rule named "taxrule1" in country "country1" and state "state1" where tax "tax1" is applied Given product "product1" belongs to tax group "taxrule1" @@ -45,10 +47,6 @@ Feature: Cart calculation with tax Scenario: tax #2: one product in cart, quantity 1 Given I have an empty default cart Given there is a product in the catalog named "product5" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" Given there is a tax named "tax1" and rate 6.0% Given there is a tax rule named "taxrule1" in country "country1" and state "state1" where tax "tax1" is applied Given product "product5" belongs to tax group "taxrule1" @@ -67,10 +65,6 @@ Feature: Cart calculation with tax Scenario: tax #3: one product in cart, quantity 1 Given I have an empty default cart Given there is a product in the catalog named "product5" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" Given there is a tax named "tax1" and rate 0.0% Given there is a tax rule named "taxrule1" in country "country1" and state "state1" where tax "tax1" is applied Given product "product5" belongs to tax group "taxrule1" @@ -89,10 +83,6 @@ Feature: Cart calculation with tax Scenario: tax #1: one product in cart, quantity 3 Given I have an empty default cart Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" Given there is a tax named "tax1" and rate 4.0% Given there is a tax rule named "taxrule1" in country "country1" and state "state1" where tax "tax1" is applied Given product "product1" belongs to tax group "taxrule1" @@ -113,10 +103,6 @@ Feature: Cart calculation with tax Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock Given there is a product in the catalog named "product2" with a price of 32.388 and 1000 items in stock Given there is a product in the catalog named "product3" with a price of 31.188 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" Given there is a tax named "tax1" and rate 4.0% Given there is a tax rule named "taxrule1" in country "country1" and state "state1" where tax "tax1" is applied Given product "product1" belongs to tax group "taxrule1" @@ -145,10 +131,6 @@ Feature: Cart calculation with tax Given there is a product in the catalog named "product1" with a price of 19.812 and 1000 items in stock Given there is a product in the catalog named "product2" with a price of 32.388 and 1000 items in stock Given there is a product in the catalog named "product3" with a price of 31.188 and 1000 items in stock - Given there is a zone named "zone1" - Given there is a country named "country1" and iso code "FR" in zone "zone1" - Given there is a state named "state1" with iso code "TEST-1" in country "country1" and zone "zone1" - Given there is an address named "address1" with postcode "1" in state "state1" Given there is a tax named "tax1" and rate 4.0% Given there is a tax rule named "taxrule1" in country "country1" and state "state1" where tax "tax1" is applied Given product "product1" belongs to tax group "taxrule1" diff --git a/tests/Integration/Behaviour/Features/Scenario/CartRule/set_carrier_restrictions.feature b/tests/Integration/Behaviour/Features/Scenario/CartRule/set_carrier_restrictions.feature index b4dd31e97e1c4..5bb7588e7a88e 100644 --- a/tests/Integration/Behaviour/Features/Scenario/CartRule/set_carrier_restrictions.feature +++ b/tests/Integration/Behaviour/Features/Scenario/CartRule/set_carrier_restrictions.feature @@ -12,8 +12,10 @@ Feature: Set cart rule carrier restrictions in BO And currency "usd" is the default one And language "language1" with locale "en-US" exists And language with iso code "en" is the default one - And there is a carrier named "carrier1" - And there is a carrier named "carrier2" + And I create carrier "carrier1" with specified properties: + | name | Carrier 1 | + And I create carrier "carrier2" with specified properties: + | name | Carrier 2 | And I add product "product1" with following information: | name[en-US] | bottle of beer | | type | virtual | diff --git a/tests/Integration/Behaviour/Features/Scenario/CartRule/set_mixed_cart_rule_restrictions.feature b/tests/Integration/Behaviour/Features/Scenario/CartRule/set_mixed_cart_rule_restrictions.feature index 9e305d64b47f0..2ee9e082b1524 100644 --- a/tests/Integration/Behaviour/Features/Scenario/CartRule/set_mixed_cart_rule_restrictions.feature +++ b/tests/Integration/Behaviour/Features/Scenario/CartRule/set_mixed_cart_rule_restrictions.feature @@ -26,8 +26,10 @@ Feature: Set cart rule restrictions in BO And manufacturer graphicCorner named "Graphic Corner" exists And supplier fashionSupplier named "Fashion supplier" exists And supplier accessoriesSupplier named "Accessories supplier" exists - And there is a carrier named "carrier1" - And there is a carrier named "carrier2" + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + And I create carrier "carrier2" with specified properties: + | name | carrier 2 | And I add new country "France" with following properties: | name[en-US] | France | | iso_code | FR | diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_address.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_address.feature index d6a86baba7cf0..69084e666d0c5 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_address.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_address.feature @@ -22,14 +22,14 @@ Feature: Order from Back Office (BO) Scenario: Check address when DNI is not defined Given I add new address to customer "testCustomer" with following details: - | Address alias | test-customer-france-address | - | First name | testFirstName | - | Last name | testLastName | - | Address | 36 Avenue des Champs Elysees | - | City | Paris | - | Country | France | - | Postal code | 75008 | - | DNI | 12345 | + | Address alias | test-customer-france-address | + | First name | testFirstName | + | Last name | testLastName | + | Address | 36 Avenue des Champs Elysees | + | City | Paris | + | Country | France | + | Postal code | 75008 | + | DNI | 12345 | And I add order "bo_order1" with the following details: | cart | dummy_cart | | message | test | @@ -38,26 +38,26 @@ Feature: Order from Back Office (BO) And I change order "bo_order1" shipping address to "test-customer-france-address" And I change order "bo_order1" invoice address to "test-customer-france-address" Then the preview order "bo_order1" has following shipping address - | Fullname | testFirstName testLastName | - | Address | 36 Avenue des Champs Elysees | - | City | Paris | - | Country | France | - | Postal code | 75008 | - | DNI | | + | Fullname | testFirstName testLastName | + | Address | 36 Avenue des Champs Elysees | + | City | Paris | + | Country | France | + | Postal code | 75008 | + | DNI | | And the preview order "bo_order1" has following invoice address - | Fullname | testFirstName testLastName | - | Address | 36 Avenue des Champs Elysees | - | City | Paris | - | Country | France | - | Postal code | 75008 | - | DNI | | + | Fullname | testFirstName testLastName | + | Address | 36 Avenue des Champs Elysees | + | City | Paris | + | Country | France | + | Postal code | 75008 | + | DNI | | And the order "bo_order1" has following shipping address - | Fullname | testFirstName testLastName | - | Address | 36 Avenue des Champs Elysees | - | City | Paris | - | Country | France | - | Postal code | 75008 | - | DNI | | + | Fullname | testFirstName testLastName | + | Address | 36 Avenue des Champs Elysees | + | City | Paris | + | Country | France | + | Postal code | 75008 | + | DNI | | And the order "bo_order1" has the following formatted shipping address """ testFirstName testLastName @@ -73,12 +73,12 @@ Feature: Order from Back Office (BO) France """ And the order "bo_order1" has following invoice address - | Fullname | testFirstName testLastName | - | Address | 36 Avenue des Champs Elysees | - | City | Paris | - | Country | France | - | Postal code | 75008 | - | DNI | | + | Fullname | testFirstName testLastName | + | Address | 36 Avenue des Champs Elysees | + | City | Paris | + | Country | France | + | Postal code | 75008 | + | DNI | | And the order "bo_order1" has the following formatted invoice address """ testFirstName testLastName @@ -96,14 +96,14 @@ Feature: Order from Back Office (BO) Scenario: Check address when DNI not defined Given I add new address to customer "testCustomer" with following details: - | Address alias | test-customer-spain-address | - | First name | testFirstName | - | Last name | testLastName | - | Address | Calle de Bailén | - | City | Madrid | - | Country | Spain | - | Postal code | 28071 | - | DNI | 12345 | + | Address alias | test-customer-spain-address | + | First name | testFirstName | + | Last name | testLastName | + | Address | Calle de Bailén | + | City | Madrid | + | Country | Spain | + | Postal code | 28071 | + | DNI | 12345 | And I add order "bo_order1" with the following details: | cart | dummy_cart | | message | test | @@ -112,26 +112,26 @@ Feature: Order from Back Office (BO) And I change order "bo_order1" shipping address to "test-customer-spain-address" And I change order "bo_order1" invoice address to "test-customer-spain-address" Then the preview order "bo_order1" has following shipping address - | Fullname | testFirstName testLastName | - | Address | Calle de Bailén | - | City | Madrid | - | Country | Spain | - | Postal code | 28071 | - | DNI | 12345 | + | Fullname | testFirstName testLastName | + | Address | Calle de Bailén | + | City | Madrid | + | Country | Spain | + | Postal code | 28071 | + | DNI | 12345 | And the preview order "bo_order1" has following invoice address - | Fullname | testFirstName testLastName | - | Address | Calle de Bailén | - | City | Madrid | - | Country | Spain | - | Postal code | 28071 | - | DNI | 12345 | + | Fullname | testFirstName testLastName | + | Address | Calle de Bailén | + | City | Madrid | + | Country | Spain | + | Postal code | 28071 | + | DNI | 12345 | And the order "bo_order1" has following shipping address - | Fullname | testFirstName testLastName | - | Address | Calle de Bailén | - | City | Madrid | - | Country | Spain | - | Postal code | 28071 | - | DNI | 12345 | + | Fullname | testFirstName testLastName | + | Address | Calle de Bailén | + | City | Madrid | + | Country | Spain | + | Postal code | 28071 | + | DNI | 12345 | And the order "bo_order1" has the following formatted shipping address """ testFirstName testLastName @@ -141,12 +141,12 @@ Feature: Order from Back Office (BO) 12345 """ And the order "bo_order1" has following invoice address - | Fullname | testFirstName testLastName | - | Address | Calle de Bailén | - | City | Madrid | - | Country | Spain | - | Postal code | 28071 | - | DNI | 12345 | + | Fullname | testFirstName testLastName | + | Address | Calle de Bailén | + | City | Madrid | + | Country | Spain | + | Postal code | 28071 | + | DNI | 12345 | And the order "bo_order1" has the following formatted invoice address """ testFirstName testLastName @@ -157,8 +157,9 @@ Feature: Order from Back Office (BO) """ Scenario: Check shipping details after updating carrier tracking number & url - Given there is a carrier named "tracking-carrier" - And I enable carrier "tracking-carrier" + And I create carrier "tracking-carrier" with specified properties: + | name | tracking-carrier | + | trackingUrl | | And I add order "bo_order1" with the following details: | cart | dummy_cart | | message | test | @@ -167,15 +168,16 @@ Feature: Order from Back Office (BO) And I update order "bo_order1" Tracking number to "" and Carrier to "tracking-carrier" Then order "bo_order1" should have "tracking-carrier" as a carrier And the preview order "bo_order1" has following shipping details - | Tracking number | | - | Tracking URL | | + | Tracking number | | + | Tracking URL | | Given I update order "bo_order1" Tracking number to "42424242" and Carrier to "tracking-carrier" - And the carrier "tracking-carrier" uses "http://tracking.url" as tracking url + When I edit carrier "tracking-carrier" with specified properties I get a new carrier referenced as "new-tracking-carrier": + | trackingUrl | http://tracking.url/@ | Then order "bo_order1" should have "tracking-carrier" as a carrier And the preview order "bo_order1" has following shipping details - | Tracking number | 42424242 | - | Tracking URL | http://tracking.url | - Given the carrier "tracking-carrier" uses "http://tracking.url/@" as tracking url + | Tracking number | 42424242 | + | Tracking URL | | + Given I update order "bo_order1" Tracking number to "42424242" and Carrier to "new-tracking-carrier" Then the preview order "bo_order1" has following shipping details - | Tracking number | 42424242 | - | Tracking URL | http://tracking.url/42424242 | + | Tracking number | 42424242 | + | Tracking URL | http://tracking.url/42424242 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_cart_rules.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_cart_rules.feature index 3faef0ac1802f..8998319d5ea2c 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_cart_rules.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_cart_rules.feature @@ -718,12 +718,20 @@ Feature: Order from Back Office (BO) Scenario: When a cart rule is associated to a carrier, when I change the carrier the cart rule should be added/removed accordingly Given there is a product in the catalog named "product1" with a price of 10.00 and 100 items in stock And there is a product in the catalog named "product2" with a price of 15.00 and 100 items in stock - And there is a zone named "zone1" + And I add new zone "zone1" with following properties: + | name | zone1 | + | enabled | true | And there is a country named "country1" and iso code "FR" in zone "zone1" - And there is a carrier named "carrier1" - And there is a carrier named "carrier2" - And carrier "carrier1" applies shipping fees of 0.0 in zone "zone1" for price between 0 and 10000 - And carrier "carrier2" applies shipping fees of 0.0 in zone "zone1" for price between 0 and 10000 + And I create carrier "carrier1" with specified properties: + | name | carrier 1 | + And I create carrier "carrier2" with specified properties: + | name | carrier 2 | + Then I set ranges for carrier "carrier1" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 0.0 | + Then I set ranges for carrier "carrier2" with specified properties for all shops: + | id_zone | range_from | range_to | range_price | + | zone1 | 0 | 10000 | 0.0 | And there is a cart rule FreeGift with following properties: | name[en-US] | FreeGift | | gift_product | product1 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_currency.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_currency.feature index c417190e10908..df9abb165c947 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_currency.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_currency.feature @@ -370,7 +370,8 @@ Feature: Multiple currencies for Order in Back Office (BO) Scenario: Carrier change for an order with secondary currency Given a carrier "default_carrier" with name "My carrier" exists And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties: + | active | true | And order "bo_order1" should have "default_carrier" as a carrier And order "bo_order1" carrier should have following details: | weight | 0.600 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax.feature index ee5abaabaf453..fb037a87128e4 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax.feature @@ -35,7 +35,7 @@ Feature: Ecotax for Order in Back Office (BO) And customer "testCustomer" has address in "FR" country ## Carrier And a carrier "default_carrier" with name "My carrier" exists - And I associate the tax rule group "fr-tax-6-group" to carrier "default_carrier" + And I set tax rule "fr-tax-6-group" for carrier "default_carrier" I get a new carrier referenced as "default_carrier" ## Cart for Customer And I create an empty cart "dummy_cart" for customer "testCustomer" And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_cartrule.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_cartrule.feature index b93e59929bf8c..1b03bf52c3650 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_cartrule.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_cartrule.feature @@ -35,7 +35,7 @@ Feature: Ecotax for Order in Back Office (BO) And customer "testCustomer" has address in "FR" country ## Carrier And a carrier "default_carrier" with name "My carrier" exists - And I associate the tax rule group "fr-tax-6-group" to carrier "default_carrier" + And I set tax rule "fr-tax-6-group" for carrier "default_carrier" I get a new carrier referenced as "default_carrier" ## Cart for Customer And I create an empty cart "dummy_cart" for customer "testCustomer" And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_combination.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_combination.feature index 25aa06445b16f..c356ae9698156 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_combination.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_combination.feature @@ -41,7 +41,7 @@ Feature: Ecotax for Order in Back Office (BO) And customer "testCustomer" has address in "FR" country ## Carrier And a carrier "default_carrier" with name "My carrier" exists - And I associate the tax rule group "fr-tax-6-group" to carrier "default_carrier" + And I set tax rule "fr-tax-6-group" for carrier "default_carrier" I get a new carrier referenced as "default_carrier" ## Cart for Customer And I create an empty cart "dummy_cart" for customer "testCustomer" And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_odd_tax.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_odd_tax.feature index 4e5c2da4c70e8..49fc98e6d46c6 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_odd_tax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_odd_tax.feature @@ -35,7 +35,7 @@ Feature: Ecotax for Order in Back Office (BO) And customer "testCustomer" has address in "FR" country ## Carrier And a carrier "default_carrier" with name "My carrier" exists - And I associate the tax rule group "fr-tax-21-group" to carrier "default_carrier" + And I set tax rule "fr-tax-21-group" for carrier "default_carrier" I get a new carrier referenced as "default_carrier" ## Cart for Customer And I create an empty cart "dummy_cart" for customer "testCustomer" And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_with_tax.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_with_tax.feature index cd852aa55c692..645c81091579e 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_with_tax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_ecotax_with_tax.feature @@ -43,7 +43,7 @@ Feature: Ecotax for Order in Back Office (BO) And customer "testCustomer" has address in "FR" country ## Carrier And a carrier "default_carrier" with name "My carrier" exists - And I associate the tax rule group "fr-tax-6-group" to carrier "default_carrier" + And I set tax rule "fr-tax-6-group" for carrier "default_carrier" I get a new carrier referenced as "default_carrier" ## Cart for Customer And I create an empty cart "dummy_cart" for customer "testCustomer" And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_fixed_product_prices.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_fixed_product_prices.feature index 27a9e626daf06..b6fe2ef3d18d0 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_fixed_product_prices.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_fixed_product_prices.feature @@ -17,7 +17,8 @@ Feature: Order from Back Office (BO) And customer "testCustomer" has address in "US" country And a carrier "default_carrier" with name "My carrier" exists And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties: + | active | true | And shop configuration for "PS_CART_RULE_FEATURE_ACTIVE" is set to 1 And there is a product in the catalog named "Test Changing Product" with a price of 10.0 and 100 items in stock And the available stock for product "Test Changing Product" should be 100 diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_french_tax.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_french_tax.feature index 7af7a09177441..469d24906b56d 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_french_tax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_french_tax.feature @@ -27,8 +27,9 @@ Feature: Order from Back Office (BO) And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" And I add 2 products "Mug The best is yet to come" to the cart "dummy_cart" And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" - And I associate the tax rule group "french-tax-group" to carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties: + | active | true | + And I set tax rule "french-tax-group" for carrier "price_carrier" And I select carrier "price_carrier" for cart "dummy_cart" And cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_odd_tax.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_odd_tax.feature index abec6f607a83c..b8a27d07e4116 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_odd_tax.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_odd_tax.feature @@ -28,8 +28,9 @@ Feature: Order from Back Office (BO) And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" And I add 70 products "Test Product With Odd Tax" to the cart "dummy_cart" And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" - And I associate the tax rule group "odd-tax-group" to carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties and update its reference: + | active | true | + And I set tax rule "odd-tax-group" for carrier "price_carrier" And I select carrier "price_carrier" for cart "dummy_cart" And cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_rounding_type.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_rounding_type.feature index 18e352022ff34..a77ea85caaf5e 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_rounding_type.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_rounding_type.feature @@ -2,7 +2,6 @@ @restore-all-tables-before-feature @clear-cache-before-feature @order-rounding-type - Feature: In BO, get right display prices for products and totals, depending on the order's rounding type As a BO user, I need to see the right prices depending on rounding type with odd tax @@ -31,8 +30,9 @@ Feature: In BO, get right display prices for products and totals, depending on t And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" And I add 80 products "Test Product With Odd Tax" to the cart "dummy_cart" And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" - And I associate the tax rule group "odd-tax-group" to carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties: + | active | true | + And I set tax rule "odd-tax-group" for carrier "price_carrier" And I select carrier "price_carrier" for cart "dummy_cart" And cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -60,8 +60,9 @@ Feature: In BO, get right display prices for products and totals, depending on t And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" And I add 80 products "Test Product With Odd Tax" to the cart "dummy_cart" And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" - And I associate the tax rule group "odd-tax-group" to carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties I get a new carrier referenced as "price_carrier": + | active | true | + And I set tax rule "odd-tax-group" for carrier "price_carrier" And I select carrier "price_carrier" for cart "dummy_cart" And cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -89,8 +90,9 @@ Feature: In BO, get right display prices for products and totals, depending on t And I select "FR" address as delivery and invoice address for customer "testCustomer" in cart "dummy_cart" And I add 80 products "Test Product With Odd Tax" to the cart "dummy_cart" And a carrier "price_carrier" with name "My cheap carrier" exists - And I enable carrier "price_carrier" - And I associate the tax rule group "odd-tax-group" to carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties I get a new carrier referenced as "price_carrier": + | active | true | + And I set tax rule "odd-tax-group" for carrier "price_carrier" And I select carrier "price_carrier" for cart "dummy_cart" And cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping.feature index 5882f85d1bb42..1a65ecde7c42f 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping.feature @@ -26,7 +26,8 @@ Feature: Order from Back Office (BO) Scenario: Use a carrier that depends on price, add product to change order total the shipping price should update as well Given I select carrier "price_carrier" for cart "dummy_cart" Then I should get error that carrier is invalid - Given I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties: + | active | true | And I select carrier "price_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -121,7 +122,8 @@ Feature: Order from Back Office (BO) Scenario: Use a carrier that depends on weight, add product to change order total the shipping price should update as well Given I select carrier "weight_carrier" for cart "dummy_cart" Then I should get error that carrier is invalid - Given I enable carrier "weight_carrier" + And I edit carrier "weight_carrier" with specified properties: + | active | true | And I select carrier "weight_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "weight_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -415,7 +417,8 @@ Feature: Order from Back Office (BO) Scenario: I change the customer invoice address to another zone and check that shipping fees have been updated Given shop configuration for "PS_TAX_ADDRESS_TYPE" is set to id_address_invoice - Given I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties and update its reference: + | active | true | And I select carrier "price_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -525,7 +528,8 @@ Feature: Order from Back Office (BO) Scenario: I change the customer delivery address to another zone and check that shipping fees have been updated Given shop configuration for "PS_TAX_ADDRESS_TYPE" is set to id_address_delivery - Given I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties and update its reference: + | active | true | And I select carrier "price_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "price_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -633,7 +637,8 @@ Feature: Order from Back Office (BO) Scenario: I apply free discount shipping after it has been changed the discount should be correct Given shop configuration for "PS_TAX_ADDRESS_TYPE" is set to id_address_invoice - Given I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties and update its reference: + | active | true | And I select carrier "default_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "default_carrier" as a carrier And I add order "bo_order1" with the following details: @@ -727,7 +732,8 @@ Feature: Order from Back Office (BO) Scenario: I use and address without taxes (no order_detail_tax created), then I change to a country with taxes all is correctly computed Given shop configuration for "PS_TAX_ADDRESS_TYPE" is set to id_address_delivery - And I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties and update its reference: + | active | true | And I select carrier "price_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "price_carrier" as a carrier Then I add new address to customer "testCustomer" with following details: @@ -871,7 +877,8 @@ Feature: Order from Back Office (BO) Scenario: In rounding per item mode, I use an address without taxes (no order_detail_tax created), then I change to a country with taxes all is correctly computed Given shop configuration for "PS_TAX_ADDRESS_TYPE" is set to id_address_delivery Given specific shop configuration for "rounding type" is set to round each article - And I enable carrier "price_carrier" + And I edit carrier "price_carrier" with specified properties and update its reference: + | active | true | And I select carrier "price_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "price_carrier" as a carrier Then I add new address to customer "testCustomer" with following details: diff --git a/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping_recalculate.feature b/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping_recalculate.feature index 130fd165a1e5a..7cde022292a94 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping_recalculate.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Order/order_shipping_recalculate.feature @@ -25,7 +25,8 @@ Feature: Order from Back Office (BO) Scenario: With PS_ORDER_RECALCULATE_SHIPPING = 1 & status = Awaiting bank wire payment, check the total price is recalculated Given shop configuration for "PS_ORDER_RECALCULATE_SHIPPING" is set to 1 - And I enable carrier "weight_carrier" + And I edit carrier "weight_carrier" with specified properties: + | active | true | When I select carrier "default_carrier" for cart "dummy_cart" Then cart "dummy_cart" should have "default_carrier" as a carrier When I add order "bo_order1" with the following details: @@ -66,7 +67,8 @@ Feature: Order from Back Office (BO) Scenario: With PS_ORDER_RECALCULATE_SHIPPING = 1 & status = Processing in progress, check the total price is recalculated Given shop configuration for "PS_ORDER_RECALCULATE_SHIPPING" is set to 1 - And I enable carrier "weight_carrier" + And I edit carrier "weight_carrier" with specified properties and update its reference: + | active | true | And there is a product in the catalog named "Shipping Product" with a price of 15.0 and 100 items in stock And product "Shipping Product" weight is 0.63 kg And I add 1 products "Shipping Product" to the cart "dummy_cart" @@ -167,7 +169,8 @@ Feature: Order from Back Office (BO) Scenario: With PS_ORDER_RECALCULATE_SHIPPING = 0 & status = Processing in progress, check the total price is recalculated Given shop configuration for "PS_ORDER_RECALCULATE_SHIPPING" is set to 0 - And I enable carrier "weight_carrier" + And I edit carrier "weight_carrier" with specified properties and update its reference: + | active | true | And there is a product in the catalog named "Shipping Product" with a price of 15.0 and 100 items in stock And product "Shipping Product" weight is 0.63 kg And I add 1 products "Shipping Product" to the cart "dummy_cart" diff --git a/tests/Integration/Behaviour/Features/Scenario/Product/Shop/duplicate_product_multishop.feature b/tests/Integration/Behaviour/Features/Scenario/Product/Shop/duplicate_product_multishop.feature index 44b4e68867dd9..5c4abac59ecc9 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Product/Shop/duplicate_product_multishop.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Product/Shop/duplicate_product_multishop.feature @@ -52,9 +52,11 @@ Feature: Copy product from shop to shop. And I associate attribute "Green" with shops "shop1,shop2,shop3,shop4" And I associate attribute "Orange" with shops "shop1,shop2,shop3,shop4" And single shop context is loaded - Given manufacturer studioDesign named "Studio Design" exists - And carrier carrier1 named "ecoCarrier" exists - And carrier carrier2 named "Fast carry" exists + And manufacturer studioDesign named "Studio Design" exists + And I create carrier "carrier1" with specified properties: + | name | ecoCarrier | + And I create carrier "carrier2" with specified properties: + | name | Fast carry | # Prepare a few data And I add new tax "us-tax-state-1" with following properties: | name | US Tax (6%) | diff --git a/tests/Integration/Behaviour/Features/Scenario/Product/Shop/update_shipping_multishop.feature b/tests/Integration/Behaviour/Features/Scenario/Product/Shop/update_shipping_multishop.feature index 2fb1836ee9905..6d1c41249de89 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Product/Shop/update_shipping_multishop.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Product/Shop/update_shipping_multishop.feature @@ -35,8 +35,10 @@ Feature: Update product shipping information from Back Office (BO) for multiple | delivery time out of stock notes[en-US] | | | delivery time out of stock notes[fr-FR] | | | carriers | [] | - Given carrier carrier1 named "ecoCarrier" exists - And carrier carrier2 named "Fast carry" exists + And I create carrier "carrier1" with specified properties: + | name | ecoCarrier | + And I create carrier "carrier2" with specified properties: + | name | Fast carry | When I update product "product1" with following values: | width | 10.5 | | height | 6 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Product/bulk_duplicate_product.feature b/tests/Integration/Behaviour/Features/Scenario/Product/bulk_duplicate_product.feature index 32ea213df5e77..75bd02482ecc6 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Product/bulk_duplicate_product.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Product/bulk_duplicate_product.feature @@ -20,8 +20,10 @@ Feature: Duplicate product from Back Office (BO). And language "language1" with locale "en-US" exists And language with iso code "en" is the default one And language "language2" with locale "fr-FR" exists - And carrier carrier1 named "ecoCarrier" exists - And carrier carrier2 named "Fast carry" exists + And I create carrier "carrier1" with specified properties: + | name | ecoCarrier | + And I create carrier "carrier2" with specified properties: + | name | Fast carry | And I add new supplier supplier1 with the following properties: | name | my supplier 1 | | address | Donelaicio st. 1 | diff --git a/tests/Integration/Behaviour/Features/Scenario/Product/duplicate_product.feature b/tests/Integration/Behaviour/Features/Scenario/Product/duplicate_product.feature index fb68d13668dfe..70e9a5295f727 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Product/duplicate_product.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Product/duplicate_product.feature @@ -14,8 +14,10 @@ Feature: Duplicate product from Back Office (BO). And language "language1" with locale "en-US" exists And language with iso code "en" is the default one And language "language2" with locale "fr-FR" exists - And carrier carrier1 named "ecoCarrier" exists - And carrier carrier2 named "Fast carry" exists + And I create carrier "carrier1" with specified properties: + | name | ecoCarrier | + And I create carrier "carrier2" with specified properties: + | name | Fast carry | And attribute group "Color" named "Color" in en language exists And attribute "Red" named "Red" in en language exists And attribute "Blue" named "Blue" in en language exists diff --git a/tests/Integration/Behaviour/Features/Scenario/Product/update_shipping.feature b/tests/Integration/Behaviour/Features/Scenario/Product/update_shipping.feature index bf6431eadac76..cd1815c6ccb92 100644 --- a/tests/Integration/Behaviour/Features/Scenario/Product/update_shipping.feature +++ b/tests/Integration/Behaviour/Features/Scenario/Product/update_shipping.feature @@ -19,8 +19,10 @@ Feature: Update product shipping options from Back Office (BO) | delivery time in stock notes[en-US] | | | delivery time out of stock notes[en-US] | | | carriers | [] | - Given carrier carrier1 named "ecoCarrier" exists - And carrier carrier2 named "Fast carry" exists + And I create carrier "carrier1" with specified properties: + | name | ecoCarrier | + And I create carrier "carrier2" with specified properties: + | name | Fast carry | When I update product "product1" with following values: | width | 10.5 | | height | 6 | diff --git a/tests/Integration/Behaviour/behat.yml b/tests/Integration/Behaviour/behat.yml index d7db550b80a0a..da8f1cae30db7 100644 --- a/tests/Integration/Behaviour/behat.yml +++ b/tests/Integration/Behaviour/behat.yml @@ -96,6 +96,10 @@ default: - "%paths.base%/Features/Scenario/Cart" contexts: - Tests\Integration\Behaviour\Features\Context\CarrierFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierRangesFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\ZoneFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\CustomerFeatureContext - Tests\Integration\Behaviour\Features\Context\CartFeatureContext - Tests\Integration\Behaviour\Features\Context\CartRuleFeatureContext - Tests\Integration\Behaviour\Features\Context\CategoryFeatureContext @@ -141,6 +145,9 @@ default: - "%paths.base%/Features/Scenario/Order" contexts: - Tests\Integration\Behaviour\Features\Context\CarrierFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierRangesFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\ZoneFeatureContext - Tests\Integration\Behaviour\Features\Context\CartFeatureContext - Tests\Integration\Behaviour\Features\Context\CartRuleFeatureContext - Tests\Integration\Behaviour\Features\Context\CategoryFeatureContext @@ -156,6 +163,7 @@ default: - Tests\Integration\Behaviour\Features\Context\Domain\AddressFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\ApiClientManagementFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\CartFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierTaxRuleGroupFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\CartRule\AddCartRuleFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\CartRule\CartRuleAssertionFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\CartRule\EditCartRuleFeatureContext @@ -256,6 +264,10 @@ default: contexts: - Tests\Integration\Behaviour\Features\Context\AttributeFeatureContext - Tests\Integration\Behaviour\Features\Context\AttributeGroupFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\CustomerFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierRangesFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\ZoneFeatureContext - Tests\Integration\Behaviour\Features\Context\CarrierFeatureContext - Tests\Integration\Behaviour\Features\Context\CommonFeatureContext - Tests\Integration\Behaviour\Features\Context\CurrencyFeatureContext @@ -613,23 +625,25 @@ default: paths: - "%paths.base%/Features/Scenario/Carrier" contexts: + - Tests\Integration\Behaviour\Features\Context\CategoryFeatureContext - Tests\Integration\Behaviour\Features\Context\CommonFeatureContext + - Tests\Integration\Behaviour\Features\Context\Configuration\EmailConfigurationFeatureContext + - Tests\Integration\Behaviour\Features\Context\CountryFeatureContext + - Tests\Integration\Behaviour\Features\Context\CustomerFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierRangesFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\Carrier\CarrierTaxRuleGroupFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\CartFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\CustomerFeatureContext - - Tests\Integration\Behaviour\Features\Context\ShopFeatureContext - - Tests\Integration\Behaviour\Features\Context\LanguageFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\OrderFeatureContext - - Tests\Integration\Behaviour\Features\Context\Configuration\EmailConfigurationFeatureContext - - Tests\Integration\Behaviour\Features\Context\Domain\CartFeatureContext - - Tests\Integration\Behaviour\Features\Context\CountryFeatureContext - - Tests\Integration\Behaviour\Features\Context\ModuleFeatureContext - - Tests\Integration\Behaviour\Features\Context\EmployeeFeatureContext - - Tests\Integration\Behaviour\Features\Context\CustomerFeatureContext - Tests\Integration\Behaviour\Features\Context\Domain\OrderShippingFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\TaxRulesGroupFeatureContext + - Tests\Integration\Behaviour\Features\Context\Domain\ZoneFeatureContext + - Tests\Integration\Behaviour\Features\Context\EmployeeFeatureContext + - Tests\Integration\Behaviour\Features\Context\LanguageFeatureContext - Tests\Integration\Behaviour\Features\Context\LegacyProductFeatureContext - - Tests\Integration\Behaviour\Features\Context\CategoryFeatureContext + - Tests\Integration\Behaviour\Features\Context\ModuleFeatureContext + - Tests\Integration\Behaviour\Features\Context\ShopFeatureContext employee: paths: - "%paths.base%/Features/Scenario/Employee"