/**
  * Create sitemap.
  *
  * @param Sitemap $sitemap
  * @return void
  */
 public function test(Sitemap $sitemap)
 {
     // Steps
     $this->sitemapIndex->open();
     $this->sitemapIndex->getGridPageActions()->addNew();
     $this->sitemapNew->getSitemapForm()->fill($sitemap);
     $this->sitemapNew->getFormPageActions()->save();
 }
 /**
  * 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.");
 }
 /**
  * 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();
 }
 /**
  * Assert that sitemap is present in sitemap grid.
  *
  * @param Sitemap $sitemap
  * @param SitemapIndex $sitemapIndex
  * @return void
  */
 public function processAssert(Sitemap $sitemap, SitemapIndex $sitemapIndex)
 {
     $sitemapIndex->open()->getSitemapGrid()->sortGridByField('sitemap_id');
     $filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath()];
     \PHPUnit_Framework_Assert::assertTrue($sitemapIndex->getSitemapGrid()->isRowVisible($filter), 'Sitemap is absent in grid.');
 }
 /**
  * Assert that success message is displayed after sitemap creation.
  *
  * @param SitemapIndex $sitemapIndex
  * @return void
  */
 public function processAssert(SitemapIndex $sitemapIndex)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $sitemapIndex->getMessagesBlock()->getSuccessMessages());
 }
 /**
  * Assert that error message is displayed after creating sitemap with wrong path.
  *
  * @param SitemapIndex $sitemapIndex
  * @param Sitemap $sitemap
  * @return void
  */
 public function processAssert(SitemapIndex $sitemapIndex, Sitemap $sitemap)
 {
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::FAIL_PATH_MESSAGE, $sitemap->getSitemapFilename()), $sitemapIndex->getMessagesBlock()->getErrorMessages());
 }
 /**
  * Assert that success messages are displayed after sitemap generate.
  *
  * @param SitemapIndex $sitemapIndex
  * @param Sitemap $sitemap
  * @return void
  */
 public function processAssert(SitemapIndex $sitemapIndex, Sitemap $sitemap)
 {
     $actualMessages = $sitemapIndex->getMessagesBlock()->getSuccessMessages();
     \PHPUnit_Framework_Assert::assertTrue(in_array(self::SUCCESS_SAVE_MESSAGE, $actualMessages) && in_array(sprintf(self::SUCCESS_GENERATE_MESSAGE, $sitemap->getSitemapFilename()), $actualMessages), "The messages about the successful sitemap creation and generation are not present.");
 }