Skip to content

Commit 366f916

Browse files
author
Lorenzo Paderi
committed
test: add UfficioPostale tests
1 parent ada6240 commit 366f916

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ $cap = $openapi->comuni->getCitiesByCap('00132');
7171

7272
// Imprese: prendi informazioni su una specifica impresa
7373
$impresa = $openapi->imprese->getByPartitaIva('12485671007');
74+
75+
// Ufficio Postale: ottieni informaizoni sul tracking
76+
$track = $this->openapi->ufficiopostale->track('123456789');
7477
```
7578

7679
# Modulo ufficio postale
80+
## Creare raccomandata
81+
7782

7883
# Modulo visure
7984

src/classes/UfficioPostale.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function __construct(string $token, array $scopes, object $cache, string $prefi
1717
* Restiuisce un oggetto di tipo raccomandata
1818
* @return object
1919
*/
20-
function createRaccomandata(){
20+
function createRaccomandata() {
2121
return new \OpenApi\classes\utility\UfficioPostale\Raccomandata(function(string $endpoint, $type = "GET", $param = [], $ttr = 0, $force = false, $forceRaw = false){
2222

2323
return $this->connect( $endpoint, $type, $param , $ttr , $force, $forceRaw);

tests/ClientTest.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use OpenApi\classes\utility\UfficioPostale\Objects\Recipient;
4+
use OpenApi\classes\utility\UfficioPostale\Objects\Sender;
35
use OpenApi\OpenApi;
46
use PHPUnit\Framework\TestCase;
57
use Symfony\Component\Dotenv\Dotenv;
@@ -36,6 +38,7 @@ public function __construct() {
3638
"GET:comuni.openapi.it/istat",
3739
"GET:comuni.openapi.it/regioni",
3840
"GET:comuni.openapi.it/province",
41+
"GET:ws.ufficiopostale.com/tracking",
3942
"POST:geocoding.realgest.it/geocode"
4043
];
4144

@@ -53,9 +56,36 @@ public function testComuni() {
5356
$this->assertIsArray($cap);
5457
}
5558

56-
public function testGeocoding() {
57-
// Prendi informazioni sul cap 00132
58-
$cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
59-
$this->assertIsArray($cap);
59+
// public function testGeocoding() {
60+
// // Prendi informazioni sul cap 00132
61+
// $cap = $this->openapi->geocoding->geocode('Via Cristoforo Colombo, Roma RM');
62+
// $this->assertIsArray($cap);
63+
// }
64+
65+
public function testUfficioPostale() {
66+
$track = $this->openapi->ufficiopostale->track($_ENV['TRACK_TEST']);
67+
$this->assertEquals(true, $track->success);
68+
var_dump($track);
69+
70+
$raccomandata = $this->openapi->ufficiopostale->createRaccomandata();
71+
var_dump($raccomandata);
72+
73+
$data = new stdClass();
74+
$sender = new Sender([
75+
'firstName' => 'John',
76+
'secondName' => 'Doe',
77+
'companyName' => 'example-spa',
78+
]);
79+
80+
$recipient = new Recipient([
81+
'firstName' => 'John',
82+
'secondName' => 'Doe',
83+
'companyName' => 'example-spa',
84+
]);
85+
86+
$data->sender = $sender;
87+
$data->recipient = $recipient;
88+
89+
$raccomandata->creaRaccomandataByData();
6090
}
6191
}

0 commit comments

Comments
 (0)