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.
 
 
 
 
 

71 lines
2.2 KiB

<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\db\oci;
use yii\db\Schema;
/**
* @group db
* @group oci
*/
class CommandTest extends \yiiunit\framework\db\CommandTest
{
protected $driverName = 'oci';
public function testAutoQuoting()
{
$db = $this->getConnection(false);
$sql = 'SELECT [[id]], [[t.name]] FROM {{customer}} t';
$command = $db->createCommand($sql);
$this->assertEquals('SELECT "id", "t"."name" FROM "customer" t', $command->sql);
}
public function testLastInsertId()
{
$db = $this->getConnection();
$sql = 'INSERT INTO {{profile}}([[description]]) VALUES (\'non duplicate\')';
$command = $db->createCommand($sql);
$command->execute();
$this->assertEquals(3, $db->getSchema()->getLastInsertID('profile_SEQ'));
}
public function batchInsertSqlProvider()
{
$data = parent::batchInsertSqlProvider();
$data['issue11242']['expected'] = 'INSERT INTO "type" ("int_col", "float_col", "char_col") VALUES (NULL, NULL, \'Kyiv {{city}}, Ukraine\')';
$data['wrongBehavior']['expected'] = 'INSERT INTO "type" ("type"."int_col", "float_col", "char_col") VALUES (\'\', \'\', \'Kyiv {{city}}, Ukraine\')';
return $data;
}
/**
* Testing the "ORA-01461: can bind a LONG value only for insert into a LONG column"
*
* @return void
*/
public function testCLOBStringInsertion()
{
$db = $this->getConnection();
if ($db->getSchema()->getTableSchema('longstring') !== null) {
$db->createCommand()->dropTable('longstring')->execute();
}
$db->createCommand()->createTable('longstring', ['message' => Schema::TYPE_TEXT])->execute();
$longData = str_pad('-', 4001, '-=', STR_PAD_LEFT);
$db->createCommand()->insert('longstring', [
'message' => $longData,
])->execute();
$this->assertEquals(1, $db->createCommand('SELECT count(*) FROM {{longstring}}')->queryScalar());
$db->createCommand()->dropTable('longstring')->execute();
}
}