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.
53 lines
1.5 KiB
53 lines
1.5 KiB
<?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\ExistValidator; |
|
|
|
/** |
|
* @group db |
|
* @group pgsql |
|
* @group validators |
|
*/ |
|
class ExistValidatorTest extends \yiiunit\framework\validators\ExistValidatorTest |
|
{ |
|
public $driverName = 'pgsql'; |
|
|
|
/** |
|
* @see https://github.com/yiisoft/yii2/issues/14274 |
|
*/ |
|
public function testWithCameCasedTableName() |
|
{ |
|
// The same target table |
|
$validator = new ExistValidator(['targetAttribute' => 'ref']); |
|
$model = ValidatorTestRefModel::findOne(['id' => 2]); |
|
$validator->validateAttribute($model, 'ref'); |
|
$this->assertFalse($model->hasErrors()); |
|
|
|
// Different target table |
|
$validator = new ExistValidator(['targetClass' => ValidatorTestMainModel::className(), 'targetAttribute' => 'id']); |
|
$model = ValidatorTestRefModel::findOne(['id' => 1]); |
|
$validator->validateAttribute($model, 'ref'); |
|
$this->assertFalse($model->hasErrors()); |
|
} |
|
} |
|
|
|
class ValidatorTestRefModel extends \yiiunit\data\validators\models\ValidatorTestRefModel |
|
{ |
|
public static function tableName() |
|
{ |
|
return 'validatorRef'; |
|
} |
|
} |
|
class ValidatorTestMainModel extends \yiiunit\data\validators\models\ValidatorTestRefModel |
|
{ |
|
public static function tableName() |
|
{ |
|
return 'validatorMain'; |
|
} |
|
}
|
|
|