99
1010use Magento \Catalog \Api \CategoryRepositoryInterface ;
1111use 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 ;
1414use Magento \Catalog \Model \Session ;
15+ use Magento \Framework \App \Http \Context ;
1516use Magento \Framework \ObjectManagerInterface ;
1617use Magento \Framework \Registry ;
1718use Magento \Framework \View \LayoutInterface ;
19+ use Magento \TestFramework \Catalog \Model \CategoryLayoutUpdateManager ;
20+ use Magento \TestFramework \Helper \Bootstrap ;
1821use Magento \TestFramework \TestCase \AbstractController ;
1922
2023/**
@@ -45,6 +48,11 @@ class CategoryTest extends AbstractController
4548 */
4649 private $ layout ;
4750
51+ /**
52+ * @var Context
53+ */
54+ private $ httpContext ;
55+
4856 /**
4957 * @inheritdoc
5058 */
@@ -54,14 +62,12 @@ protected function setUp(): void
5462
5563 $ this ->objectManager = Bootstrap::getObjectManager ();
5664 $ 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]
6166 ]);
6267 $ this ->registry = $ this ->objectManager ->get (Registry::class);
6368 $ this ->layout = $ this ->objectManager ->get (LayoutInterface::class);
6469 $ this ->session = $ this ->objectManager ->get (Session::class);
70+ $ this ->httpContext = $ this ->objectManager ->get (Context::class);
6571 }
6672
6773 /**
@@ -205,4 +211,26 @@ public function testViewWithCustomUpdate(): void
205211 ->getHandles ();
206212 $ this ->assertContains ("catalog_category_view_selectable_ {$ categoryId }_ {$ file }" , $ handles );
207213 }
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+ }
208236}
0 commit comments