1+ <?php
2+
3+ use OpenApi \OpenApi ;
4+ use PHPUnit \Framework \TestCase ;
5+ use Symfony \Component \Dotenv \Dotenv ;
6+
7+ require_once 'vendor/autoload.php ' ;
8+
9+ final class ClientTest extends TestCase {
10+
11+ public Dotenv $ dotenv ;
12+ public string $ username ;
13+ public string $ api_key ;
14+ public array $ scopes ;
15+ public OpenApi $ openapi ;
16+
17+ public function __construct () {
18+ parent ::__construct ();
19+ $ this ->dotenv = new Dotenv ();
20+ $ this ->dotenv ->load (__DIR__ .'/../.env ' );
21+
22+ $ this ->username = $ _ENV ['OPENAPI_USERNAME ' ];
23+ $ this ->api_key = $ _ENV ['API_KEY ' ];
24+
25+ // Dichiaro gli scopes necessari
26+ $ this ->scopes = [
27+ "GET:ws.ufficiopostale.com/telegrammi " ,
28+ "GET:imprese.altravia.com/autocomplete " ,
29+ "GET:imprese.openapi.it/base " ,
30+ "GET:imprese.openapi.it/advance " ,
31+ "GET:imprese.openapi.it/pec " ,
32+ "GET:imprese.openapi.it/autocomplete " ,
33+ "GET:imprese.openapi.it/closed " ,
34+ "GET:imprese.openapi.it/gruppoiva " ,
35+ "GET:comuni.openapi.it/cap " ,
36+ "GET:comuni.openapi.it/istat " ,
37+ "GET:comuni.openapi.it/regioni " ,
38+ "GET:comuni.openapi.it/province " ,
39+ "POST:geocoding.realgest.it/geocode "
40+ ];
41+
42+ $ this ->openapi = new OpenApi ($ this ->scopes , $ this ->username , $ this ->api_key , 'test ' );
43+ }
44+
45+
46+ public function testClientInstance () {
47+ $ this ->assertInstanceOf ('OpenApi\OpenApi ' , $ this ->openapi );
48+ }
49+
50+ public function testComuni () {
51+ // Prendi informazioni sul cap 00132
52+ $ cap = $ this ->openapi ->comuni ->getCitiesByCap ('00132 ' );
53+ $ this ->assertIsArray ($ cap );
54+ }
55+
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 );
60+ }
61+ }
0 commit comments