1 | <?php |
||||
2 | |||||
3 | namespace Bpost\BpostApiClient\Geo6\test; |
||||
4 | |||||
5 | use Bpost\BpostApiClient\Exception\BpostApiResponseException\BpostTaxipostLocatorException; |
||||
6 | use Bpost\BpostApiClient\Geo6; |
||||
7 | use Exception; |
||||
8 | use PHPUnit_Framework_TestCase; |
||||
0 ignored issues
–
show
|
|||||
9 | |||||
10 | class Geo6Test extends PHPUnit_Framework_TestCase |
||||
11 | { |
||||
12 | /** |
||||
13 | * @var Geo6 |
||||
14 | */ |
||||
15 | private $geo6; |
||||
16 | |||||
17 | /** |
||||
18 | * Prepares the environment before running a test. |
||||
19 | */ |
||||
20 | protected function setUp() |
||||
21 | { |
||||
22 | parent::setUp(); |
||||
23 | $this->geo6 = new Geo6(GEO6_PARTNER, GEO6_APP_ID); |
||||
24 | } |
||||
25 | |||||
26 | /** |
||||
27 | * Cleans up the environment after running a test. |
||||
28 | */ |
||||
29 | protected function tearDown() |
||||
30 | { |
||||
31 | $this->geo6 = null; |
||||
32 | parent::tearDown(); |
||||
33 | } |
||||
34 | |||||
35 | /** |
||||
36 | * Tests Geo6->getTimeOut() |
||||
37 | */ |
||||
38 | public function testGetTimeOut() |
||||
39 | { |
||||
40 | $this->geo6->setTimeOut(5); |
||||
41 | $this->assertSame(5, $this->geo6->getTimeOut()); |
||||
42 | } |
||||
43 | |||||
44 | /** |
||||
45 | * Tests Geo6->getUserAgent() |
||||
46 | */ |
||||
47 | public function testGetUserAgent() |
||||
48 | { |
||||
49 | $this->geo6->setUserAgent('testing/1.0.0'); |
||||
50 | $this->assertSame('PHP Bpost Geo6/' . Geo6::VERSION . ' testing/1.0.0', $this->geo6->getUserAgent()); |
||||
51 | } |
||||
52 | |||||
53 | /** |
||||
54 | * Tests Geo6->getNearestServicePoint() |
||||
55 | */ |
||||
56 | public function testGetNearestServicePoint() |
||||
57 | { |
||||
58 | $response = $this->geo6->getNearestServicePoint('Afrikalaan', '289', '9000'); |
||||
59 | |||||
60 | $this->assertInternalType('array', $response); |
||||
61 | |||||
62 | foreach ($response as $item) { |
||||
63 | $this->assertArrayHasKey('poi', $item); |
||||
64 | $this->assertArrayHasKey('distance', $item); |
||||
65 | $this->assertInstanceOf('Bpost\BpostApiClient\Geo6\Poi', $item['poi']); |
||||
66 | } |
||||
67 | } |
||||
68 | |||||
69 | /** |
||||
70 | * Tests Geo6->getServicePointDetails() |
||||
71 | */ |
||||
72 | public function testGetServicePointDetails() |
||||
73 | { |
||||
74 | $id = '220000'; |
||||
75 | $type = '1'; |
||||
76 | $response = $this->geo6->getServicePointDetails($id, 'nl', $type); |
||||
0 ignored issues
–
show
$type of type string is incompatible with the type integer expected by parameter $type of Bpost\BpostApiClient\Geo...etServicePointDetails() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
77 | |||||
78 | $this->assertInstanceOf('Bpost\BpostApiClient\Geo6\Poi', $response); |
||||
79 | $this->assertSame($response->getId(), $id); |
||||
80 | $this->assertSame($response->getType(), $type); |
||||
81 | |||||
82 | try { |
||||
83 | $this->geo6->getServicePointDetails('-1'); |
||||
84 | $this->fail('BpostTaxipostLocatorException not launched'); |
||||
85 | } catch (BpostTaxipostLocatorException $e) { |
||||
86 | $this->assertSame('No match for id : -1 and type : 3', $e->getMessage()); |
||||
87 | } catch (Exception $e) { |
||||
88 | $this->fail('BpostTaxipostLocatorException not caught'); |
||||
89 | } |
||||
90 | |||||
91 | try { |
||||
92 | $this->geo6->getServicePointDetails('0'); |
||||
93 | $this->fail('BpostTaxipostLocatorException not launched'); |
||||
94 | } catch (BpostTaxipostLocatorException $e) { |
||||
95 | $this->assertSame('Id is mandatory', $e->getMessage()); |
||||
96 | } catch (Exception $e) { |
||||
97 | $this->fail('BpostTaxipostLocatorException not caught'); |
||||
98 | } |
||||
99 | } |
||||
100 | |||||
101 | /** |
||||
102 | * Tests Geo6->getServicePointPage() |
||||
103 | */ |
||||
104 | public function testGetServicePointPage() |
||||
105 | { |
||||
106 | $id = 220000; |
||||
107 | $type = 1; |
||||
108 | $response = $this->geo6->getServicePointPageUrl($id, 'nl', $type); |
||||
109 | |||||
110 | $this->assertSame( |
||||
111 | 'https://pudo.bpost.be/Locator?Id=' . $id . '&Language=nl&Type=' . $type . '&Country=BE&Function=page&Partner=' . GEO6_PARTNER . '&AppId=' . GEO6_APP_ID . '&Format=xml', |
||||
112 | $response |
||||
113 | ); |
||||
114 | } |
||||
115 | } |
||||
116 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths