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 7
7
8
8
use Magento \Framework \App \ResourceConnection ;
9
9
use Magento \Framework \DB \Ddl \Table ;
10
+ use Magento \Framework \DB \Select ;
10
11
use Magento \Framework \Search \Adapter \Mysql \Aggregation \Builder as AggregationBuilder ;
11
12
use Magento \Framework \Search \AdapterInterface ;
12
13
use Magento \Framework \Search \RequestInterface ;
@@ -129,32 +130,35 @@ private function getConnection()
129
130
/**
130
131
* Get rows size
131
132
*
133
+ * @param Select $query
132
134
* @return int
133
135
*/
134
- private function getSize ($ query )
136
+ private function getSize (Select $ query ): int
135
137
{
136
138
$ sql = $ this ->getSelectCountSql ($ query );
137
139
$ parentSelect = $ this ->getConnection ()->select ();
138
140
$ parentSelect ->from (['core_select ' => $ sql ]);
139
141
$ parentSelect ->reset (\Magento \Framework \DB \Select::COLUMNS );
140
142
$ parentSelect ->columns ('COUNT(*) ' );
141
143
$ totalRecords = $ this ->getConnection ()->fetchOne ($ parentSelect );
144
+
142
145
return intval ($ totalRecords );
143
146
}
144
147
145
148
/**
146
149
* Reset limit and offset
147
150
*
151
+ * @param Select $query
148
152
* @return Select
149
153
*/
150
- private function getSelectCountSql ($ query )
154
+ private function getSelectCountSql (Select $ query ): Select
151
155
{
152
156
foreach ($ this ->countSqlSkipParts as $ part => $ toSkip ) {
153
157
if ($ toSkip ) {
154
158
$ query ->reset ($ part );
155
159
}
156
160
}
161
+
157
162
return $ query ;
158
163
}
159
-
160
164
}
Original file line number Diff line number Diff line change @@ -161,10 +161,16 @@ public function testQuery()
161
161
$ select = $ this ->getMockBuilder (\Magento \Framework \DB \Select::class)
162
162
->disableOriginalConstructor ()
163
163
->getMock ();
164
- $ this ->connectionAdapter ->expects ($ this ->once ())
164
+
165
+ $ this ->connectionAdapter ->expects ($ this ->exactly (2 ))
165
166
->method ('select ' )
166
167
->willReturn ($ select );
167
168
169
+ $ this ->connectionAdapter ->expects ($ this ->once ())
170
+ ->method ('fetchOne ' )
171
+ ->with ($ select )
172
+ ->willReturn ($ selectResult ['total ' ]);
173
+
168
174
$ table = $ this ->getMockBuilder (\Magento \Framework \DB \Ddl \Table::class)
169
175
->disableOriginalConstructor ()
170
176
->getMock ();
You can’t perform that action at this time.
0 commit comments