/**
  * Check whether the attribute is unique.
  *
  * @param CatalogProductIndex $catalogProductIndex
  * @param CatalogProductEdit $catalogProductEdit
  * @param CatalogProductAttribute $attribute
  * @param CatalogProductSimple $product ,
  * @param FixtureFactory $fixtureFactory
  * @throws \Exception
  * @return void
  */
 public function processAssert(CatalogProductIndex $catalogProductIndex, CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, CatalogProductSimple $product, FixtureFactory $fixtureFactory)
 {
     $this->fixtureFactory = $fixtureFactory;
     $simpleProduct = $this->createSimpleProductFixture($product, $attribute);
     $catalogProductIndex->open()->getGridPageActionBlock()->addProduct('simple');
     $productForm = $catalogProductEdit->getProductForm();
     $productForm->fill($simpleProduct);
     $catalogProductEdit->getFormPageActions()->save();
     $actualErrorMessage = $catalogProductEdit->getMessagesBlock()->getErrorMessage();
     $attributeLabel = $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::UNIQUE_MESSAGE, $attributeLabel), $actualErrorMessage, 'JS error notice on product edit page is not equal to expected.');
 }
 /**
  * Assign promoted products.
  *
  * @param string $promotedProducts
  * @param string $type
  * @return void
  */
 protected function assignPromotedProducts($promotedProducts, $type)
 {
     $promotedProducts = $this->parsePromotedProducts($promotedProducts);
     foreach ($promotedProducts as $productName => $assignedNames) {
         $initialProduct = $this->products[$productName];
         $filter = ['sku' => $initialProduct->getSku()];
         $assignedProducts = [];
         foreach ($assignedNames as $assignedName) {
             $assignedProducts[] = $this->products[$assignedName];
         }
         $product = $this->fixtureFactory->create(get_class($initialProduct), ['data' => [$type => ['products' => $assignedProducts]]]);
         $this->catalogProductIndex->open();
         $this->catalogProductIndex->getProductGrid()->searchAndOpen($filter);
         $this->catalogProductEdit->getProductForm()->fill($product);
         $this->catalogProductEdit->getFormPageActions()->save();
         $this->catalogProductEdit->getMessagesBlock()->waitSuccessMessage();
     }
 }
 /**
  * Checking the output message successful product duplication
  *
  * @param CatalogProductEdit $productPage
  * @return void
  */
 public function processAssert(CatalogProductEdit $productPage)
 {
     $actualMessages = $productPage->getMessagesBlock()->getSuccessMessages();
     \PHPUnit_Framework_Assert::assertContains(self::DUPLICATE_MESSAGE, $actualMessages, 'Wrong duplicated message is displayed.' . "\nExpected: " . self::DUPLICATE_MESSAGE . "\nActual:\n" . implode("\n - ", $actualMessages));
 }
 /**
  * Assert that success message is displayed after product save
  *
  * @param CatalogProductEdit $productPage
  * @return void
  */
 public function processAssert(CatalogProductEdit $productPage)
 {
     $actualMessage = $productPage->getMessagesBlock()->getSuccessMessages();
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_MESSAGE . "\nActual: " . $actualMessage);
 }
 /**
  * Assert that success message is displayed after product save
  *
  * @param CatalogProductEdit $productPage
  * @return void
  */
 public function processAssert(CatalogProductEdit $productPage)
 {
     $actualMessages = $productPage->getMessagesBlock()->getSuccessMessages();
     $actualMessages = is_array($actualMessages) ? $actualMessages : [$actualMessages];
     \PHPUnit_Framework_Assert::assertContains(self::SUCCESS_MESSAGE, $actualMessages, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_MESSAGE . "\nActual:\n" . implode("\n - ", $actualMessages));
 }