66use Cristal \ApiWrapper \Transports \TransportInterface ;
77use Mockery ;
88use PHPUnit \Framework \TestCase ;
9+ use TypeError ;
910
1011class ApiTest extends TestCase
1112{
12- const ENDPOINTS = ['client ' , 'catalogue ' , 'materiel ' , 'fabricant ' , 'type ' , 'tarif ' , 'caracteristique ' ];
13+ protected const ENDPOINTS = ['client ' , 'catalogue ' , 'materiel ' , 'fabricant ' , 'type ' , 'tarif ' , 'caracteristique ' ];
1314 protected $ token ;
1415 protected $ entrypoint ;
1516
16- const WITH_FILTER = ['with_filters ' ];
17- const WITHOUT_FILTER = ['without_filters ' ];
18- const ID_ENTITY = 123 ;
17+ protected const WITH_FILTER = ['with_filters ' ];
18+ protected const WITHOUT_FILTER = ['without_filters ' ];
19+ protected const ID_ENTITY = 123 ;
1920
2021 protected function createFakeTransport ()
2122 {
@@ -27,60 +28,50 @@ protected function createFakeTransport()
2728 return $ transport ;
2829 }
2930
30- public function setUp ()
31+ public function setUp (): void
3132 {
3233 $ this ->token = 'token_jwt ' ;
3334 $ this ->entrypoint = 'https://exemple/api/ ' ;
3435 }
3536
36- public function testApiWithoutTransport ()
37+ public function testApiWithoutTransport (): void
3738 {
38- $ this ->expectException (\ TypeError::class);
39+ $ this ->expectException (TypeError::class);
3940 new Api (null );
4041 }
4142
42- public function testApiWithTransport ()
43+ public function testApiWithTransport (): void
4344 {
4445 $ transport = Mockery::mock (TransportInterface::class);
4546 $ api = new Api ($ transport );
46- $ this -> assertInstanceOf (TransportInterface::class, $ api ->getTransport ());
47+ self :: assertInstanceOf (TransportInterface::class, $ api ->getTransport ());
4748 }
4849
49- public function testGetWithoutFilters ()
50+ public function testGetWithoutFilters (): void
5051 {
5152 $ transport = $ this ->createFakeTransport ();
5253 $ api = new Api ($ transport );
5354 foreach (self ::ENDPOINTS as $ endpoint ) {
54- $ this -> assertEquals (self ::WITHOUT_FILTER , $ api ->{'get ' .ucfirst ($ endpoint ).'s ' }());
55+ self :: assertEquals (self ::WITHOUT_FILTER , $ api ->{'get ' .ucfirst ($ endpoint ).'s ' }());
5556 }
5657 }
5758
58- public function testGetWithFilters ()
59+ public function testGetWithFilters (): void
5960 {
6061 $ transport = $ this ->createFakeTransport ();
6162 $ api = new Api ($ transport );
6263 foreach (self ::ENDPOINTS as $ endpoint ) {
63- $ this -> assertEquals (self ::WITH_FILTER , $ api ->{'get ' .ucfirst ($ endpoint ).'s ' }(self ::WITH_FILTER ));
64+ self :: assertEquals (self ::WITH_FILTER , $ api ->{'get ' .ucfirst ($ endpoint ).'s ' }(self ::WITH_FILTER ));
6465 }
6566 }
6667
67- public function testTryToGetSpecificEntityWithoutIdAsArgument ()
68- {
69- $ this ->expectException (\TypeError::class);
70- $ transport = $ this ->createFakeTransport ();
71- $ api = new Api ($ transport );
72- foreach (self ::ENDPOINTS as $ endpoint ) {
73- $ api ->{'get ' .ucfirst ($ endpoint )}();
74- }
75- }
76-
77- public function testTryToGetSpecificEntity ()
68+ public function testTryToGetSpecificEntity (): void
7869 {
7970 $ transport = $ this ->createFakeTransport ();
8071 $ api = new Api ($ transport );
8172 foreach (self ::ENDPOINTS as $ endpoint ) {
8273 $ entity = $ api ->{'get ' .ucfirst ($ endpoint )}(self ::ID_ENTITY );
83- $ this -> assertInternalType ( ' array ' , $ entity );
74+ self :: assertIsArray ( $ entity );
8475 }
8576 }
8677}
0 commit comments