File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
lib/internal/Magento/Framework/Search Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 77
88use Magento \Framework \App \ResourceConnection ;
99use Magento \Framework \DB \Ddl \Table ;
10+ use Magento \Framework \DB \Select ;
1011use Magento \Framework \Search \Adapter \Mysql \Aggregation \Builder as AggregationBuilder ;
1112use Magento \Framework \Search \AdapterInterface ;
1213use Magento \Framework \Search \RequestInterface ;
@@ -129,32 +130,35 @@ private function getConnection()
129130 /**
130131 * Get rows size
131132 *
133+ * @param Select $query
132134 * @return int
133135 */
134- private function getSize ($ query )
136+ private function getSize (Select $ query ): int
135137 {
136138 $ sql = $ this ->getSelectCountSql ($ query );
137139 $ parentSelect = $ this ->getConnection ()->select ();
138140 $ parentSelect ->from (['core_select ' => $ sql ]);
139141 $ parentSelect ->reset (\Magento \Framework \DB \Select::COLUMNS );
140142 $ parentSelect ->columns ('COUNT(*) ' );
141143 $ totalRecords = $ this ->getConnection ()->fetchOne ($ parentSelect );
144+
142145 return intval ($ totalRecords );
143146 }
144147
145148 /**
146149 * Reset limit and offset
147150 *
151+ * @param Select $query
148152 * @return Select
149153 */
150- private function getSelectCountSql ($ query )
154+ private function getSelectCountSql (Select $ query ): Select
151155 {
152156 foreach ($ this ->countSqlSkipParts as $ part => $ toSkip ) {
153157 if ($ toSkip ) {
154158 $ query ->reset ($ part );
155159 }
156160 }
161+
157162 return $ query ;
158163 }
159-
160164}
Original file line number Diff line number Diff line change @@ -161,10 +161,16 @@ public function testQuery()
161161 $ select = $ this ->getMockBuilder (\Magento \Framework \DB \Select::class)
162162 ->disableOriginalConstructor ()
163163 ->getMock ();
164- $ this ->connectionAdapter ->expects ($ this ->once ())
164+
165+ $ this ->connectionAdapter ->expects ($ this ->exactly (2 ))
165166 ->method ('select ' )
166167 ->willReturn ($ select );
167168
169+ $ this ->connectionAdapter ->expects ($ this ->once ())
170+ ->method ('fetchOne ' )
171+ ->with ($ select )
172+ ->willReturn ($ selectResult ['total ' ]);
173+
168174 $ table = $ this ->getMockBuilder (\Magento \Framework \DB \Ddl \Table::class)
169175 ->disableOriginalConstructor ()
170176 ->getMock ();
You can’t perform that action at this time.
0 commit comments