Skip to content

Commit 99e81ca

Browse files
committed
Add test for autocomplete limit
1 parent 86b5442 commit 99e81ca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

app/code/Magento/CatalogSearch/Test/Unit/Model/Autocomplete/DataProviderTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase
3030
*/
3131
private $suggestCollection;
3232

33+
/**
34+
* @var integer
35+
*/
36+
private $limit = 3;
37+
3338
protected function setUp()
3439
{
3540
$helper = new ObjectManager($this);
@@ -60,11 +65,20 @@ protected function setUp()
6065
->setMethods(['create'])
6166
->getMock();
6267

68+
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
69+
->setMethods(['getValue'])
70+
->disableOriginalConstructor()
71+
->getMockForAbstractClass();
72+
$scopeConfig->expects($this->any())
73+
->method('getValue')
74+
->willReturn($this->limit);
75+
6376
$this->model = $helper->getObject(
6477
\Magento\CatalogSearch\Model\Autocomplete\DataProvider::class,
6578
[
6679
'queryFactory' => $queryFactory,
67-
'itemFactory' => $this->itemFactory
80+
'itemFactory' => $this->itemFactory,
81+
'scopeConfig' => $scopeConfig
6882
]
6983
);
7084
}
@@ -103,8 +117,10 @@ public function testGetItems()
103117
->will($this->returnValue($expected));
104118

105119
$this->itemFactory->expects($this->any())->method('create')->willReturn($itemMock);
120+
106121
$result = $this->model->getItems();
107122
$this->assertEquals($expected, $result[0]->toArray());
123+
$this->assertEquals($this->limit, count($result));
108124
}
109125

110126
private function buildCollection(array $data)

0 commit comments

Comments
 (0)