Commit d15378ef by Qiang Xue

moved db tests.

parent 2188ece1
......@@ -189,9 +189,9 @@ abstract class ActiveRecord extends Model
*/
public static function updateAll($attributes, $condition = '', $params = array())
{
$query = new Query;
$query->update(static::tableName(), $attributes, $condition, $params);
return $query->createCommand(static::getDbConnection())->execute();
$command = static::getDbConnection()->createCommand();
$command->update(static::tableName(), $attributes, $condition, $params);
return $command->execute();
}
/**
......@@ -210,9 +210,9 @@ abstract class ActiveRecord extends Model
$quotedName = $db->quoteColumnName($name, true);
$counters[$name] = new Expression($value >= 0 ? "$quotedName+$value" : "$quotedName$value");
}
$query = new Query;
$query->update(static::tableName(), $counters, $condition, $params);
return $query->createCommand($db)->execute();
$command = $db->createCommand();
$command->update(static::tableName(), $counters, $condition, $params);
return $command->execute();
}
/**
......@@ -224,9 +224,9 @@ abstract class ActiveRecord extends Model
*/
public static function deleteAll($condition = '', $params = array())
{
$query = new Query;
$query->delete(static::tableName(), $condition, $params);
return $query->createCommand(static::getDbConnection())->execute();
$command = static::getDbConnection()->createCommand();
$command->delete(static::tableName(), $condition, $params);
return $command->execute();
}
/**
......@@ -587,10 +587,9 @@ abstract class ActiveRecord extends Model
public function insert($attributes = null)
{
if ($this->beforeInsert()) {
$query = new Query;
$values = $this->getChangedAttributes($attributes);
$db = $this->getDbConnection();
$command = $query->insert($this->tableName(), $values)->createCommand($db);
$command = $db->createCommand()->insert($this->tableName(), $values);
if ($command->execute()) {
$table = $this->getTableSchema();
if ($table->sequenceName !== null) {
......
<?php
namespace yiiunit\framework\db\ar;
namespace yiiunit\framework\db;
use yii\db\Query;
use yii\db\ActiveQuery;
......
<?php
namespace yiiunit\framework\db\dao;
namespace yiiunit\framework\db;
use yii\db\Connection;
use yii\db\Command;
......@@ -213,4 +213,110 @@ class CommandTest extends \yiiunit\MysqlTestCase
$result = $command->queryRow(array(), \PDO::FETCH_NUM);
$this->assertTrue(is_array($result) && isset($result[0]));
}
function testInsert()
{
}
function testUpdate()
{
}
function testDelete()
{
}
function testCreateTable()
{
}
function testRenameTable()
{
}
function testDropTable()
{
}
function testTruncateTable()
{
}
function testAddColumn()
{
}
function testDropColumn()
{
}
function testRenameColumn()
{
}
function testAlterColumn()
{
}
function testAddForeignKey()
{
}
function testDropForeignKey()
{
}
function testCreateIndex()
{
}
function testDropIndex()
{
}
function testParams()
{
}
function testGetSql()
{
}
function testCreateCommand()
{
}
function testReset()
{
}
function testToArray()
{
}
function testMergeWith()
{
}
}
\ No newline at end of file
<?php
namespace yiiunit\framework\db\dao;
namespace yiiunit\framework\db;
use yii\db\Connection;
......
<?php
namespace yiiunit\framework\db\dao;
namespace yiiunit\framework\db;
use yii\db\Connection;
use yii\db\Command;
......@@ -107,109 +107,4 @@ class QueryTest extends \yiiunit\MysqlTestCase
{
}
function testInsert()
{
}
function testUpdate()
{
}
function testDelete()
{
}
function testCreateTable()
{
}
function testRenameTable()
{
}
function testDropTable()
{
}
function testTruncateTable()
{
}
function testAddColumn()
{
}
function testDropColumn()
{
}
function testRenameColumn()
{
}
function testAlterColumn()
{
}
function testAddForeignKey()
{
}
function testDropForeignKey()
{
}
function testCreateIndex()
{
}
function testDropIndex()
{
}
function testParams()
{
}
function testGetSql()
{
}
function testCreateCommand()
{
}
function testReset()
{
}
function testToArray()
{
}
function testMergeWith()
{
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment