Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteAttributeStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
10 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeIndex;
11 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeNew;
12 use Magento\Mtf\TestStep\TestStepInterface;
13 
17 class DeleteAttributeStep implements TestStepInterface
18 {
25 
32 
38  protected $attribute;
39 
46  public function __construct(
47  CatalogProductAttributeIndex $catalogProductAttributeIndex,
48  CatalogProductAttributeNew $catalogProductAttributeNew,
49  CatalogProductAttribute $attribute
50  ) {
51  $this->catalogProductAttributeIndex = $catalogProductAttributeIndex;
52  $this->catalogProductAttributeNew = $catalogProductAttributeNew;
53  $this->attribute = $attribute;
54  }
55 
61  public function run()
62  {
63  $filter = $this->attribute->hasData('attribute_code')
64  ? ['attribute_code' => $this->attribute->getAttributeCode()]
65  : ['frontend_label' => $this->attribute->getFrontendLabel()];
66  $this->catalogProductAttributeIndex->open();
67  if ($this->catalogProductAttributeIndex->getGrid()->isRowVisible($filter)) {
68  $this->catalogProductAttributeIndex->getGrid()->searchAndOpen($filter);
69  $this->catalogProductAttributeNew->getPageActions()->delete();
70  $this->catalogProductAttributeNew->getModalBlock()->acceptAlert();
71  }
72  }
73 }
__construct(CatalogProductAttributeIndex $catalogProductAttributeIndex, CatalogProductAttributeNew $catalogProductAttributeNew, CatalogProductAttribute $attribute)