File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Yii Framework 2 Elasticsearch extension Change Log
55-----------------------
66
77- Bug #344 : Disabled JSON pretty print for ElasticSearch bulk API (rhertogh)
8+ - Bug #350 : Remove deprecated code, set $pagination->totalCount (lav45)
89
910
10112.1.4 May 22, 2023
Original file line number Diff line number Diff line change @@ -122,9 +122,6 @@ protected function prepareModels()
122122
123123 if (is_array (($ results = $ query ->search ($ this ->db )))) {
124124 $ this ->setQueryResults ($ results );
125- if ($ pagination !== false ) {
126- $ pagination ->totalCount = $ this ->getTotalCount ();
127- }
128125 return $ results ['hits ' ]['hits ' ];
129126 }
130127 $ this ->setQueryResults ([]);
Original file line number Diff line number Diff line change @@ -138,4 +138,23 @@ public function testRefresh()
138138 $ dataProvider ->refresh ();
139139 $ this ->assertEquals (1 , $ dataProvider ->getTotalCount ());
140140 }
141+
142+ public function testTotalCountAfterSearch ()
143+ {
144+ $ query = Customer::find ();
145+ $ provider = new ActiveDataProvider ([
146+ 'query ' => $ query ,
147+ 'pagination ' => [
148+ 'pageSize ' => 2 ,
149+ ],
150+ ]);
151+
152+ $ pagination = $ provider ->getPagination ();
153+ $ this ->assertEquals (2 , $ pagination ->getPageCount ());
154+ $ this ->assertEquals (3 , $ pagination ->getTotalCount ());
155+
156+ $ query ->andWhere (['name ' => 'user2 ' ]);
157+ $ this ->assertEquals (1 , $ pagination ->getPageCount ());
158+ $ this ->assertEquals (1 , $ pagination ->getTotalCount ());
159+ }
141160}
You can’t perform that action at this time.
0 commit comments