Passed
Push — master ( f71bba...a12491 )
by Maurício
01:50
created

UtilTest::data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 17
rs 9.9332
c 0
b 0
f 0
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