Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateProductVideoTest.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 
33 class UpdateProductVideoTest extends Injectable
34 {
35  /* tags */
36  const TEST_TYPE = 'extended_acceptance_test';
37  const MVP = 'yes';
38  const STABLE = 'no';
39  /* end tags */
40 
46  protected $productGrid;
47 
51  protected $newProductPage;
52 
58  protected $configData;
59 
66  public function __inject(
67  CatalogProductIndex $productGrid,
68  CatalogProductNew $newProductPage
69  ) {
70  $this->productGrid = $productGrid;
71  $this->newProductPage = $newProductPage;
72  }
73 
82  public function test(
83  CatalogProductSimple $product,
84  CatalogProductSimple $productVideo,
85  $configData = null
86  ) {
87  $this->configData = $configData;
88 
89  // Preconditions
90  $this->objectManager->create(
91  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
92  ['configData' => $this->configData]
93  )->run();
94 
95  // Steps
96  // * 1. Go to backend.
97  $this->productGrid->open();
98  // * 2. Open simple product page to create a new product.
99  $this->productGrid->getGridPageActionBlock()->addProduct('simple');
100 
101  // * 3. Click "Add Video" in "Images and Videos" section.
102  // * 4. Fill fields regarding to Test Data.
103  // * 5. Click "Save" button on "Add Video" panel.
104  $this->newProductPage->getProductForm()->fill($productVideo);
105 
106  // * 6. Click on video preview.
107  // * 7. Fill fields regarding to Test Data.
108  // * 8. Click "Save" button on "Edit Video" panel.
109 
110  $this->newProductPage->getProductForm()->fill($product);
111 
112  // * 9. Click "Save" button on product page
113  $this->newProductPage->getFormPageActions()->save();
114 
115  return ['product' => $product];
116  }
117 
123  public function tearDown()
124  {
125  if ($this->configData) {
126  $this->objectManager->create(
127  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
128  ['configData' => $this->configData, 'rollback' => true]
129  )->run();
130  }
131  }
132 }
test(CatalogProductSimple $product, CatalogProductSimple $productVideo, $configData=null)
__inject(CatalogProductIndex $productGrid, CatalogProductNew $newProductPage)