/**
  * Assert that created CMS page displays with error message on unassigned store views on frontend.
  *
  * @param CmsPage $cms
  * @param FrontendCmsPage $frontendCmsPage
  * @param Browser $browser
  * @param CmsIndex $cmsIndex
  * @param string|null $notFoundMessage
  * @return void
  */
 public function processAssert(CmsPage $cms, FrontendCmsPage $frontendCmsPage, Browser $browser, CmsIndex $cmsIndex, $notFoundMessage = null)
 {
     $browser->open($_ENV['app_frontend_url'] . $cms->getIdentifier());
     $notFoundMessage = $notFoundMessage !== null ? $notFoundMessage : self::ERROR_MESSAGE;
     $cmsIndex->getHeaderBlock()->selectStore('Default Store View');
     \PHPUnit_Framework_Assert::assertContains($notFoundMessage, $frontendCmsPage->getCmsPageContentBlock()->getPageContent(), 'Wrong page content is displayed.');
 }
Esempio n. 2
0
 /**
  * Assert that displayed CMS page data on edit page equals passed from fixture.
  *
  * @param CmsPage $cms
  * @param CmsPageIndex $cmsPageIndex
  * @param CmsPageNew $cmsPageNew
  * @return void
  */
 public function processAssert(CmsPage $cms, CmsPageIndex $cmsPageIndex, CmsPageNew $cmsPageNew)
 {
     $cmsPageIndex->open();
     $cmsPageIndex->getCmsPageGridBlock()->searchAndOpen(['title' => $cms->getTitle()]);
     $cmsFormData = $cmsPageNew->getPageForm()->getData($cms);
     $errors = $this->verifyData($cms->getData(), $cmsFormData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
Esempio n. 3
0
 /**
  * Fill store view.
  *
  * @param CmsPage $cms
  * @return void
  */
 protected function fillStoreView(CmsPage $cms)
 {
     $this->openTab('page_information');
     $storeViewField = $this->_rootElement->find($this->storeView, Locator::SELECTOR_CSS, 'multiselectgrouplist');
     if ($storeViewField->isVisible() && !$cms->hasData('store_id')) {
         $storeViewField->setValue('All Store Views');
     }
 }
 /**
  * Delete CMS Page.
  *
  * @param CmsPage $cmsPage
  * @return void
  */
 public function test(CmsPage $cmsPage)
 {
     // Preconditions
     $cmsPage->persist();
     // Steps
     $this->cmsIndex->open();
     $this->cmsIndex->getCmsPageGridBlock()->searchAndOpen(['title' => $cmsPage->getTitle()]);
     $this->cmsEdit->getPageMainActions()->deleteAndAcceptAlert();
 }
 /**
  * Assert that sitemap.xml file contains correct content according to dataset:
  *  - product url
  *  - category url
  *  - CMS page url
  *
  * @param CatalogProductSimple $product
  * @param CatalogCategory $category
  * @param CmsPage $cmsPage
  * @param Sitemap $sitemap
  * @param SitemapIndex $sitemapIndex
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, CatalogCategory $category, CmsPage $cmsPage, Sitemap $sitemap, SitemapIndex $sitemapIndex)
 {
     $sitemapIndex->open()->getSitemapGrid()->sortGridByField('sitemap_id');
     $filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath()];
     $sitemapIndex->getSitemapGrid()->search($filter);
     $content = file_get_contents($sitemapIndex->getSitemapGrid()->getLinkForGoogle());
     $frontendUrl = str_replace('index.php/', '', $_ENV['app_frontend_url']);
     $urls = [$frontendUrl . $product->getUrlKey() . '.html', $frontendUrl . $category->getUrlKey() . '.html', $frontendUrl . $cmsPage->getIdentifier()];
     \PHPUnit_Framework_Assert::assertTrue($this->checkContent($content, $urls), "File '{$sitemap->getSitemapFilename()}' does not contains correct content.");
 }
 /**
  * Assert that link to Currently Published Revision on CMS Page Information Form is available.
  *
  * @param CmsRevisionEdit $cmsRevisionEdit
  * @param CmsPage $cms
  * @param CmsPageEdit $cmsPageEdit
  * @param CmsPageIndex $cmsPageIndex
  * @param array $results
  * @param Revision|null $revision [optional]
  * @return void
  */
 public function processAssert(CmsRevisionEdit $cmsRevisionEdit, CmsPage $cms, CmsPageEdit $cmsPageEdit, CmsPageIndex $cmsPageIndex, array $results, Revision $revision = null)
 {
     $filter = ['title' => $cms->getTitle()];
     $cmsPageIndex->open();
     $cmsPageIndex->getCmsPageGridBlock()->searchAndOpen($filter);
     $formPublishedRevision = $cmsPageEdit->getPageVersionsForm()->getCurrentlyPublishedRevisionText();
     \PHPUnit_Framework_Assert::assertEquals($cms->getTitle() . '; ' . $results['revision'], $formPublishedRevision, 'Link to Currently Published Revision not equals to passed in fixture.');
     $cmsPageEdit->getPageVersionsForm()->clickCurrentlyPublishedRevision();
     $formRevisionData = $cmsRevisionEdit->getRevisionForm()->getTabElement('content')->getContentData();
     $fixtureRevisionData['revision'] = $results['revisionKey'];
     $fixtureRevisionData['version'] = $cms->getTitle();
     $fixtureRevisionData['content'] = $revision !== null ? ['content' => $revision->getContent()] : $cms->getContent();
     $error = $this->verifyData($fixtureRevisionData, $formRevisionData);
     \PHPUnit_Framework_Assert::assertEmpty($error, $error);
 }
 /**
  * Assert that content of created cms page displayed in main content section and equals passed from fixture.
  *
  * @param CmsPage $cms
  * @param CmsPageIndex $cmsPageIndex
  * @param FrontendCmsPage $frontendCmsPage
  * @param CmsPageEdit $cmsPageEdit
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CmsPage $cms, CmsPageIndex $cmsPageIndex, FrontendCmsPage $frontendCmsPage, CmsPageEdit $cmsPageEdit, Browser $browser)
 {
     $cmsPageIndex->open();
     $cmsPageIndex->getCmsPageGridBlock()->searchAndOpen(['title' => $cms->getTitle()]);
     $cmsPageEdit->getPageMainActions()->preview();
     $browser->selectWindow();
     $frontendCmsPage->getTemplateBlock()->waitLoader();
     $browser->switchToFrame(new Locator($this->iFrameSelector));
     $element = $browser->find('body');
     $fixtureContent = $cms->getContent();
     \PHPUnit_Framework_Assert::assertContains($fixtureContent['content'], $frontendCmsPage->getCmsPageContentBlock()->getPageContent($element), 'Wrong content is displayed.');
     if ($cms->getContentHeading()) {
         \PHPUnit_Framework_Assert::assertEquals(strtolower($cms->getContentHeading()), strtolower($frontendCmsPage->getCmsPageContentBlock()->getPageTitle($element)), 'Wrong title is displayed.');
     }
     if (isset($fixtureContent['widget'])) {
         foreach ($fixtureContent['widget']['preset'] as $widget) {
             \PHPUnit_Framework_Assert::assertTrue($frontendCmsPage->getCmsPageContentBlock()->isWidgetVisible($widget), "Widget '{$widget['widget_type']}' is not displayed.");
         }
     }
 }
 /**
  * Assert that content of created cms page displayed in main content section and equals passed from fixture.
  *
  * @param CmsPage $cms
  * @param CmsPageIndex $cmsPageIndex
  * @param FrontendCmsPage $frontendCmsPage
  * @param Browser $browser
  * @param bool $isIFrame [optional]
  * @return void
  */
 public function processAssert(CmsPage $cms, CmsPageIndex $cmsPageIndex, FrontendCmsPage $frontendCmsPage, Browser $browser, $isIFrame = false)
 {
     $cmsPageIndex->open();
     $cmsPageIndex->getCmsPageGridBlock()->searchAndReview(['title' => $cms->getTitle()]);
     $browser->selectWindow();
     if ($isIFrame) {
         $this->switchToFrame($browser);
     }
     $element = $browser->find('body');
     $fixtureContent = $cms->getContent();
     \PHPUnit_Framework_Assert::assertContains($fixtureContent['content'], $frontendCmsPage->getCmsPageContentBlock()->getPageContent($element), 'Wrong content is displayed.');
     if ($cms->getContentHeading()) {
         \PHPUnit_Framework_Assert::assertEquals(strtolower($cms->getContentHeading()), strtolower($frontendCmsPage->getCmsPageContentBlock()->getPageTitle($element)), 'Wrong title is displayed.');
     }
     if (isset($fixtureContent['widget'])) {
         foreach ($fixtureContent['widget']['preset'] as $widget) {
             \PHPUnit_Framework_Assert::assertTrue($frontendCmsPage->getCmsPageContentBlock()->isWidgetVisible($widget), "Widget '{$widget['widget_type']}' is not displayed.");
         }
     }
     $browser->closeWindow();
     $browser->selectWindow();
     $browser->switchToFrame();
 }
 /**
  * Delete store.
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->cms instanceof CmsPage) {
         return;
     }
     $stores = $this->cms->getStoreId();
     if ($stores) {
         $stores = $this->cms->getDataFieldConfig('store_id')['source']->getStore();
         foreach ($stores as $store) {
             $this->storeIndex->open();
             $this->storeIndex->getStoreGrid()->openStore($store);
             $this->editStore->getFormPageActions()->delete();
             $this->deleteStore->getFormPageActions()->delete();
         }
     }
 }
 /**
  * Assert that created CMS page with status "disabled" displays with error message on frontend.
  *
  * @param CmsPage $cms
  * @param FrontendCmsPage $frontendCmsPage
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CmsPage $cms, FrontendCmsPage $frontendCmsPage, Browser $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $cms->getIdentifier());
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $frontendCmsPage->getCmsPageContentBlock()->getPageHeadTitle(), 'Wrong page is displayed.');
 }
Esempio n. 11
0
 /**
  * Assert that cms page is present in pages grid.
  *
  * @param CmsPage $cms
  * @param CmsPageIndex $cmsPageIndex
  * @return void
  */
 public function processAssert(CmsPage $cms, CmsPageIndex $cmsPageIndex)
 {
     $cmsPageIndex->open();
     $cmsTitle = $cms->getTitle();
     \PHPUnit_Framework_Assert::assertTrue($cmsPageIndex->getCmsPageGridBlock()->isRowVisible(['title' => $cmsTitle]), "Cms page '{$cmsTitle}' is not present in pages grid.");
 }
 /**
  * Assert that created CMS page displays with error message on unassigned store views on frontend.
  *
  * @param CmsPage $cms
  * @param FrontendCmsPage $frontendCmsPage
  * @param Browser $browser
  * @param CmsIndex $cmsIndex
  * @return void
  */
 public function processAssert(CmsPage $cms, FrontendCmsPage $frontendCmsPage, Browser $browser, CmsIndex $cmsIndex)
 {
     $browser->open($_ENV['app_frontend_url'] . $cms->getIdentifier());
     $cmsIndex->getHeaderBlock()->selectStore('Default Store View');
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $frontendCmsPage->getCmsPageContentBlock()->getPageHeadTitle(), 'Wrong page content is displayed.');
 }
 /**
  * Run publish cms page revision test.
  *
  * @param CmsPage $cms
  * @param Revision $revision
  * @param int $initialRevision
  * @param int $revisionId
  * @return void
  */
 public function test(CmsPage $cms, Revision $revision, $initialRevision, $revisionId)
 {
     // Steps
     $this->cmsPageIndex->open();
     $title = $cms->getTitle();
     $this->cmsPageIndex->getCmsPageGridBlock()->searchAndOpen(['title' => $title]);
     $this->cmsPageEdit->getPageVersionsForm()->openTab('versions');
     $filter = ['label' => $title];
     $revisionGrid = $this->cmsVersionEdit->getRevisionsGrid();
     $revisionForm = $this->cmsRevisionEdit->getRevisionForm();
     $this->cmsPageEdit->getPageVersionsForm()->getTabElement('versions')->getVersionsGrid()->searchAndOpen($filter);
     $revisionGrid->searchAndOpen(['revision_number_from' => $revisionId]);
     $revisionForm->toggleEditor();
     $revisionForm->fill($revision);
     $this->cmsRevisionEdit->getFormPageActions()->save();
     $filter = ['revision_number_from' => $initialRevision, 'revision_number_to' => $initialRevision];
     $revisionGrid->searchAndOpen($filter);
     $this->cmsRevisionEdit->getFormPageActions()->publish();
 }
 /**
  * Generate sitemap test.
  *
  * @param Sitemap $sitemap
  * @param CatalogProductSimple $product
  * @param CatalogCategory $category
  * @param CmsPage $cmsPage
  * @return void
  */
 public function test(Sitemap $sitemap, CatalogProductSimple $product, CatalogCategory $category, CmsPage $cmsPage)
 {
     // Preconditions
     $product->persist();
     $category->persist();
     $cmsPage->persist();
     // Steps
     $this->sitemapIndex->open();
     $this->sitemapIndex->getGridPageActions()->addNew();
     $this->sitemapNew->getSitemapForm()->fill($sitemap);
     $this->sitemapNew->getFormPageActions()->saveAndGenerate();
 }
 /**
  * Update CMS Page test.
  *
  * @param CmsPage $cms
  * @param CmsPage $cmsOriginal
  * @return array
  */
 public function test(CmsPage $cms, CmsPage $cmsOriginal)
 {
     // Steps
     $this->cmsIndex->open();
     $filter = ['title' => $cmsOriginal->getTitle()];
     $this->cmsIndex->getCmsPageGridBlock()->searchAndOpen($filter);
     $this->cmsEdit->getPageForm()->fill($cms);
     $this->cmsEdit->getPageMainActions()->save();
     return ['cms' => $this->factory->createByCode('cmsPage', ['data' => array_merge($cmsOriginal->getData(), $cms->getData())])];
 }
 /**
  * Assert that CMS page cann't be found in grid via:
  * - Page title type
  * - Url Key
  * - Status
  *
  * @param CmsPageIndex $cmsIndex
  * @param CmsPage $cmsPage
  * @return void
  */
 public function processAssert(CmsPageIndex $cmsIndex, CmsPage $cmsPage)
 {
     $cmsIndex->open();
     $filter = ['title' => $cmsPage->getTitle(), 'identifier' => $cmsPage->getIdentifier(), 'is_active' => $cmsPage->getIsActive()];
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getCmsPageGridBlock()->isRowVisible($filter), "Cms page {$cmsPage->getTitle()} is present in pages 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];
 }