Completed
Push — master ( 1b0014...e530af )
by Tobias
03:11
created

WkbTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 36
loc 36
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Tests\Dumper;
14
15
use Geocoder\Dumper\Wkb;
16
use Geocoder\Model\Address;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * @author Jan Sorgalla <[email protected]>
21
 * @author William Durand <[email protected]>
22
 */
23
class WkbTest extends TestCase
24
{
25
    /**
26
     * @var Wkb
27
     */
28
    private $dumper;
29
30
    public function setUp()
31
    {
32
        $this->dumper = new Wkb();
33
    }
34
35
    public function testDump()
36
    {
37
        $address = Address::createFromArray([]);
38
        $expected = pack('H*', '010100000000000000000000000000000000000000');
39
        $result = $this->dumper->dump($address);
40
41
        $this->assertTrue(is_string($result));
42
        $this->assertEquals($expected, $result);
43
    }
44
45
    public function testDumpWithData()
46
    {
47
        $address = Address::createFromArray([
48
            'latitude' => 48.8631507,
49
            'longitude' => 2.3889114,
50
        ]);
51
        $expected = pack('H*', '0101000000255580947D1C03407F02DEB87B6E4840');
52
53
        $result = $this->dumper->dump($address);
54
55
        $this->assertTrue(is_string($result));
56
        $this->assertEquals($expected, $result);
57
    }
58
}
59