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