@@ -97,51 +97,63 @@ public function testBuild(): void
9797 $ filter = $ this ->createMock (Filter::class);
9898
9999 $ searchCriteria = $ this ->getMockBuilder (SearchCriteriaInterface::class)
100- ->disableOriginalConstructor ()
101- ->getMockForAbstractClass ();
100+ ->disableOriginalConstructor ()
101+ ->getMockForAbstractClass ();
102102 $ attributeInterface = $ this ->getMockBuilder (Attribute::class)
103- ->disableOriginalConstructor ()
104- ->getMockForAbstractClass ();
103+ ->disableOriginalConstructor ()
104+ ->getMockForAbstractClass ();
105105
106106 $ attributeInterface ->setData (['is_filterable ' => 0 ]);
107107
108108 $ this ->builder ->expects ($ this ->any ())
109- ->method ('build ' )
110- ->with ('products ' , $ args )
111- ->willReturn ($ searchCriteria );
109+ ->method ('build ' )
110+ ->with ('products ' , $ args )
111+ ->willReturn ($ searchCriteria );
112112 $ searchCriteria ->expects ($ this ->any ())->method ('getFilterGroups ' )->willReturn ([]);
113113 $ this ->eavConfig ->expects ($ this ->any ())
114- ->method ('getAttribute ' )
115- ->with (Product::ENTITY , 'price ' )
116- ->willReturn ($ attributeInterface );
117-
118- $ this ->sortOrderBuilder ->expects ($ this ->once ())
119- ->method ('setField ' )
120- ->with ('_id ' )
121- ->willReturnSelf ();
122- $ this ->sortOrderBuilder ->expects ($ this ->once ())
123- ->method ('setDirection ' )
124- ->with ('DESC ' )
125- ->willReturnSelf ();
126- $ this ->sortOrderBuilder ->expects ($ this ->any ())
127- ->method ('create ' )
128- ->willReturn ([]);
129-
130- $ this ->filterBuilder ->expects ($ this ->once ())
131- ->method ('setField ' )
132- ->with ('visibility ' )
133- ->willReturnSelf ();
134- $ this ->filterBuilder ->expects ($ this ->once ())
135- ->method ('setValue ' )
136- ->with ("" )
137- ->willReturnSelf ();
138- $ this ->filterBuilder ->expects ($ this ->once ())
139- ->method ('setConditionType ' )
140- ->with ('in ' )
141- ->willReturnSelf ();
142-
143- $ this ->filterBuilder ->expects ($ this ->once ())->method ('create ' )->willReturn ($ filter );
144-
114+ ->method ('getAttribute ' )
115+ ->with (Product::ENTITY , 'price ' )
116+ ->willReturn ($ attributeInterface );
117+ $ sortOrderList = ['relevance ' ,'_id ' ];
118+ $ sortIncrementIndex = 0 ;
119+ foreach ($ sortOrderList as $ sortList ) {
120+ $ this ->sortOrderBuilder ->expects ($ this ->at ($ sortIncrementIndex ++))
121+ ->method ('setField ' )
122+ ->with ($ sortList )
123+ ->willReturnSelf ();
124+ $ this ->sortOrderBuilder ->expects ($ this ->at ($ sortIncrementIndex ++))
125+ ->method ('setDirection ' )
126+ ->with ('DESC ' )
127+ ->willReturnSelf ();
128+ $ this ->sortOrderBuilder ->expects ($ this ->at ($ sortIncrementIndex ++))
129+ ->method ('create ' )
130+ ->willReturn ([]);
131+ }
132+ $ filterOrderList = [1 =>'search_term ' , 2 =>'visibility ' ];
133+ $ filterIncrementIndex = 0 ;
134+ foreach ($ filterOrderList as $ index => $ filterList ) {
135+ $ this ->filterBuilder ->expects ($ this ->at ($ filterIncrementIndex ++))
136+ ->method ('setField ' )
137+ ->with ($ filterList )
138+ ->willReturnSelf ();
139+ $ this ->filterBuilder ->expects ($ this ->at ($ filterIncrementIndex ++))
140+ ->method ('setValue ' )
141+ ->with ('' )
142+ ->willReturnSelf ();
143+ if ($ index ==2 ) {
144+ $ this ->filterBuilder ->expects ($ this ->at ($ filterIncrementIndex ++))
145+ ->method ('setConditionType ' )
146+ ->with ('in ' )
147+ ->willReturnSelf ();
148+ } else {
149+ $ this ->filterBuilder ->expects ($ this ->at ($ filterIncrementIndex ++))
150+ ->method ('setConditionType ' )
151+ ->with ('' )
152+ ->willReturnSelf ();
153+ }
154+
155+ $ this ->filterBuilder ->expects ($ this ->at ($ filterIncrementIndex ++))->method ('create ' )->willReturn ($ filter );
156+ }
145157 $ this ->filterGroupBuilder ->expects ($ this ->any ())
146158 ->method ('addFilter ' )
147159 ->with ($ filter )
0 commit comments