|
|
|
@ -197,6 +197,7 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
|
|
|
|
$this->assertEquals($expected, $value, 'In column ' . $attribute); |
|
|
|
|
if ($value instanceof ArrayExpression) { |
|
|
|
|
$this->assertInstanceOf('\ArrayAccess', $value); |
|
|
|
|
$this->assertInstanceOf('\Traversable', $value); |
|
|
|
|
foreach ($type->$attribute as $key => $v) { // testing arrayaccess |
|
|
|
|
$this->assertSame($expected[$key], $value[$key]); |
|
|
|
|
} |
|
|
|
@ -208,8 +209,14 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
|
|
|
|
{ |
|
|
|
|
return [ |
|
|
|
|
'simple arrays values' => [[ |
|
|
|
|
'intarray_col' => [new ArrayExpression([1,-2,null,'42'], 'int4', 1)], |
|
|
|
|
'textarray2_col' => [new ArrayExpression([['text'], [null], [1]], 'text', 2)], |
|
|
|
|
'intarray_col' => [ |
|
|
|
|
new ArrayExpression([1,-2,null,'42'], 'int4', 1), |
|
|
|
|
new ArrayExpression([1,-2,null,42], 'int4', 1), |
|
|
|
|
], |
|
|
|
|
'textarray2_col' => [ |
|
|
|
|
new ArrayExpression([['text'], [null], [1]], 'text', 2), |
|
|
|
|
new ArrayExpression([['text'], [null], ['1']], 'text', 2), |
|
|
|
|
], |
|
|
|
|
'json_col' => [['a' => 1, 'b' => null, 'c' => [1,3,5]]], |
|
|
|
|
'jsonb_col' => [[null, 'a', 'b', '\"', '{"af"}']], |
|
|
|
|
'jsonarray_col' => [new ArrayExpression([[',', 'null', true, 'false', 'f']], 'json')], |
|
|
|
@ -217,11 +224,11 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
|
|
|
|
'arrays packed in classes' => [[ |
|
|
|
|
'intarray_col' => [ |
|
|
|
|
new ArrayExpression([1,-2,null,'42'], 'int', 1), |
|
|
|
|
new ArrayExpression([1,-2,null,'42'], 'int4', 1), |
|
|
|
|
new ArrayExpression([1,-2,null,42], 'int4', 1), |
|
|
|
|
], |
|
|
|
|
'textarray2_col' => [ |
|
|
|
|
new ArrayExpression([['text'], [null], [1]], 'text', 2), |
|
|
|
|
new ArrayExpression([['text'], [null], [1]], 'text', 2), |
|
|
|
|
new ArrayExpression([['text'], [null], ['1']], 'text', 2), |
|
|
|
|
], |
|
|
|
|
'json_col' => [ |
|
|
|
|
new JsonExpression(['a' => 1, 'b' => null, 'c' => [1,3,5]]), |
|
|
|
@ -234,7 +241,6 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
|
|
|
|
'jsonarray_col' => [ |
|
|
|
|
new Expression("array['[\",\",\"null\",true,\"false\",\"f\"]'::json]::json[]"), |
|
|
|
|
new ArrayExpression([[',', 'null', true, 'false', 'f']], 'json'), |
|
|
|
|
|
|
|
|
|
] |
|
|
|
|
]], |
|
|
|
|
'scalars' => [[ |
|
|
|
|