Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GenerateSitemapEntityTest.php
Go to the documentation of this file.
1 <?php
8 
12 use Magento\Sitemap\Test\Fixture\Sitemap;
13 use Magento\Sitemap\Test\Page\Adminhtml\SitemapIndex;
14 use Magento\Sitemap\Test\Page\Adminhtml\SitemapNew;
15 use Magento\Mtf\TestStep\TestStepFactory;
16 use Magento\Mtf\TestCase\Injectable;
17 
38 class GenerateSitemapEntityTest extends Injectable
39 {
40  /* tags */
41  const MVP = 'no';
42  const SEVERITY = 'S1';
43  /* end tags */
44 
50  private $stepFactory;
51 
57  protected $sitemapIndex;
58 
64  protected $sitemapNew;
65 
71  private $configData;
72 
81  public function __inject(
82  SitemapIndex $sitemapIndex,
83  SitemapNew $sitemapNew,
84  TestStepFactory $stepFactory
85  ) {
86  $this->sitemapIndex = $sitemapIndex;
87  $this->sitemapNew = $sitemapNew;
88  $this->stepFactory = $stepFactory;
89  }
90 
101  public function testGenerateSitemap(
102  Sitemap $sitemap,
103  CatalogProductSimple $product,
104  Category $catalog,
105  CmsPage $cmsPage,
106  $configData = null
107  ) {
108  $this->configData = $configData;
109 
110  // Preconditions
111  if ($this->configData !== null) {
112  $this->stepFactory->create(
113  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
114  ['configData' => $this->configData]
115  )->run();
116  }
117 
118  $product->persist();
119  $catalog->persist();
120  $cmsPage->persist();
121 
122  // Steps
123  $this->sitemapIndex->open();
124  $this->sitemapIndex->getGridPageActions()->addNew();
125  $this->sitemapNew->getSitemapForm()->fill($sitemap);
126  $this->sitemapNew->getSitemapPageActions()->saveAndGenerate();
127  }
128 
134  public function tearDown()
135  {
136  if ($this->configData !== null) {
137  $this->stepFactory->create(
138  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
139  ['configData' => $this->configData, 'rollback' => true]
140  )->run();
141  }
142  }
143 }
__inject(SitemapIndex $sitemapIndex, SitemapNew $sitemapNew, TestStepFactory $stepFactory)
testGenerateSitemap(Sitemap $sitemap, CatalogProductSimple $product, Category $catalog, CmsPage $cmsPage, $configData=null)