/** * Assert that you will be redirected to url from dataset * * @param CmsIndex $cmsIndex * @param BrowserInterface $browser * @param CatalogSearchQuery $searchTerm * @return void */ public function processAssert(CmsIndex $cmsIndex, BrowserInterface $browser, CatalogSearchQuery $searchTerm) { $cmsIndex->open()->getSearchBlock()->search($searchTerm->getSynonymFor()); $windowUrl = $browser->getUrl(); $redirectUrl = $searchTerm->getRedirect(); \PHPUnit_Framework_Assert::assertEquals($windowUrl, $redirectUrl, 'Redirect by synonym was not executed.' . PHP_EOL . "Expected: " . $redirectUrl . PHP_EOL . "Actual: " . $windowUrl); }
/** * Assert that after save a search term on edit term search page displays: * - correct Search Query field passed from fixture * - correct Store * - correct Number of results * - correct Number of Uses * - correct Synonym For * - correct Redirect URL * - correct Display in Suggested Terms * * @param CatalogSearchIndex $indexPage * @param CatalogSearchEdit $editPage * @param CatalogSearchQuery $searchTerm * @return void */ public function processAssert(CatalogSearchIndex $indexPage, CatalogSearchEdit $editPage, CatalogSearchQuery $searchTerm) { $indexPage->open()->getGrid()->searchAndOpen(['search_query' => $searchTerm->getQueryText()]); $formData = $editPage->getForm()->getData($searchTerm); $fixtureData = $searchTerm->getData(); \PHPUnit_Framework_Assert::assertEquals($formData, $fixtureData, 'This form "Search Term" does not match the fixture data.'); }
/** * Assert that result page contains product, according to search request from fixture. * * @param CatalogSearchQuery $catalogSearch * @param AdvancedResult $resultPage * @return void */ public function processAssert(CatalogSearchQuery $catalogSearch, AdvancedResult $resultPage) { $product = $catalogSearch->getDataFieldConfig('query_text')['source']->getProduct(); $isProductVisible = $resultPage->getListProductBlock()->getProductItem($product)->isVisible(); while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage()) { $isProductVisible = $resultPage->getListProductBlock()->getProductItem($product)->isVisible(); } \PHPUnit_Framework_Assert::assertTrue($isProductVisible, "A product with name '" . $product->getName() . "' was not found."); }
/** * Run edit search term test * * @param CatalogSearchQuery $searchTerm * @return void */ public function test(CatalogSearchQuery $searchTerm) { // Preconditions $searchText = $searchTerm->getQueryText(); // Steps $this->cmsIndex->open()->getSearchBlock()->search($searchText); $this->indexPage->open()->getGrid()->searchAndOpen(['search_query' => $searchText]); $this->editPage->getForm()->fill($searchTerm); $this->editPage->getFormPageActions()->save(); }
/** * Run delete search term entity test * * @param CatalogSearchQuery $searchTerm * @return void */ public function test(CatalogSearchQuery $searchTerm) { // Preconditions $searchTerm->persist(); $searchText = $searchTerm->getQueryText(); // Steps $this->indexPage->open(); $this->indexPage->getGrid()->searchAndOpen(['search_query' => $searchText]); $this->editPage->getFormPageActions()->delete(); }
/** * Check suggest block visibility * * @param CatalogSearchQuery $searchTerm * @return array */ protected function checkSuggestSearch(CatalogSearchQuery $searchTerm) { $queryText = $searchTerm->getQueryText(); $this->searchBlock->fillSearch($queryText); if ($searchTerm->hasData('num_results')) { $isVisible = $this->searchBlock->isSuggestSearchVisible($queryText, $searchTerm->getNumResults()); } else { $isVisible = $this->searchBlock->isSuggestSearchVisible($queryText); } return $isVisible ? [] : ['- block "Suggest Search" when searching was not found']; }
/** * Assert product can be opened from search results page. * * @param CatalogSearchQuery $catalogSearch * @param AdvancedResult $resultPage * @param CatalogProductView $catalogProductViewPage * @return void */ public function processAssert(CatalogSearchQuery $catalogSearch, AdvancedResult $resultPage, CatalogProductView $catalogProductViewPage) { $product = $catalogSearch->getDataFieldConfig('query_text')['source']->getProduct(); $isProductVisible = $resultPage->getListProductBlock()->getProductItem($product)->isVisible(); while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage()) { $isProductVisible = $resultPage->getListProductBlock()->getProductItem($product)->isVisible(); } $productName = $product->getName(); \PHPUnit_Framework_Assert::assertTrue($isProductVisible, "A product with name {$productName} was not found."); $resultPage->getListProductBlock()->getProductItem($product)->open(); \PHPUnit_Framework_Assert::assertEquals($productName, $catalogProductViewPage->getViewBlock()->getProductName(), 'Wrong product page has been opened.'); }
/** * Check that after input some text(e.g. product name) into search field, drop-down window is appeared. * Window contains requested entity and number of quantity. * * @param CmsIndex $cmsIndex * @param CatalogSearchQuery $catalogSearch * @return void */ public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSearch) { $cmsIndex->open(); $searchBlock = $cmsIndex->getSearchBlock(); $queryText = $catalogSearch->getQueryText(); $searchBlock->fillSearch($queryText); if ($catalogSearch->hasData('num_results')) { $isVisible = $searchBlock->isSuggestSearchVisible($queryText, $catalogSearch->getNumResults()); } else { $isVisible = $searchBlock->isSuggestSearchVisible($queryText); } \PHPUnit_Framework_Assert::assertTrue($isVisible, 'Block "Suggest Search" when searching was not found'); }
/** * Assert that after save a term search on edit term search page displays: * - correct Search Query field passed from fixture * - correct Store * - correct Results * - correct Uses * - correct Synonym * - correct Redirect URL * - correct Suggested Terms * * @param CatalogSearchIndex $indexPage * @param CatalogSearchQuery $searchTerm * @return void */ public function processAssert(CatalogSearchIndex $indexPage, CatalogSearchQuery $searchTerm) { $grid = $indexPage->open()->getGrid(); $filters = ['search_query' => $searchTerm->getQueryText(), 'store_id' => $searchTerm->getStoreId(), 'results_from' => $searchTerm->getNumResults(), 'popularity_from' => $searchTerm->getPopularity(), 'synonym_for' => $searchTerm->getSynonymFor(), 'redirect' => $searchTerm->getRedirect(), 'display_in_terms' => strtolower($searchTerm->getDisplayInTerms())]; $grid->search($filters); unset($filters['store_id']); \PHPUnit_Framework_Assert::assertTrue($grid->isRowVisible($filters, false), 'Row terms according to the filters is not found.'); }
/** * Assert that after delete a search term on grid page not displayed * * @param CatalogSearchIndex $indexPage * @param CatalogSearchQuery $searchTerm * @return void */ public function processAssert(CatalogSearchIndex $indexPage, CatalogSearchQuery $searchTerm) { $queryText = $searchTerm->getQueryText(); $grid = $indexPage->open()->getGrid(); $filters = ['search_query' => $queryText, 'store_id' => $searchTerm->getStoreId(), 'results_from' => $searchTerm->getNumResults(), 'popularity_from' => $searchTerm->getPopularity(), 'redirect' => $searchTerm->getRedirect(), 'display_in_terms' => strtolower($searchTerm->getDisplayInTerms())]; $grid->search($filters); unset($filters['store_id']); \PHPUnit_Framework_Assert::assertFalse($grid->isRowVisible($filters, false), 'Search term "' . $queryText . '" was found in grid.'); }
/** * Assert that you will be not redirected to url from dataset * * @param CmsIndex $cmsIndex * @param CatalogSearchQuery $searchTerm * @param BrowserInterface $browser * @return void */ public function processAssert(CmsIndex $cmsIndex, BrowserInterface $browser, CatalogSearchQuery $searchTerm) { $cmsIndex->open()->getSearchBlock()->search($searchTerm->getSynonymFor()); \PHPUnit_Framework_Assert::assertNotEquals($browser->getUrl(), $searchTerm->getRedirect(), 'Url in the browser corresponds to Url in fixture (redirect has been performed).' . PHP_EOL . 'Search term: "' . $searchTerm->getQueryText() . '"'); }
/** * Run searching result test. * * @param CatalogSearchQuery $catalogSearch * @return void */ public function test(CatalogSearchQuery $catalogSearch) { $this->cmsIndex->open(); $this->cmsIndex->getSearchBlock()->search($catalogSearch->getQueryText()); }
/** * Run suggest searching result test * * @param CmsIndex $cmsIndex * @param CatalogSearchQuery $catalogSearch * @return void */ public function testSearch(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSearch) { $cmsIndex->open(); $cmsIndex->getSearchBlock()->search($catalogSearch->getQueryText()); }