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.
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @link http://www.yiiframework.com/
|
|
|
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
|
|
|
* @license http://www.yiiframework.com/license/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace yiiunit\framework\db\pgsql;
|
|
|
|
|
|
|
|
use yii\validators\UniqueValidator;
|
|
|
|
use yiiunit\data\ar\Type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group db
|
|
|
|
* @group pgsql
|
|
|
|
* @group validators
|
|
|
|
*/
|
|
|
|
class UniqueValidatorTest extends \yiiunit\framework\validators\UniqueValidatorTest
|
|
|
|
{
|
|
|
|
public $driverName = 'pgsql';
|
|
|
|
|
|
|
|
public function testPrepareParams()
|
|
|
|
{
|
|
|
|
parent::testPrepareParams();
|
|
|
|
|
|
|
|
// Add table prefix for column name
|
|
|
|
$model = new Type;
|
|
|
|
$model->name = 'Angela';
|
|
|
|
|
|
|
|
$attribute = 'name';
|
|
|
|
$targetAttribute = [$attribute => "[[jsonb_col]]->>'name'"];
|
|
|
|
$result = $this->invokeMethod(new UniqueValidator(), 'prepareConditions', [$targetAttribute, $model, $attribute]);
|
|
|
|
$expected = ['{{' . Type::tableName() . '}}.' . $targetAttribute[$attribute] => $model->name];
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
}
|