/**
  * Test update grouped product
  *
  * @param GroupedProductInjectable $product
  * @param GroupedProductInjectable $originalProduct
  * @return void
  */
 public function test(GroupedProductInjectable $product, GroupedProductInjectable $originalProduct)
 {
     // Precondition
     $originalProduct->persist();
     // Steps
     $this->catalogProductIndex->open();
     $this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $originalProduct->getSku()]);
     $this->catalogProductEdit->getProductForm()->fill($product);
     $this->catalogProductEdit->getFormPageActions()->save();
 }
 /**
  * Verify product price on grouped product view page
  *
  * @param GroupedProductInjectable $product
  * @param CatalogProductView $catalogProductView
  * @param AssertPriceOnProductPageInterface $object
  * @param Browser $browser
  * @param string $typePrice [optional]
  * @return bool|string
  */
 protected function processAssertPrice(GroupedProductInjectable $product, CatalogProductView $catalogProductView, AssertPriceOnProductPageInterface $object, Browser $browser, $typePrice = '')
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $groupedData = $product->getAssociated();
     /** @var InjectableFixture $subProduct */
     foreach ($groupedData['products'] as $key => $subProduct) {
         //Process assertions
         $catalogProductView->getViewBlock()->{'item' . $typePrice . 'PriceProductBlock'}(++$key);
         $object->setErrorMessage(sprintf($this->errorMessage, $subProduct->getData('name')));
         $object->assertPrice($subProduct, $catalogProductView, 'Grouped');
     }
 }
 /**
  * Assert that default qty for sub products in grouped product displays according to dataset on product page
  *
  * @param CatalogProductView $groupedProductView
  * @param GroupedProductInjectable $product
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CatalogProductView $groupedProductView, GroupedProductInjectable $product, Browser $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $associatedProducts = $product->getAssociated();
     $fixtureQtyData = [];
     $pageOptions = $groupedProductView->getViewBlock()->getOptions($product);
     $pageQtyData = [];
     foreach ($associatedProducts['assigned_products'] as $productData) {
         $fixtureQtyData[] = ['name' => $productData['name'], 'qty' => $productData['qty']];
     }
     foreach ($pageOptions['grouped_options'] as $productData) {
         $pageQtyData[] = ['name' => $productData['name'], 'qty' => $productData['qty']];
     }
     $fixtureQtyData = $this->sortDataByPath($fixtureQtyData, '::name');
     $pageQtyData = $this->sortDataByPath($pageQtyData, '::name');
     $error = $this->verifyData($fixtureQtyData, $pageQtyData);
     \PHPUnit_Framework_Assert::assertEmpty($error, $error);
 }