-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 13920-validation-marks-valid-field-as-invalid
- Loading branch information
Showing
13 changed files
with
333 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace yiiunit\framework\db; | ||
|
||
use yiiunit\data\ar\ActiveRecord; | ||
|
||
abstract class BaseActiveRecordTest extends DatabaseTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
ActiveRecord::$db = $this->getConnection(); | ||
} | ||
|
||
public function provideArrayValueWithChange() | ||
{ | ||
return [ | ||
'not an associative array with data change' => [ | ||
[1, 2, 3], | ||
[1, 3, 2], | ||
], | ||
|
||
'associative array with data change case 1' => [ | ||
['pineapple' => 2, 'apple' => 5, 'banana' => 1], | ||
['apple' => 5, 'pineapple' => 1, 'banana' => 3], | ||
], | ||
'associative array with data change case 2' => [ | ||
['pineapple' => 2, 'apple' => 5, 'banana' => 1], | ||
['pineapple' => 2, 'apple' => 3, 'banana' => 1], | ||
], | ||
|
||
'filling an empty array' => [ | ||
[], | ||
['pineapple' => 3, 'apple' => 1, 'banana' => 1], | ||
], | ||
'zeroing the array' => [ | ||
['pineapple' => 3, 'apple' => 1, 'banana' => 17], | ||
[], | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace yiiunit\framework\db\mysql; | ||
|
||
use yiiunit\data\ar\Storage; | ||
|
||
class BaseActiveRecordTest extends \yiiunit\framework\db\BaseActiveRecordTest | ||
{ | ||
public $driverName = 'mysql'; | ||
|
||
/** | ||
* @see https://github.com/yiisoft/yii2/issues/19872 | ||
* | ||
* @dataProvider provideArrayValueWithChange | ||
*/ | ||
public function testJsonDirtyAttributesWithDataChange($actual, $modified) | ||
{ | ||
if (version_compare($this->getConnection()->getSchema()->getServerVersion(), '5.7', '<')) { | ||
$this->markTestSkipped('JSON columns are not supported in MySQL < 5.7'); | ||
} | ||
if (version_compare(PHP_VERSION, '5.6', '<')) { | ||
$this->markTestSkipped('JSON columns are not supported in PDO for PHP < 5.6'); | ||
} | ||
|
||
$createdStorage = new Storage(['data' => $actual]); | ||
|
||
$createdStorage->save(); | ||
|
||
$foundStorage = Storage::find()->limit(1)->one(); | ||
|
||
$this->assertNotNull($foundStorage); | ||
|
||
$foundStorage->data = $modified; | ||
|
||
$this->assertSame(['data' => $modified], $foundStorage->getDirtyAttributes()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace yiiunit\framework\db\pgsql; | ||
|
||
use yii\db\JsonExpression; | ||
use yiiunit\data\ar\ActiveRecord; | ||
|
||
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) | ||
{ | ||
$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}}'; | ||
} | ||
} |
Oops, something went wrong.