/**
  * 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 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);
 }
 /**
  * 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 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.");
         }
     }
 }
 /**
  * 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();
 }