/**
  * Assert that sitemap.xml file contains correct content according to dataset:
  *  - product url
  *  - category url
  *  - CMS page url
  *
  * @param CatalogProductSimple $product
  * @param Category $catalog
  * @param CmsPage $cmsPage
  * @param Sitemap $sitemap
  * @param SitemapIndex $sitemapIndex
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, Category $catalog, 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());
     $urls = [$_ENV['app_frontend_url'] . $product->getUrlKey() . '.html', $_ENV['app_frontend_url'] . $catalog->getUrlKey() . '.html', $_ENV['app_frontend_url'] . $cmsPage->getIdentifier()];
     \PHPUnit_Framework_Assert::assertTrue($this->checkContent($content, $urls), 'Content of file sitemap.xml does not include one or more of next urls:' . implode("\n", $urls));
 }
 /**
  * @param Sitemap $sitemap
  */
 public function testDeleteSitemap(Sitemap $sitemap)
 {
     // Preconditions
     $sitemap->persist();
     $filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath(), 'sitemap_id' => $sitemap->getSitemapId()];
     // Steps
     $this->sitemapIndex->open();
     $this->sitemapIndex->getSitemapGrid()->searchAndOpen($filter);
     $this->sitemapEdit->getFormPageActions()->delete();
 }
 /**
  * Update Sitemap Entity
  *
  * @param Sitemap $sitemap
  * @param CatalogProductSimple $product
  * @param CatalogCategory $catalog
  * @param CmsPage $cmsPage
  * @return void
  */
 public function testUpdateSitemap(Sitemap $sitemap, CatalogProductSimple $product, CatalogCategory $catalog, CmsPage $cmsPage)
 {
     // Preconditions
     $sitemap->persist();
     $product->persist();
     $catalog->persist();
     $cmsPage->persist();
     $filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath(), 'sitemap_id' => $sitemap->getSitemapId()];
     // Steps
     $this->sitemapIndex->open()->getSitemapGrid()->search($filter);
     $this->sitemapIndex->getSitemapGrid()->generate();
 }
 /**
  * Assert that sitemap availability 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 with filename \'' . $sitemap->getSitemapFilename() . '\' and path \'' . $sitemap->getSitemapPath() . '\' is absent in Sitemap grid. \'');
 }
 /**
  * Assert that success messages is 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), 'Wrong success messages is displayed.' . "\nExpected: " . sprintf(self::SUCCESS_GENERATE_MESSAGE, $sitemap->getSitemapFilename()) . "\nExpected: " . self::SUCCESS_SAVE_MESSAGE . "\nActual messages: " . implode("\n", $actualMessages));
 }
 /**
  * Assert that success message is displayed after sitemap generate
  *
  * @param SitemapIndex $sitemapPage
  * @param Sitemap $sitemap
  * @return void
  */
 public function processAssert(SitemapIndex $sitemapPage, Sitemap $sitemap)
 {
     $actualMessage = $sitemapPage->getMessagesBlock()->getSuccessMessages();
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::SUCCESS_GENERATE_MESSAGE, $sitemap->getSitemapFilename()), $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . sprintf(self::SUCCESS_GENERATE_MESSAGE, $sitemap->getSitemapFilename()) . "\nActual: " . $actualMessage);
 }
 /**
  * Assert that sitemap not availability in sitemap grid
  *
  * @param Sitemap $sitemap
  * @param SitemapIndex $sitemapPageGrid
  * @return void
  */
 public function processAssert(Sitemap $sitemap, SitemapIndex $sitemapPageGrid)
 {
     $sitemapPageGrid->open();
     $filter = ['sitemap_filename' => $sitemap->getSitemapFilename(), 'sitemap_path' => $sitemap->getSitemapPath(), 'sitemap_id' => $sitemap->getSitemapId()];
     \PHPUnit_Framework_Assert::assertFalse($sitemapPageGrid->getSitemapGrid()->isRowVisible($filter), 'Sitemap with filename \'' . $sitemap->getSitemapFilename() . '\' and id \'' . $sitemap->getSitemapId() . '\' and path \'' . $sitemap->getSitemapPath() . '\' is present in Sitemap grid.');
 }
 /**
  * Assert that error message is displayed after creating sitemap with wrong path
  *
  * @param SitemapIndex $sitemapPage
  * @param Sitemap $sitemap
  * @return void
  */
 public function processAssert(SitemapIndex $sitemapPage, Sitemap $sitemap)
 {
     $actualMessage = $sitemapPage->getMessagesBlock()->getErrorMessage();
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::FAIL_PATH_MESSAGE, $sitemap->getSitemapFilename()), $actualMessage, 'Wrong error message is displayed.' . "\nExpected: " . self::FAIL_PATH_MESSAGE . "\nActual: " . $actualMessage);
 }