|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* phpMyAdmin ShapeFile library |
|
7
|
|
|
* <https://github.com/phpmyadmin/shapefile/>. |
|
8
|
|
|
* |
|
9
|
|
|
* Copyright 2016 - 2017 Michal Čihař <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software; you can redistribute it and/or |
|
12
|
|
|
* modify it under the terms of the GNU General Public License |
|
13
|
|
|
* as published by the Free Software Foundation. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU General Public License |
|
21
|
|
|
* along with this program; if not, you can download one from |
|
22
|
|
|
* https://www.gnu.org/copyleft/gpl.html. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace PhpMyAdminTest\ShapeFile; |
|
26
|
|
|
|
|
27
|
|
|
use PhpMyAdmin\ShapeFile\Util; |
|
28
|
|
|
use PHPUnit\Framework\TestCase; |
|
29
|
|
|
|
|
30
|
|
|
class UtilTest extends TestCase |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* Test data loading. |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $type Data type |
|
36
|
|
|
* @param string|false $data Data to parse |
|
37
|
|
|
* @param mixed $expected Expected result |
|
38
|
|
|
* |
|
39
|
|
|
* @dataProvider data |
|
40
|
|
|
*/ |
|
41
|
|
|
public function testLoadData(string $type, string|false $data, mixed $expected): void |
|
42
|
|
|
{ |
|
43
|
|
|
self::assertEquals( |
|
44
|
|
|
$expected, |
|
45
|
|
|
Util::loadData($type, $data), |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Data provider for loadData tests. |
|
51
|
|
|
* |
|
52
|
|
|
* @psalm-return list<array{string, string|false, mixed}> |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function data(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return [ |
|
57
|
|
|
[ |
|
58
|
|
|
'N', |
|
59
|
|
|
'', |
|
60
|
|
|
false, |
|
61
|
|
|
], |
|
62
|
|
|
[ |
|
63
|
|
|
'N', |
|
64
|
|
|
false, |
|
65
|
|
|
false, |
|
66
|
|
|
], |
|
67
|
|
|
[ |
|
68
|
|
|
'N', |
|
69
|
|
|
"\x01\x02\x03\x04", |
|
70
|
|
|
0x01020304, |
|
71
|
|
|
], |
|
72
|
|
|
]; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|