9
9
10
10
use Magento \Catalog \Api \CategoryRepositoryInterface ;
11
11
use Magento \Catalog \Model \Category ;
12
- use Magento \TestFramework \ Catalog \Model \CategoryLayoutUpdateManager ;
13
- use Magento \TestFramework \ Helper \ Bootstrap ;
12
+ use Magento \Catalog \Model \Category \ Attribute \ LayoutUpdateManager ;
13
+ use Magento \Catalog \ Model \ Product \ ProductList \ Toolbar as ToolbarModel ;
14
14
use Magento \Catalog \Model \Session ;
15
+ use Magento \Framework \App \Http \Context ;
15
16
use Magento \Framework \ObjectManagerInterface ;
16
17
use Magento \Framework \Registry ;
17
18
use Magento \Framework \View \LayoutInterface ;
19
+ use Magento \TestFramework \Catalog \Model \CategoryLayoutUpdateManager ;
20
+ use Magento \TestFramework \Helper \Bootstrap ;
18
21
use Magento \TestFramework \TestCase \AbstractController ;
19
22
20
23
/**
@@ -45,6 +48,11 @@ class CategoryTest extends AbstractController
45
48
*/
46
49
private $ layout ;
47
50
51
+ /**
52
+ * @var Context
53
+ */
54
+ private $ httpContext ;
55
+
48
56
/**
49
57
* @inheritdoc
50
58
*/
@@ -54,14 +62,12 @@ protected function setUp(): void
54
62
55
63
$ this ->objectManager = Bootstrap::getObjectManager ();
56
64
$ this ->objectManager ->configure ([
57
- 'preferences ' => [
58
- \Magento \Catalog \Model \Category \Attribute \LayoutUpdateManager::class
59
- => \Magento \TestFramework \Catalog \Model \CategoryLayoutUpdateManager::class
60
- ]
65
+ 'preferences ' => [LayoutUpdateManager::class => CategoryLayoutUpdateManager::class]
61
66
]);
62
67
$ this ->registry = $ this ->objectManager ->get (Registry::class);
63
68
$ this ->layout = $ this ->objectManager ->get (LayoutInterface::class);
64
69
$ this ->session = $ this ->objectManager ->get (Session::class);
70
+ $ this ->httpContext = $ this ->objectManager ->get (Context::class);
65
71
}
66
72
67
73
/**
@@ -205,4 +211,26 @@ public function testViewWithCustomUpdate(): void
205
211
->getHandles ();
206
212
$ this ->assertContains ("catalog_category_view_selectable_ {$ categoryId }_ {$ file }" , $ handles );
207
213
}
214
+
215
+ /**
216
+ * Checks that pagination value can be changed to a new one if remember pagination enabled and already have saved
217
+ * some value
218
+ *
219
+ * @magentoDataFixture Magento/Catalog/_files/category.php
220
+ * @magentoConfigFixture default/catalog/frontend/remember_pagination 1
221
+ *
222
+ * @return void
223
+ */
224
+ public function testViewWithRememberPaginationAndPreviousValue (): void
225
+ {
226
+ $ this ->session ->setData (ToolbarModel::LIMIT_PARAM_NAME , 16 );
227
+ $ newPaginationValue = 24 ;
228
+ $ this ->getRequest ()->setParams ([ToolbarModel::LIMIT_PARAM_NAME => $ newPaginationValue ]);
229
+ $ this ->dispatch ("catalog/category/view/id/333 " );
230
+ $ block = $ this ->layout ->getBlock ('product_list_toolbar ' );
231
+ $ this ->assertNotFalse ($ block );
232
+ $ this ->assertEquals ($ newPaginationValue , $ block ->getLimit ());
233
+ $ this ->assertEquals ($ newPaginationValue , $ this ->session ->getData (ToolbarModel::LIMIT_PARAM_NAME ));
234
+ $ this ->assertEquals ($ newPaginationValue , $ this ->httpContext ->getValue (ToolbarModel::LIMIT_PARAM_NAME ));
235
+ }
208
236
}
0 commit comments