Yii2 framework backup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

49 lines
1.2 KiB

<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\data;
use yii\data\SqlDataProvider;
use yiiunit\framework\db\DatabaseTestCase;
/**
* @group data
*/
class SqlDataProviderTest extends DatabaseTestCase
{
protected $driverName = 'sqlite';
public function testGetModels()
{
$dataProvider = new SqlDataProvider([
'sql' => 'select * from `customer`',
'db' => $this->getConnection(),
]);
$this->assertCount(3, $dataProvider->getModels());
}
public function testTotalCount()
{
$dataProvider = new SqlDataProvider([
'sql' => 'select * from `customer`',
'db' => $this->getConnection(),
]);
$this->assertEquals(3, $dataProvider->getTotalCount());
}
public function testTotalCountWithParams()
{
$dataProvider = new SqlDataProvider([
'sql' => 'select * from `customer` where id > :minimum',
'params' => [
':minimum' => -1,
],
'db' => $this->getConnection(),
]);
$this->assertEquals(3, $dataProvider->getTotalCount());
}
}