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

AddressTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 57
rs 10
c 0
b 0
f 0
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\Model;
14
15
use Geocoder\Model\Address;
16
use Geocoder\Model\AdminLevelCollection;
17
use PHPUnit\Framework\TestCase;
18
19
/**
20
 * @author Antoine Lemaire <[email protected]>
21
 */
22
class AddressTest extends TestCase
23
{
24
    public function testDumpEmptyAddress()
25
    {
26
        $expected = [
27
            'providedBy' => 'n/a',
28
            'latitude' => null,
29
            'longitude' => null,
30
            'bounds' => [
31
                'south' => null,
32
                'west' => null,
33
                'north' => null,
34
                'east' => null,
35
            ],
36
            'streetNumber' => null,
37
            'streetName' => null,
38
            'postalCode' => null,
39
            'locality' => null,
40
            'subLocality' => null,
41
            'adminLevels' => [],
42
            'country' => null,
43
            'countryCode' => null,
44
            'timezone' => null,
45
        ];
46
47
        $address = new Address('n/a', new AdminLevelCollection());
48
        $this->assertEquals($address->toArray(), $expected);
49
    }
50
51
    public function testToArray()
52
    {
53
        $data = [
54
            'providedBy' => 'n/a',
55
            'latitude' => 48.8631507,
56
            'longitude' => 2.3889114,
57
            'bounds' => [
58
                'south' => 48.8631507,
59
                'west' => 2.3889114,
60
                'north' => 48.8631507,
61
                'east' => 2.388911,
62
            ],
63
            'streetNumber' => '10',
64
            'streetName' => 'Avenue Gambetta',
65
            'postalCode' => '75020',
66
            'locality' => 'Paris',
67
            'subLocality' => '20e Arrondissement',
68
            'adminLevels' => [1 => ['name' => 'Ile-de-France', 'code' => 'Ile-de-France', 'level' => 1]],
69
            'country' => 'France',
70
            'countryCode' => 'FR',
71
            'timezone' => null,
72
        ];
73
74
        $address = Address::createFromArray($data);
75
76
        $this->assertSame($data, $address->toArray());
77
    }
78
}
79