Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddProductVideoTest.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 
30 class AddProductVideoTest extends Injectable
31 {
32  /* tags */
33  const TEST_TYPE = 'acceptance_test, extended_acceptance_test';
34  const MVP = 'yes';
35  /* end tags */
36 
42  protected $productGrid;
43 
47  protected $newProductPage;
48 
54  protected $configData;
55 
62  public function __inject(
63  CatalogProductIndex $productGrid,
64  CatalogProductNew $newProductPage
65  ) {
66  $this->productGrid = $productGrid;
67  $this->newProductPage = $newProductPage;
68  }
69 
77  public function test(
78  CatalogProductSimple $product,
79  $configData = null
80  ) {
81  $this->configData = $configData;
82 
83  // Preconditions
84  $this->objectManager->create(
85  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
86  ['configData' => $this->configData]
87  )->run();
88 
89  // Steps
90  // * 1. Go to backend.
91  $this->productGrid->open();
92 
93  // * 2. Open simple product page to create a new one.
94  $this->productGrid->getGridPageActionBlock()->addProduct('simple');
95 
96  // * 3. Click "Add Video" in "Images and Videos" section.
97  // * 4. Fill fields regarding to Test Data.
98  // * 5. Click "Save" button on "Add Video" panel.
99  $this->newProductPage->getProductForm()->fill($product);
100 
101  // * 6. Click "Save" button on product page.
102  $this->newProductPage->getFormPageActions()->save();
103 
104  return ['product' => $product];
105  }
106 
112  public function tearDown()
113  {
114  if ($this->configData) {
115  $this->objectManager->create(
116  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
117  ['configData' => $this->configData, 'rollback' => true]
118  )->run();
119  }
120  }
121 }
__inject(CatalogProductIndex $productGrid, CatalogProductNew $newProductPage)
test(CatalogProductSimple $product, $configData=null)