![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/testsuite/Magento/Checkout/_files/ |
<?php /** * SalesRule 10% discount coupon * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\SalesRule\Model\RuleFactory $salesRule */ $salesRuleFactory = $objectManager->get(\Magento\SalesRule\Model\RuleFactory::class); /** @var \Magento\SalesRule\Model\Rule $salesRule */ $salesRule = $salesRuleFactory->create(); $data = [ 'name' => 'Test Coupon', 'is_active' => true, 'website_ids' => [ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( \Magento\Store\Model\StoreManagerInterface::class )->getStore()->getWebsiteId() ], 'customer_group_ids' => [\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID, 1], 'coupon_type' => \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC, 'coupon_code' => uniqid(), 'simple_action' => \Magento\SalesRule\Model\Rule::BY_PERCENT_ACTION, 'discount_amount' => 10, 'discount_step' => 1 ]; $salesRule->loadPost($data)->setUseAutoGeneration(false)->save(); $objectManager->get(\Magento\Framework\Registry::class)->unregister('Magento/Checkout/_file/discount_10percent'); $objectManager->get(\Magento\Framework\Registry::class) ->register('Magento/Checkout/_file/discount_10percent', $salesRule->getRuleId());