Commit 6e3dfb8f by Paul Klimov

"Sphinx" unit tests for "update" and "delete" added.

parent 0f94ed39
......@@ -19,6 +19,23 @@ use yii\db\TableSchema;
class Schema extends \yii\db\mysql\Schema
{
/**
* @var array mapping from physical column types (keys) to abstract column types (values)
*/
public $typeMap = [
'field' => self::TYPE_STRING,
'string' => self::TYPE_STRING,
'ordinal' => self::TYPE_STRING,
'integer' => self::TYPE_INTEGER,
'int' => self::TYPE_INTEGER,
'uint' => self::TYPE_INTEGER,
'bigint' => self::TYPE_BIGINT,
'timestamp' => self::TYPE_TIMESTAMP,
'bool' => self::TYPE_BOOLEAN,
'float' => self::TYPE_FLOAT,
'mva' => self::TYPE_STRING,
];
/**
* Creates a query builder for the database.
* This method may be overridden by child classes to create a DBMS-specific query builder.
* @return QueryBuilder query builder instance
......
......@@ -3,6 +3,7 @@
namespace yiiunit\extensions\sphinx;
use yii\db\DataReader;
use yii\db\Expression;
/**
* @group sphinx
......@@ -128,12 +129,34 @@ class CommandTest extends SphinxTestCase
$command = $db->createCommand()->update(
'yii2_test_rt_index',
[
'title' => 'Test title',
'content' => 'Test content',
'type_id' => $newTypeId,
],
'id = 1'
);
$this->assertEquals(1, $command->execute(), 'Unable to execute update!');
list($row) = $db->createCommand('SELECT * FROM yii2_test_rt_index')->queryAll();
$this->assertEquals($newTypeId, $row['type_id'], 'Unable to update attribute value!');
}
/**
* @depends testInsert
*/
public function testDelete()
{
$db = $this->getConnection();
$db->createCommand()->insert('yii2_test_rt_index', [
'title' => 'Test title',
'content' => 'Test content',
'type_id' => 2,
'id' => 1,
])->execute();
$command = $db->createCommand()->delete('yii2_test_rt_index', 'id = 1');
$this->assertEquals(1, $command->execute(), 'Unable to execute delete!');
$rows = $db->createCommand('SELECT * FROM yii2_test_rt_index')->queryAll();
$this->assertEquals(0, count($rows), 'Unable to delete record!');
}
}
\ 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