mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-10-31 02:28:35 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			1006 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1006 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * @link https://www.yiiframework.com/
 | |
|  * @copyright Copyright (c) 2008 Yii Software LLC
 | |
|  * @license https://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);
 | |
|     }
 | |
| }
 | 
