Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateCatalogPriceRuleEntityTest.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\CatalogRule\Test\Fixture\CatalogRule;
14 
32 {
33  /* tags */
34  const MVP = 'yes';
35  const TEST_TYPE = 'extended_acceptance_test';
36  /* end tags */
37 
49  public function test(
50  CatalogRule $catalogPriceRule,
51  CatalogRule $catalogPriceRuleOriginal,
52  Cron $cron,
53  $saveAction,
54  Customer $customer = null,
55  $isCronEnabled = false
56  ) {
57  // Preconditions
58  $catalogPriceRuleOriginal->persist();
59 
60  if ($customer !== null) {
61  $customer->persist();
62  }
63 
64  if ($isCronEnabled) {
65  $cron->run();
66  $cron->run();
67  }
68 
69  // Prepare data
70  $productSimple = $this->fixtureFactory->createByCode(
71  'catalogProductSimple',
72  ['dataset' => 'product_with_category']
73  );
74 
76  $sourceCategories = $productSimple->getDataFieldConfig('category_ids')['source'];
77  $replace = [
78  'conditions' => [
79  'conditions' => [
80  '%category_1%' => $sourceCategories->getIds()[0],
81  ],
82  ],
83  ];
84  $filter = [
85  'name' => $catalogPriceRuleOriginal->getName(),
86  'rule_id' => $catalogPriceRuleOriginal->getId(),
87  ];
88 
89  // Steps
90  $this->catalogRuleIndex->open();
91  $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter);
92  $this->catalogRuleNew->getEditForm()->fill($catalogPriceRule, null, $replace);
93  $this->catalogRuleNew->getFormPageActions()->$saveAction();
94 
95  if ($isCronEnabled) {
96  $cron->run();
97  $cron->run();
98  }
99 
100  // Create simple product with category
101  $productSimple->persist();
102 
103  return ['products' => [$productSimple]];
104  }
105 }
$customer
Definition: customers.php:11