Skip to content

Commit a170f6a

Browse files
MTO-109: [Variation] Create and use XML Sitemap with submission to Robots.txt
2 parents 54ef5f4 + ba9fc39 commit a170f6a

File tree

22 files changed

+683
-25
lines changed

22 files changed

+683
-25
lines changed

app/code/Magento/Braintree/Model/Ui/ConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Class ConfigProvider
1515
*/
16-
final class ConfigProvider implements ConfigProviderInterface
16+
class ConfigProvider implements ConfigProviderInterface
1717
{
1818
const CODE = 'braintree';
1919

app/code/Magento/Vault/Model/Method/Vault.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
2929
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3030
*/
31-
final class Vault implements VaultPaymentInterface
31+
class Vault implements VaultPaymentInterface
3232
{
3333
/**
3434
* @deprecated

app/code/Magento/Vault/Model/Ui/Adminhtml/TokensConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @api
2828
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2929
*/
30-
final class TokensConfigProvider
30+
class TokensConfigProvider
3131
{
3232
/**
3333
* @var PaymentTokenRepositoryInterface

app/code/Magento/Vault/Model/Ui/TokensConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Class ConfigProvider
1616
* @api
1717
*/
18-
final class TokensConfigProvider implements ConfigProviderInterface
18+
class TokensConfigProvider implements ConfigProviderInterface
1919
{
2020
/**
2121
* @var string
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sitemap\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
12+
/**
13+
* Assert that robots.txt file is available and contains correct content.
14+
*/
15+
class AssertSitemapSubmissionToRobotsTxt extends AbstractConstraint
16+
{
17+
/**
18+
* Error HTTP response code.
19+
*/
20+
const HTTP_NOT_FOUND = '404 Not Found';
21+
22+
/**
23+
* File path for "Robots txt".
24+
*
25+
* @var string
26+
*/
27+
private $filename = 'robots.txt';
28+
29+
/**
30+
* Assert that robots.txt is available and contains correct data.
31+
*
32+
* @param BrowserInterface $browser
33+
* @return void
34+
*/
35+
public function processAssert(BrowserInterface $browser)
36+
{
37+
$browser->open($_ENV['app_frontend_url'] . $this->filename);
38+
\PHPUnit_Framework_Assert::assertNotEquals(
39+
self::HTTP_NOT_FOUND,
40+
$browser->getTitle(),
41+
'File ' . $this->filename . ' is not readable or not exists.'
42+
);
43+
44+
$expectedRobotsContent = 'Sitemap: ' . $_ENV['app_frontend_url'] . 'sitemap.xml';
45+
\PHPUnit_Framework_Assert::assertTrue(
46+
strpos($browser->getHtmlSource(), $expectedRobotsContent) !== false,
47+
'File ' . $this->filename . ' contains incorrect data.'
48+
);
49+
}
50+
51+
/**
52+
* Returns a string representation of the object.
53+
*
54+
* @return string
55+
*/
56+
public function toString()
57+
{
58+
return 'File ' . $this->filename . ' contains correct content.';
59+
}
60+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9+
<repository class="Magento\Config\Test\Repository\ConfigData">
10+
<dataset name="enable_submission_to_robots">
11+
<field name="sitemap/search_engines/submission_robots" xsi:type="array">
12+
<item name="scope_id" xsi:type="number">0</item>
13+
<item name="label" xsi:type="string">Yes</item>
14+
<item name="value" xsi:type="number">1</item>
15+
</field>
16+
</dataset>
17+
18+
<dataset name="enable_submission_to_robots_rollback">
19+
<field name="sitemap/search_engines/submission_robots" xsi:type="array">
20+
<item name="scope" xsi:type="string">default</item>
21+
<item name="scope_id" xsi:type="number">1</item>
22+
<item name="label" xsi:type="string">No</item>
23+
<item name="value" xsi:type="number">0</item>
24+
</field>
25+
</dataset>
26+
</repository>
27+
</config>
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sitemap\Test\TestCase;
8+
9+
use Magento\Catalog\Test\Fixture\Category;
10+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
11+
use Magento\Cms\Test\Fixture\CmsPage;
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+
18+
/**
19+
* Cover generating Sitemap Entity
20+
*
21+
* Test Flow:
22+
* Preconditions:
23+
* 1. Create category.
24+
* 2. Create simple product.
25+
* 3. Create CMS page.
26+
* 4. Set configurations.
27+
* Steps:
28+
* 1. Log in as admin user from data set.
29+
* 2. Navigate to Marketing > SEO and Search > Site Map.
30+
* 3. Click "Add Sitemap" button.
31+
* 4. Fill out all data according to data set.
32+
* 5. Click "Save" button.
33+
* 6. Perform all assertions.
34+
*
35+
* @group XML_Sitemap
36+
* @ZephyrId MAGETWO-25124
37+
*/
38+
class GenerateSitemapEntityTest extends Injectable
39+
{
40+
/* tags */
41+
const MVP = 'no';
42+
const SEVERITY = 'S1';
43+
/* end tags */
44+
45+
/**
46+
* Step factory.
47+
*
48+
* @var TestStepFactory
49+
*/
50+
private $stepFactory;
51+
52+
/**
53+
* Sitemap grid page
54+
*
55+
* @var SitemapIndex
56+
*/
57+
protected $sitemapIndex;
58+
59+
/**
60+
* Sitemap new page
61+
*
62+
* @var SitemapNew
63+
*/
64+
protected $sitemapNew;
65+
66+
/**
67+
* Configuration setting.
68+
*
69+
* @var string
70+
*/
71+
private $configData;
72+
73+
/**
74+
* Inject data
75+
*
76+
* @param SitemapIndex $sitemapIndex
77+
* @param SitemapNew $sitemapNew
78+
* @param TestStepFactory $stepFactory
79+
* @return void
80+
*/
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+
91+
/**
92+
* Generate Sitemap Entity
93+
*
94+
* @param Sitemap $sitemap
95+
* @param CatalogProductSimple $product
96+
* @param Category $catalog
97+
* @param CmsPage $cmsPage
98+
* @param null|string $configData
99+
* @return void
100+
*/
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+
129+
/**
130+
* Set default configuration.
131+
*
132+
* @return void
133+
*/
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+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Sitemap\Test\TestCase\GenerateSitemapEntityTest" summary="Generate Sitemap" ticketId="MAGETWO-25124">
10+
<variation name="GenerateSitemapEntityTestVariation1">
11+
<data name="tag" xsi:type="string">stable:no, severity:S1</data>
12+
<data name="catalog/dataset" xsi:type="string">default_subcategory</data>
13+
<data name="product/dataset" xsi:type="string">default</data>
14+
<data name="cmsPage/dataset" xsi:type="string">default</data>
15+
<data name="sitemap/data/sitemap_filename" xsi:type="string">sitemap.xml</data>
16+
<data name="sitemap/data/sitemap_path" xsi:type="string">/</data>
17+
<constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapSuccessSaveAndGenerateMessages" />
18+
<constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapContent" />
19+
<constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapInGrid" />
20+
</variation>
21+
<variation name="GenerateSitemapEntityTestVariation2" summary="Generate Sitemap with submission to Robots.txt" ticketId="MAGETWO-12410">
22+
<data name="catalog/dataset" xsi:type="string">default_subcategory</data>
23+
<data name="product/dataset" xsi:type="string">default</data>
24+
<data name="cmsPage/dataset" xsi:type="string">default</data>
25+
<data name="sitemap/data/sitemap_filename" xsi:type="string">sitemap.xml</data>
26+
<data name="sitemap/data/sitemap_path" xsi:type="string">/</data>
27+
<data name="configData" xsi:type="string">enable_submission_to_robots</data>
28+
<constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapSuccessSaveAndGenerateMessages" />
29+
<constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapSubmissionToRobotsTxt" />
30+
</variation>
31+
</testCase>
32+
</config>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sitemap\Test\TestCase;
8+
9+
use Magento\Catalog\Test\Fixture\Category;
10+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
11+
use Magento\Cms\Test\Fixture\CmsPage;
12+
use Magento\Sitemap\Test\Fixture\Sitemap;
13+
use Magento\Sitemap\Test\Page\Adminhtml\SitemapIndex;
14+
use Magento\Mtf\TestCase\Injectable;
15+
16+
/**
17+
* Cover updating Sitemap Entity
18+
*
19+
* Test Flow:
20+
* Preconditions:
21+
* 1. Generate sitemap
22+
* 2. Create category
23+
* 3. Create simple product
24+
* 4. Create CMS page
25+
* Steps:
26+
* 1. Login as Admin User
27+
* 2. Go to Marketing > SEO & Search: Site Map
28+
* 3. Click 'Generate' In the grid for sitemap from preconditions
29+
* 4. Perform all assertions
30+
*
31+
* @group XML_Sitemap
32+
* @ZephyrId MAGETWO-25362
33+
*/
34+
class UpdateSitemapEntityTest extends Injectable
35+
{
36+
/* tags */
37+
const MVP = 'no';
38+
const SEVERITY = 'S1';
39+
/* end tags */
40+
41+
/**
42+
* Sitemap grid page
43+
*
44+
* @var SitemapIndex
45+
*/
46+
protected $sitemapIndex;
47+
48+
/**
49+
* Inject data
50+
*
51+
* @param SitemapIndex $sitemapIndex
52+
* @return void
53+
*/
54+
public function __inject(SitemapIndex $sitemapIndex)
55+
{
56+
$this->sitemapIndex = $sitemapIndex;
57+
}
58+
59+
/**
60+
* Update Sitemap Entity
61+
*
62+
* @param Sitemap $sitemap
63+
* @param CatalogProductSimple $product
64+
* @param Category $catalog
65+
* @param CmsPage $cmsPage
66+
* @return void
67+
*/
68+
public function testUpdateSitemap(
69+
Sitemap $sitemap,
70+
CatalogProductSimple $product,
71+
Category $catalog,
72+
CmsPage $cmsPage
73+
) {
74+
// Preconditions
75+
$sitemap->persist();
76+
$product->persist();
77+
$catalog->persist();
78+
$cmsPage->persist();
79+
$filter = [
80+
'sitemap_filename' => $sitemap->getSitemapFilename(),
81+
'sitemap_path' => $sitemap->getSitemapPath(),
82+
'sitemap_id' => $sitemap->getSitemapId(),
83+
];
84+
85+
// Steps
86+
$this->sitemapIndex->open()->getSitemapGrid()->search($filter);
87+
$this->sitemapIndex->getSitemapGrid()->generate();
88+
}
89+
}

0 commit comments

Comments
 (0)