Skip to content

Commit

Permalink
Remove legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
lav45 committed Jun 15, 2024
1 parent 9a70a0f commit 1be4fea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
3 changes: 0 additions & 3 deletions ActiveDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ protected function prepareModels()

if (is_array(($results = $query->search($this->db)))) {
$this->setQueryResults($results);
if ($pagination !== false) {
$pagination->totalCount = $this->getTotalCount();
}
return $results['hits']['hits'];
}
$this->setQueryResults([]);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"require": {
"yiisoft/yii2": "<=2.0.49",
"yiisoft/yii2": ">=2.0.50",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand Down
19 changes: 19 additions & 0 deletions tests/ActiveDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,23 @@ public function testRefresh()
$dataProvider->refresh();
$this->assertEquals(1, $dataProvider->getTotalCount());
}

public function testTotalCountAfterSearch()
{
$query = Customer::find();
$provider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 2,
],
]);

$pagination = $provider->getPagination();
$this->assertEquals(2, $pagination->getPageCount());
$this->assertEquals(3, $pagination->getTotalCount());

$query->andWhere(['name' => 'user2']);
$this->assertEquals(1, $pagination->getPageCount());
$this->assertEquals(1, $pagination->getTotalCount());
}
}

0 comments on commit 1be4fea

Please sign in to comment.