mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Fix #20175: Fix bad result for pagination when used with GridView
This commit is contained in:
@ -197,4 +197,23 @@ abstract class ActiveDataProviderTest extends DatabaseTestCase
|
||||
|
||||
$this->assertEquals(0, $pagination->getPageCount());
|
||||
}
|
||||
|
||||
public function testTotalCountAfterSearch()
|
||||
{
|
||||
$query = Order::find();
|
||||
$provider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'pagination' => [
|
||||
'pageSize' => 2,
|
||||
],
|
||||
]);
|
||||
|
||||
$pagination = $provider->getPagination();
|
||||
$this->assertEquals(2, $pagination->getPageCount());
|
||||
$this->assertEquals(3, $pagination->getTotalCount());
|
||||
|
||||
$query->andWhere(['customer_id' => 2]);
|
||||
$this->assertEquals(1, $pagination->getPageCount());
|
||||
$this->assertEquals(2, $pagination->getTotalCount());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user