/**
  * 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];
 }