@@ -30,6 +30,11 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase
30
30
*/
31
31
private $ suggestCollection ;
32
32
33
+ /**
34
+ * @var integer
35
+ */
36
+ private $ limit = 3 ;
37
+
33
38
protected function setUp ()
34
39
{
35
40
$ helper = new ObjectManager ($ this );
@@ -60,11 +65,20 @@ protected function setUp()
60
65
->setMethods (['create ' ])
61
66
->getMock ();
62
67
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
+
63
76
$ this ->model = $ helper ->getObject (
64
77
\Magento \CatalogSearch \Model \Autocomplete \DataProvider::class,
65
78
[
66
79
'queryFactory ' => $ queryFactory ,
67
- 'itemFactory ' => $ this ->itemFactory
80
+ 'itemFactory ' => $ this ->itemFactory ,
81
+ 'scopeConfig ' => $ scopeConfig
68
82
]
69
83
);
70
84
}
@@ -103,8 +117,10 @@ public function testGetItems()
103
117
->will ($ this ->returnValue ($ expected ));
104
118
105
119
$ this ->itemFactory ->expects ($ this ->any ())->method ('create ' )->willReturn ($ itemMock );
120
+
106
121
$ result = $ this ->model ->getItems ();
107
122
$ this ->assertEquals ($ expected , $ result [0 ]->toArray ());
123
+ $ this ->assertEquals ($ this ->limit , count ($ result ));
108
124
}
109
125
110
126
private function buildCollection (array $ data )
0 commit comments