mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-16 15:21:13 +08:00
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace yiiunit\framework\db\pgsql;
|
|
|
|
use yii\db\JsonExpression;
|
|
use yiiunit\data\ar\ActiveRecord;
|
|
|
|
/**
|
|
* @group db
|
|
* @group pgsql
|
|
*/
|
|
class BaseActiveRecordTest extends \yiiunit\framework\db\BaseActiveRecordTest
|
|
{
|
|
public $driverName = 'pgsql';
|
|
|
|
/**
|
|
* @see https://github.com/yiisoft/yii2/issues/19872
|
|
*
|
|
* @dataProvider provideArrayValueWithChange
|
|
*/
|
|
public function testJsonDirtyAttributesWithDataChange($actual, $modified): void
|
|
{
|
|
$createdStorage = new ArrayAndJsonType([
|
|
'json_col' => new JsonExpression($actual),
|
|
]);
|
|
|
|
$createdStorage->save();
|
|
|
|
$foundStorage = ArrayAndJsonType::find()->limit(1)->one();
|
|
|
|
$this->assertNotNull($foundStorage);
|
|
|
|
$foundStorage->json_col = $modified;
|
|
|
|
$this->assertSame(['json_col' => $modified], $foundStorage->getDirtyAttributes());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
* @property array id
|
|
* @property array json_col
|
|
*/
|
|
class ArrayAndJsonType extends ActiveRecord
|
|
{
|
|
public static function tableName()
|
|
{
|
|
return '{{%array_and_json_types}}';
|
|
}
|
|
}
|