Skip to content

Commit 30dc698

Browse files
committed
MAGETWO-61962: Pagination broken in the storefront category page when Flat Category is enabled
1 parent 0061fa8 commit 30dc698

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Constraint;
8+
9+
use Magento\Mtf\Client\BrowserInterface;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Catalog\Test\Fixture\Category;
12+
13+
class AssertPaginationCorrectOnStoreFront extends AbstractConstraint
14+
{
15+
/* tags */
16+
const SEVERITY = 'low';
17+
/* end tags */
18+
19+
/**
20+
* @param BrowserInterface $browser
21+
* @param Category $category
22+
*/
23+
public function processAssert(BrowserInterface $browser, Category $category)
24+
{
25+
$browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
26+
}
27+
28+
/**
29+
* Return string representation of object.
30+
*
31+
* @return string
32+
*/
33+
public function toString()
34+
{
35+
return 'Attribute is visible with HTML tags on frontend.';
36+
}
37+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\TestCase\Product;
8+
9+
use Magento\Mtf\Fixture\FixtureFactory;
10+
use Magento\Mtf\TestCase\Injectable;
11+
use Magento\Catalog\Test\Fixture\Category;
12+
13+
class CreateFlatCatalogProduct extends Injectable
14+
{
15+
/* tags */
16+
const MVP = 'yes';
17+
/* end tags */
18+
19+
/**
20+
* Configuration data.
21+
*
22+
* @var string
23+
*/
24+
protected $configData;
25+
26+
/**
27+
* Factory for Fixtures.
28+
*
29+
* @var FixtureFactory
30+
*/
31+
private $fixtureFactory;
32+
33+
/**
34+
* Category fixture
35+
*
36+
* @var Category
37+
*/
38+
protected $category;
39+
40+
/**
41+
* Prepare data
42+
*
43+
* @param Category $category
44+
* @return array
45+
*/
46+
public function __prepare(Category $category)
47+
{
48+
$category->persist();
49+
return [
50+
'category' => $category
51+
];
52+
}
53+
54+
/**
55+
* Injection data
56+
*
57+
* @param Category $category
58+
* @param FixtureFactory $fixtureFactory
59+
* @return void
60+
*/
61+
public function __inject(
62+
Category $category,
63+
FixtureFactory $fixtureFactory
64+
) {
65+
$this->category = $category;
66+
$this->fixtureFactory = $fixtureFactory;
67+
}
68+
69+
/**
70+
* Run mass update product simple entity test.
71+
*
72+
* @param string $configData
73+
* @param string $productsCount
74+
* @return array
75+
*/
76+
public function test($configData, $productsCount)
77+
{
78+
$this->createBulkOfProducts($productsCount);
79+
$this->configData = $configData;
80+
return ['category' => $this->category];
81+
}
82+
83+
/**
84+
* Clear data after test.
85+
*
86+
* @return void
87+
*/
88+
public function tearDown()
89+
{
90+
$this->objectManager->create(
91+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
92+
['configData' => $this->configData, 'rollback' => true]
93+
)->run();
94+
}
95+
96+
/**
97+
* @param $productsCount
98+
*/
99+
private function createBulkOfProducts($productsCount)
100+
{
101+
foreach (range(1, $productsCount) as $element) {
102+
/**
103+
* @product FixtureInterface
104+
*/
105+
$product = $this->fixtureFactory->createByCode(
106+
'catalogProductSimple',
107+
[
108+
'dataset' => 'default',
109+
'data' => [
110+
'category_ids' => [
111+
'category' => $this->category
112+
]
113+
]
114+
]
115+
);
116+
$product->persist();
117+
}
118+
}
119+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 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\Catalog\Test\TestCase\Product\CreateFlatCatalogProduct" summary="Create flat catalog Product" ticketId="MAGETWO-67570">
10+
<variation name="CheckPaginationInStorefront">
11+
<data name="configData" xsi:type="string">category_flat,product_flat</data>
12+
<data name="productsCount" xsi:type="number">2</data>
13+
<constraint name="Magento\Catalog\Test\Constraint\AssertPaginationCorrectOnStoreFront" />
14+
</variation>
15+
</testCase>
16+
</config>

0 commit comments

Comments
 (0)