Skip to content

Commit d833b62

Browse files
author
Serhii Balko
committed
MC-38625: Storefront Order History product count is doubled if has more than 10 configurables
1 parent 86da4c8 commit d833b62

File tree

1 file changed

+23
-24
lines changed
  • dev/tests/integration/testsuite/Magento/Sales/Block/Order

1 file changed

+23
-24
lines changed

dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,15 @@ public function testGetOrderItems(): void
8686
*
8787
* @return void
8888
*/
89-
public function testGetOrderItemsConfigurable(): void
89+
public function testGetPagerCountConfigurable(): void
9090
{
9191
$order = $this->orderFactory->create()->loadByIncrementId('100000001');
9292
$this->registerOrder($order);
93-
$this->block = $this->layout->createBlock(Items::class);
94-
$this->assertCount(1, $this->block->getItems());
93+
$this->prepareBlockWithPager();
94+
95+
/** @var Pager $pagerBlock */
96+
$pagerBlock = $this->block->getChildBlock('sales_order_item_pager');
97+
$this->assertCount(1, $pagerBlock->getCollection()->getItems());
9598
}
9699

97100
/**
@@ -104,13 +107,7 @@ public function testPagerIsDisplayed(): void
104107
{
105108
$order = $this->orderFactory->create()->loadByIncrementId('100000001');
106109
$this->registerOrder($order);
107-
$this->block = $this->layout->createBlock(Items::class, 'items_block');
108-
$this->layout->addBlock(
109-
$this->objectManager->get(Pager::class),
110-
'sales_order_item_pager',
111-
'items_block'
112-
);
113-
$this->block->setLayout($this->layout);
110+
$this->prepareBlockWithPager();
114111
$this->assertTrue($this->block->isPagerDisplayed());
115112
}
116113

@@ -123,13 +120,7 @@ public function testPagerIsNotDisplayed(): void
123120
{
124121
$order = $this->orderFactory->create()->loadByIncrementId('100000001');
125122
$this->registerOrder($order);
126-
$this->block = $this->layout->createBlock(Items::class, 'items_block');
127-
$this->layout->addBlock(
128-
$this->objectManager->get(Pager::class),
129-
'sales_order_item_pager',
130-
'items_block'
131-
);
132-
$this->block->setLayout($this->layout);
123+
$this->prepareBlockWithPager();
133124
$this->assertFalse($this->block->isPagerDisplayed());
134125
$this->assertEmpty(preg_replace('/\s+/', '', strip_tags($this->block->getPagerHtml())));
135126
}
@@ -144,13 +135,7 @@ public function testGetPagerHtml(): void
144135
{
145136
$order = $this->orderFactory->create()->loadByIncrementId('100000001');
146137
$this->registerOrder($order);
147-
$this->block = $this->layout->createBlock(Items::class, 'items_block');
148-
$this->layout->addBlock(
149-
$this->objectManager->get(Pager::class),
150-
'sales_order_item_pager',
151-
'items_block'
152-
);
153-
$this->block->setLayout($this->layout);
138+
$this->prepareBlockWithPager();
154139
$this->assertNotEmpty(preg_replace('/\s+/', '', strip_tags($this->block->getPagerHtml())));
155140
$this->assertTrue($this->block->isPagerDisplayed());
156141
}
@@ -240,4 +225,18 @@ private function registerOrder(OrderInterface $order): void
240225
$this->registry->unregister('current_order');
241226
$this->registry->register('current_order', $order);
242227
}
228+
229+
/**
230+
* Create items block with pager
231+
*/
232+
private function prepareBlockWithPager(): void
233+
{
234+
$this->block = $this->layout->createBlock(Items::class, 'items_block');
235+
$this->layout->addBlock(
236+
$this->objectManager->get(Pager::class),
237+
'sales_order_item_pager',
238+
'items_block'
239+
);
240+
$this->block->setLayout($this->layout);
241+
}
243242
}

0 commit comments

Comments
 (0)