yiiapi/tests/framework/web/CSortTest.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
/**
* CSortTest
*/
Yii::import('system.db.CDbConnection');
Yii::import('system.db.ar.CActiveRecord');
class CSortTest extends CTestCase {
private $db;
public function setUp(){
if(!extension_loaded('pdo') || !extension_loaded('pdo_sqlite'))
$this->markTestSkipped('PDO and SQLite extensions are required.');
$this->db=new CDbConnection('sqlite::memory:');
$this->db->active=true;
$this->db->pdoInstance->exec(file_get_contents(dirname(__FILE__).'/CSortTest.sql'));
CActiveRecord::$db=$this->db;
}
public function tearDown(){
$this->db->active=false;
}
/**
* Tests for acceptance of fields with dots in
* CSort::attributes.
*
* @return void
*/
function testGetDirectionsWithDots(){
$_GET['sort'] = 'comments.id';
$criteria = new CDbCriteria();
$criteria->with = 'comments';
$sort = new CSort('TestPost');
$sort->attributes = array(
'id',
'comments.id' => array(
'asc'=>'comments.id',
'desc'=>'comments.id desc',
),
);
$sort->applyOrder($criteria);
$directions = $sort->getDirections();
$this->assertTrue(isset($directions['comments.id']));
}
/**
* Tests for acceptance of arrays for asc/desc keys in
* CSort::attributes.
*
* @return void
*/
function testGetDirectionsWithArrays(){
$_GET['sort'] = 'comments.id';
后面还有 50 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
