Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteCatalogPriceRuleEntityTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\CatalogRule\Test\Fixture\CatalogRule;
10 use Magento\CatalogRule\Test\Page\Adminhtml\CatalogRuleIndex;
11 use Magento\CatalogRule\Test\Page\Adminhtml\CatalogRuleNew;
12 use Magento\Mtf\TestCase\Injectable;
14 
32 class DeleteCatalogPriceRuleEntityTest extends Injectable
33 {
34  /* tags */
35  const MVP = 'yes';
36  /* end tags */
37 
43  protected $catalogRuleIndex;
44 
50  protected $catalogRuleNew;
51 
59  public function __inject(
60  CatalogRuleIndex $catalogRuleIndex,
61  CatalogRuleNew $catalogRuleNew
62  ) {
63  $this->catalogRuleIndex = $catalogRuleIndex;
64  $this->catalogRuleNew = $catalogRuleNew;
65  }
66 
75  public function test(CatalogRule $catalogPriceRule, $product, Customer $customer = null)
76  {
77  // Precondition
78  $catalogPriceRule->persist();
79 
80  if ($customer) {
81  $customer->persist();
82  }
83 
84  $filter = [
85  'name' => $catalogPriceRule->getName(),
86  'rule_id' => $catalogPriceRule->getId(),
87  ];
88  // Steps
89  $this->catalogRuleIndex->open();
90  $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter);
91  $this->catalogRuleNew->getFormPageActions()->delete();
92  $this->catalogRuleNew->getModalBlock()->acceptAlert();
93  $products = $this->objectManager->create(
94  \Magento\Catalog\Test\TestStep\CreateProductsStep::class,
95  ['products' => $product]
96  )->run();
97 
98  return [
99  'products' => $products['products']
100  ];
101  }
102 }
$customer
Definition: customers.php:11
test(CatalogRule $catalogPriceRule, $product, Customer $customer=null)
__inject(CatalogRuleIndex $catalogRuleIndex, CatalogRuleNew $catalogRuleNew)