-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...tests/integration/testsuite/Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\Customer\Model\GroupManagement as CustomerGroupManagement; | ||
use Magento\Framework\Api\DataObjectHelper; | ||
use Magento\SalesRule\Api\RuleRepositoryInterface; | ||
use Magento\SalesRule\Model\Data\Rule as RuleData; | ||
use Magento\Store\Model\StoreManagerInterface as StoreManagerInterface; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
|
||
$objectManager = Bootstrap::getObjectManager(); | ||
/** @var RuleRepositoryInterface $ruleRepository */ | ||
$ruleRepository = $objectManager->get(RuleRepositoryInterface::class); | ||
/** @var DataObjectHelper $dataObjectHelper */ | ||
$dataObjectHelper = Bootstrap::getObjectManager()->get(DataObjectHelper::class); | ||
$ruleLabel = $objectManager->create(\Magento\SalesRule\Api\Data\RuleLabelInterface::class); | ||
$ruleLabelFactory = $objectManager->get(\Magento\SalesRule\Model\Data\RuleLabelFactory::class); | ||
|
||
|
||
/** @var RuleData $salesRule */ | ||
$salesRule = $objectManager->create(RuleData::class); | ||
/** @var \Magento\SalesRule\Api\Data\RuleLabelInterface $ruleLabel */ | ||
$ruleLabel = $ruleLabelFactory->create(); | ||
$ruleLabel->setStoreId(0); | ||
$ruleLabel->setStoreLabel('50% Off for all orders'); | ||
$ruleData = [ | ||
'name' => '50% Off for all orders', | ||
'is_active' => 1, | ||
'customer_group_ids' => [CustomerGroupManagement::NOT_LOGGED_IN_ID], | ||
'coupon_type' => RuleData::COUPON_TYPE_NO_COUPON, | ||
'conditions' => [], | ||
'simple_action' => 'by_percent', | ||
'discount_amount' => 50, | ||
'discount_step' => 0, | ||
'website_ids' => [ | ||
$objectManager->get( | ||
StoreManagerInterface::class | ||
)->getWebsite()->getId(), | ||
], | ||
'discount_qty' => 0, | ||
'apply_to_shipping' => 1, | ||
'simple_free_shipping' => 1, | ||
]; | ||
$dataObjectHelper->populateWithArray($salesRule, $ruleData, \Magento\SalesRule\Api\Data\RuleInterface::class); | ||
$salesRule->setStoreLabels([$ruleLabel]); | ||
|
||
$ruleRepository->save($salesRule); |
26 changes: 26 additions & 0 deletions
26
...egration/testsuite/Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon_rollback.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\SalesRule\Api\RuleRepositoryInterface; | ||
use Magento\SalesRule\Model\ResourceModel\Rule as RuleResource; | ||
use Magento\SalesRule\Model\RuleFactory as RuleFactory; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
$objectManager = Bootstrap::getObjectManager(); | ||
/** @var RuleRepositoryInterface $ruleRepository */ | ||
$ruleRepository = $objectManager->get(RuleRepositoryInterface::class); | ||
/** @var RuleResource $ruleResource */ | ||
$ruleResource = $objectManager->get(RuleResource::class); | ||
/** @var RuleFactory $ruleFactory */ | ||
$ruleFactory = $objectManager->get(RuleFactory::class); | ||
$salesRule = $ruleFactory->create(); | ||
|
||
$ruleResource->load($salesRule, '50% Off for all orders', 'name'); | ||
// FIXME: the rule cannot be found for some reason | ||
if ($salesRule->getRuleId()) { | ||
$ruleRepository->deleteById($salesRule->getRuleId()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters