-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathArrayParserTest.php
More file actions
61 lines (56 loc) · 1.62 KB
/
ArrayParserTest.php
File metadata and controls
61 lines (56 loc) · 1.62 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Pgsql\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Yiisoft\Db\Pgsql\Data\ArrayParser;
/**
* @group pgsql
*/
final class ArrayParserTest extends TestCase
{
public static function parserProvider(): iterable
{
yield [[], '{}'];
yield [[''], '{""}'];
yield [[null, null], '{NULL,NULL}'];
yield [[null, null], '{,}'];
yield [
["a\nb"],
"{\"a\nb\"}",
];
yield [
['1', '2', '3'],
'{1,2,3}',
];
yield [
['1', '-2', null, '42'],
'{1,-2,NULL,42}',
];
yield [
[['text'], [null], ['1']],
'{{text},{NULL},{1}}',
];
yield [
[',', '}', '"', '\\', '"\\,}', 'NULL', 't', 'f'],
'{",","}","\\"","\\\\","\\"\\\\,}","NULL",t,f}',
];
yield [
['[",","null",true,"false","f"]'],
'{"[\",\",\"null\",true,\"false\",\"f\"]"}',
];
// Multibyte strings
yield [
['我', '👍🏻', 'multibyte строка我👍🏻', 'נטשופ צרכנות'],
'{我,👍🏻,"multibyte строка我👍🏻","נטשופ צרכנות"}',
];
// Similar cases can be in default values
yield [null, "'{one,two}'::text[]"];
}
#[DataProvider('parserProvider')]
public function testParser(?array $expected, string $value): void
{
$arrayParse = new ArrayParser();
$this->assertSame($expected, $arrayParse->parse($value));
}
}