/**
  * Assert that after save a search term:
  *  - it displays in the Search field at the top of the page if type set of characters passed from fixture
  *  - after click 'Go' of Search field opens a results page if it was not specified Redirect URL
  *  - after click 'Go' of Search field a customer search redirects to a specific page (passed from fixture)
  *    if it was specified Redirect URL
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogSearchQuery $searchTerm
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $searchTerm, Browser $browser)
 {
     $errors = [];
     $this->searchBlock = $cmsIndex->open()->getSearchBlock();
     if ($searchTerm->hasData('display_in_terms') && $searchTerm->getDisplayInTerms() === 'Yes') {
         $errors = !$this->isSugestSearchisVisible($searchTerm) ? '- block "Suggest Search" when searching was not found' : [];
     }
     $this->searchBlock->search($searchTerm->getQueryText());
     $windowUrl = $browser->getUrl();
     $redirectUrl = $searchTerm->getRedirect();
     if ($windowUrl !== $redirectUrl) {
         $errors[] = '- url window (' . $windowUrl . ') does not match the url redirect(' . $redirectUrl . ')';
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
Exemplo n.º 2
0
 /**
  * Assert that displayed category data on category page equals to passed from fixture.
  *
  * @param CatalogCategory $category
  * @param CatalogCategory $initialCategory
  * @param FixtureFactory $fixtureFactory
  * @param CatalogCategoryView $categoryView
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CatalogCategory $category, CatalogCategory $initialCategory, FixtureFactory $fixtureFactory, CatalogCategoryView $categoryView, Browser $browser)
 {
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['category_ids' => ['category' => $initialCategory]]]);
     $categoryData = array_merge($initialCategory->getData(), $category->getData());
     $product->persist();
     $url = $_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html';
     $browser->open($url);
     \PHPUnit_Framework_Assert::assertEquals($url, $browser->getUrl(), 'Wrong page URL.');
     if (isset($categoryData['name'])) {
         \PHPUnit_Framework_Assert::assertEquals(strtoupper($categoryData['name']), $categoryView->getTitleBlock()->getTitle(), 'Wrong page title.');
     }
     if (isset($categoryData['description'])) {
         \PHPUnit_Framework_Assert::assertEquals($categoryData['description'], $categoryView->getViewBlock()->getDescription(), 'Wrong category description.');
     }
     if (isset($categoryData['default_sort_by'])) {
         $sortBy = strtolower($categoryData['default_sort_by']);
         $sortType = $categoryView->getTopToolbar()->getSelectSortType();
         \PHPUnit_Framework_Assert::assertEquals($sortBy, $sortType, 'Wrong sorting type.');
     }
 }
 /**
  * Run create customer segment test.
  *
  * @param Customer $customer
  * @param CustomerSegment $customerSegment
  * @param CustomerSegment $customerSegmentConditions
  * @param array $salesRule
  * @param Browser $browser
  * @return void
  */
 public function test(Customer $customer, CustomerSegment $customerSegment, CustomerSegment $customerSegmentConditions, array $salesRule, Browser $browser)
 {
     // Preconditions
     $customer->persist();
     $replacement = $this->prepareReplacement($customer);
     // Steps
     $this->customerSegmentIndex->open();
     $this->customerSegmentIndex->getPageActionsBlock()->addNew();
     $this->customerSegmentNew->getCustomerSegmentForm()->fill($customerSegment);
     $this->customerSegmentNew->getPageMainActions()->saveAndContinue();
     // Retrieve customer segment id
     preg_match('@id/(\\d+)/@', $browser->getUrl(), $matches);
     $customerSegmentId = $matches[1];
     $this->customerSegmentEdit->getCustomerSegmentForm()->openTab('conditions');
     $this->customerSegmentEdit->getCustomerSegmentForm()->fillForm($customerSegmentConditions, null, $replacement);
     $this->customerSegmentEdit->getPageMainActions()->save();
     $this->createCartPriceRule($salesRule, $customerSegmentId);
 }
 /**
  * Assert that you will be redirected to url from dataset.
  *
  * @param CmsIndex $cmsIndex
  * @param Browser $browser
  * @param CatalogSearchQuery $searchTerm
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Browser $browser, CatalogSearchQuery $searchTerm)
 {
     $cmsIndex->open()->getSearchBlock()->search($searchTerm->getSynonymFor());
     \PHPUnit_Framework_Assert::assertEquals($searchTerm->getRedirect(), $browser->getUrl(), 'Redirect by synonym was not executed.');
 }