Completed
Push — master ( 08027e...371217 )
by Jeroen
02:01
created

testGettingLatitudeAndLongitudeFromAddressWithoutHTTPS()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace JeroenDesloovere\Geolocation\tests;
4
5
// required to load
6
require_once __DIR__ . '/../vendor/autoload.php';
7
8
/*
9
 * This file is part of the Geolocation PHP Class from Jeroen Desloovere.
10
 *
11
 * For the full copyright and license information, please view the license
12
 * file that was distributed with this source code.
13
 */
14
15
use JeroenDesloovere\Geolocation\Geolocation;
16
use PHPUnit\Framework\TestCase;
17
18
/**
19
 * In this class we test all generic functions from Geolocation.
20
 *
21
 * @author Jeroen Desloovere <[email protected]>
22
 */
23
class GeolocationTest extends TestCase
24
{
25
    /** @var Geolocation */
26
    private $api;
27
28
    public function setUp(): void
29
    {
30
        $this->api = new Geolocation();
31
    }
32
33
    /**
34
     * Test getting latitude/longitude coordinates from address.
35
     */
36
    public function testGettingLatitudeAndLongitudeFromAddress(): void
37
    {
38
        $street = 'Koningin Maria Hendrikaplein';
39
        $streetNumber = '1';
40
        $city = 'Gent';
41
        $zip = '1';
42
        $country = 'belgium';
43
44
        $result = $this->api->getCoordinates(
45
            $street,
46
            $streetNumber,
47
            $city,
48
            $zip,
49
            $country
50
        );
51
52
        $this->assertEquals(51.037249600000003, $result->getLatitude());
53
        $this->assertEquals(3.7094974999999999, $result->getLongitude());
54
    }
55
56
    /**
57
     * Test getting address from latitude and longitude coordinates.
58
     */
59
    public function testGetAddressFromLatitudeAndLongitude(): void
60
    {
61
        $latitude = 51.0363935;
62
        $longitude = 3.7121008;
63
64
        $result = $this->api->getAddress(
65
            $latitude,
66
            $longitude
67
        );
68
69
        $this->assertEquals('Pr. Clementinalaan 114-140, 9000 Gent, Belgium', $result->getLabel());
70
    }
71
72
    /**
73
     * Test getting latitude/longitude coordinates from address.
74
     */
75
    public function testGettingLatitudeAndLongitudeFromAddressWithoutHTTPS(): void
76
    {
77
        $this->api = new Geolocation(null, false);
78
        $this->testGettingLatitudeAndLongitudeFromAddress();
79
    }
80
81
    /**
82
     * Test getting address from latitude and longitude coordinates.
83
     */
84
    public function testGetAddressFromLatitudeAndLongitudeWithoutHTTPS(): void
85
    {
86
        $this->api = new Geolocation(null, false);
87
        $this->testGetAddressFromLatitudeAndLongitude();
88
    }
89
}
90