/**
  * Assert that displayed banner data on edit page equals passed from fixture.
  *
  * @param Banner $banner
  * @param BannerIndex $bannerIndex
  * @param BannerEdit $bannerEdit
  * @return void
  */
 public function processAssert(Banner $banner, BannerIndex $bannerIndex, BannerEdit $bannerEdit)
 {
     $bannerIndex->open();
     $bannerIndex->getGrid()->searchAndOpen(['name' => $banner->getName()]);
     $fixtureData = $banner->getData();
     $formData = $bannerEdit->getBannerForm()->getData($banner);
     $errors = $this->verifyData($fixtureData, $formData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * Assert that created banner is found by name and has correct banner types, visibility, status.
  *
  * @param Banner $banner
  * @param BannerIndex $bannerIndex
  * @return void
  */
 public function processAssert(Banner $banner, BannerIndex $bannerIndex)
 {
     $bannerIndex->open();
     $filter = ['name' => $banner->getName(), 'active' => $banner->getIsEnabled()];
     $isStoreContents = $banner->getStoreContents();
     if (isset($isStoreContents['store_views'])) {
         $filter['visibility'] = $banner->getDataFieldConfig('store_contents')['source']->getStore();
     }
     $bannerIndex->getGrid()->search($filter);
     if ($banner->hasData('types')) {
         $filter['types'] = implode(', ', $banner->getTypes());
     }
     unset($filter['visibility']);
     \PHPUnit_Framework_Assert::assertTrue($bannerIndex->getGrid()->isRowVisible($filter, false), 'Banner is absent in grid.');
 }
 /**
  * Creation for assign Related Cart and Catalog Rules to BannerEntity test.
  *
  * @param Banner $banner
  * @param string $customer
  * @param string $customerSegment
  * @param CmsPage $cmsPage
  * @param string $widget
  * @param string $product
  * @param string $catalogPriceRule [optional]
  * @param string $cartPriceRule [optional]
  * @param bool $isCatalogRuleApplied [optional]
  * @return array
  */
 public function test(Banner $banner, CmsPage $cmsPage, $customer, $customerSegment, $widget, $product, $catalogPriceRule = null, $cartPriceRule = null, $isCatalogRuleApplied = false)
 {
     // Preconditions
     $customer = $this->createCustomer($customer);
     $customerSegment = $this->createCustomerSegment($customerSegment);
     $cmsPage->persist();
     $this->product = $this->createProduct($product);
     $banner = $this->createBanner($customerSegment, $banner);
     $this->createWidget($widget, $banner);
     $this->createRules($cartPriceRule, $catalogPriceRule);
     $filter = ['name' => $banner->getName()];
     // Steps
     $this->bannerIndex->open();
     $this->bannerIndex->getGrid()->searchAndOpen($filter);
     $this->bannerNew->getBannerForm()->openTab('related_promotions');
     /** @var \Enterprise\Banner\Test\Block\Adminhtml\Banner\Edit\Tab\RelatedPromotions $tab */
     $tab = $this->bannerNew->getBannerForm()->getTabElement('related_promotions');
     if (!empty($this->rules['banner_sales_rules'])) {
         $tab->getCartPriceRulesGrid()->searchAndSelect(['id' => $this->rules['banner_sales_rules']]);
     }
     if (!empty($this->rules['banner_catalog_rules'])) {
         $tab->getCatalogPriceRulesGrid()->searchAndSelect(['id' => $this->rules['banner_catalog_rules']]);
     }
     $this->bannerNew->getFormPageActions()->save();
     // Apply Catalog rule for asserts:
     $this->applyCatalogRule($isCatalogRuleApplied);
     return ['product' => $this->product, 'banner' => $banner, 'customer' => $customer, 'customerSegment' => $customerSegment];
 }
 /**
  * Create banner.
  *
  * @param Banner $banner
  * @return void
  */
 public function test(Banner $banner)
 {
     // Steps
     $this->bannerIndex->open();
     $this->bannerIndex->getGridPageActions()->addNew();
     $this->bannerNew->getBannerForm()->fill($banner);
     $this->bannerNew->getFormPageActions()->save();
     // Prepare data for tier down
     $this->websiteName = explode('/', $banner->getDataFieldConfig('store_contents')['source']->getStore())[0];
 }
 /**
  * Assert that after banner save success save message is present on banner index page.
  *
  * @param BannerIndex $bannerIndex
  * @return void
  */
 public function processAssert(BannerIndex $bannerIndex)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_SAVE_MESSAGE, $bannerIndex->getMessagesBlock()->getSuccessMessages());
 }