Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeleteProductVideoTest.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
10 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew;
11 use Magento\Mtf\ObjectManager;
12 use Magento\Mtf\TestCase\Injectable;
13 
32 class DeleteProductVideoTest extends Injectable
33 {
34  /* tags */
35  const TEST_TYPE = 'acceptance_test, extended_acceptance_test';
36  const MVP = 'yes';
37  /* end tags */
38 
44  protected $productGrid;
45 
49  protected $newProductPage;
50 
56  protected $configData;
57 
64  public function __inject(
65  CatalogProductIndex $productGrid,
66  CatalogProductNew $newProductPage
67  ) {
68  $this->productGrid = $productGrid;
69  $this->newProductPage = $newProductPage;
70  }
71 
79  public function test(
80  CatalogProductSimple $product,
81  $configData = null
82  ) {
83  $this->configData = $configData;
84 
85  // Preconditions
86  $this->objectManager->create(
87  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
88  ['configData' => $this->configData]
89  )->run();
90 
91  // Steps
92  // * 1. Go to backend.
93  $this->productGrid->open();
94 
95  // * 2. Open simple product page to create a new one.
96  $this->productGrid->getGridPageActionBlock()->addProduct('simple');
97 
98  // * 3. Click "Add Video" in "Images and Videos" section.
99  // * 4. Fill fields regarding to Test Data.
100  // * 5. Click "Save" button on "Add Video" panel.
101  $productForm = $this->newProductPage->getProductForm();
102  $productForm->fill($product);
103 
104  // * 6. Click on added video preview.
105  // * 7. Click "Delete" button on "Edit Video" panel.
106  $productForm->openSection('images-and-videos')->getSection('images-and-videos')->deleteFirstVideo();
107 
108  // * 8. Click "Save" button on product page.
109  $this->newProductPage->getFormPageActions()->save();
110 
111  return ['product' => $product];
112  }
113 
119  public function tearDown()
120  {
121  if ($this->configData) {
122  $this->objectManager->create(
123  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
124  ['configData' => $this->configData, 'rollback' => true]
125  )->run();
126  }
127  }
128 }
test(CatalogProductSimple $product, $configData=null)
__inject(CatalogProductIndex $productGrid, CatalogProductNew $newProductPage)