-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathArrayParserTest.php
More file actions
34 lines (28 loc) · 1.17 KB
/
ArrayParserTest.php
File metadata and controls
34 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Pgsql\Tests;
use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Pgsql\Data\ArrayParser;
/**
* @group pgsql
*/
final class ArrayParserTest extends TestCase
{
public function testParser(): void
{
$arrayParse = new ArrayParser();
$this->assertSame([0 => null, 1 => null], $arrayParse->parse('{NULL,NULL}'));
$this->assertSame([], $arrayParse->parse('{}'));
$this->assertSame([0 => null, 1 => null], $arrayParse->parse('{,}'));
$this->assertSame([0 => '1', 1 => '2', 2 => '3'], $arrayParse->parse('{1,2,3}'));
$this->assertSame([0 => '1', 1 => '-2', 2 => null, 3 => '42'], $arrayParse->parse('{1,-2,NULL,42}'));
$this->assertSame([[0 => 'text'], [0 => null], [0 => '1']], $arrayParse->parse('{{text},{NULL},{1}}'));
$this->assertSame([0 => ''], $arrayParse->parse('{""}'));
$this->assertSame(
[0 => '[",","null",true,"false","f"]'],
$arrayParse->parse('{"[\",\",\"null\",true,\"false\",\"f\"]"}'),
);
// Similar cases can be in default values
$this->assertSame(null, $arrayParse->parse("'{one,two}'::text[]"));
}
}