mrcnpdlk /
mojepanstwo-api
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * MOJEPANSTWO-API |
||
| 4 | * |
||
| 5 | * Copyright © 2017 pudelek.org.pl |
||
| 6 | * |
||
| 7 | * @license MIT License (MIT) |
||
| 8 | * |
||
| 9 | * For the full copyright and license information, please view source file |
||
| 10 | * that is bundled with this package in the file LICENSE |
||
| 11 | * |
||
| 12 | * @author Marcin Pudełek <[email protected]> |
||
| 13 | */ |
||
| 14 | |||
| 15 | |||
| 16 | namespace mrcnpdlk\MojePanstwo; |
||
| 17 | |||
| 18 | |||
| 19 | use mrcnpdlk\MojePanstwo\Model\Address\Commune; |
||
| 20 | use mrcnpdlk\MojePanstwo\Model\Address\District; |
||
| 21 | use mrcnpdlk\MojePanstwo\Model\Address\Nts; |
||
| 22 | use mrcnpdlk\MojePanstwo\Model\Address\Province; |
||
| 23 | use mrcnpdlk\MojePanstwo\Model\KrsEntity; |
||
| 24 | use mrcnpdlk\MojePanstwo\Model\KrsEntityType; |
||
| 25 | use mrcnpdlk\MojePanstwo\Model\KrsPerson; |
||
| 26 | use mrcnpdlk\MojePanstwo\Model\SearchResponse; |
||
| 27 | |||
| 28 | class ApiTest extends TestCase |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * @var \mrcnpdlk\MojePanstwo\Api |
||
| 32 | */ |
||
| 33 | private $oApi; |
||
| 34 | |||
| 35 | public function setUp() |
||
| 36 | { |
||
| 37 | parent::setUp(); |
||
| 38 | $oClient = new \mrcnpdlk\MojePanstwo\Client(); |
||
| 39 | $this->oApi = Api::create($oClient); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function testGetClient() |
||
| 43 | { |
||
| 44 | $this->assertInstanceOf(Client::class, $this->oApi->getClient()); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function testGetCommune() |
||
| 48 | { |
||
| 49 | $this->assertInstanceOf(Commune::class, $this->oApi->getCommune(1)); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @expectedException \mrcnpdlk\MojePanstwo\Exception |
||
| 54 | */ |
||
| 55 | public function testNotFound() |
||
| 56 | { |
||
| 57 | $res = $this->oApi->getProvince(111111); |
||
|
0 ignored issues
–
show
|
|||
| 58 | } |
||
| 59 | |||
| 60 | View Code Duplication | public function testNtsConvert_one() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 61 | { |
||
| 62 | $oNts = new Nts('1234567891'); |
||
| 63 | $this->assertEquals('1', $oNts->region_id); |
||
| 64 | $this->assertEquals('23', $oNts->teryt_wojewodztwo_id); |
||
| 65 | $this->assertEquals('45', $oNts->podregion_id); |
||
| 66 | $this->assertEquals('67', $oNts->teryt_powiat_id); |
||
| 67 | $this->assertEquals('89', $oNts->teryt_gmina_id); |
||
| 68 | $this->assertEquals('1', $oNts->teryt_gmina_typ_id); |
||
| 69 | $this->assertEquals(2367891, $oNts->teryt_terc_id); |
||
| 70 | } |
||
| 71 | |||
| 72 | View Code Duplication | public function testNtsConvert_two() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 73 | { |
||
| 74 | $oNts = new Nts('11234567891'); |
||
| 75 | $this->assertEquals('1', $oNts->region_id); |
||
| 76 | $this->assertEquals('23', $oNts->teryt_wojewodztwo_id); |
||
| 77 | $this->assertEquals('45', $oNts->podregion_id); |
||
| 78 | $this->assertEquals('67', $oNts->teryt_powiat_id); |
||
| 79 | $this->assertEquals('89', $oNts->teryt_gmina_id); |
||
| 80 | $this->assertEquals('1', $oNts->teryt_gmina_typ_id); |
||
| 81 | $this->assertEquals(2367891, $oNts->teryt_terc_id); |
||
| 82 | } |
||
| 83 | |||
| 84 | View Code Duplication | public function testSearchCommune() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 85 | { |
||
| 86 | $res = $this->oApi->searchCommune()->limit(1)->get(); |
||
| 87 | $this->assertInstanceOf(SearchResponse::class, $res); |
||
| 88 | $this->assertEquals(1, count($res->items)); |
||
| 89 | $this->assertInstanceOf(Commune::class, $res->items[0]->data); |
||
| 90 | } |
||
| 91 | |||
| 92 | View Code Duplication | public function testSearchDistrict() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 93 | { |
||
| 94 | $res = $this->oApi->searchDistrict()->limit(1)->get(); |
||
| 95 | $this->assertInstanceOf(SearchResponse::class, $res); |
||
| 96 | $this->assertEquals(1, count($res->items)); |
||
| 97 | $this->assertInstanceOf(District::class, $res->items[0]->data); |
||
| 98 | } |
||
| 99 | |||
| 100 | View Code Duplication | public function testSearchKrsEntity() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 101 | { |
||
| 102 | $res = $this->oApi->searchKrsEntity()->limit(1)->get(); |
||
| 103 | $this->assertInstanceOf(SearchResponse::class, $res); |
||
| 104 | $this->assertEquals(1, count($res->items)); |
||
| 105 | $this->assertInstanceOf(KrsEntity::class, $res->items[0]->data); |
||
| 106 | } |
||
| 107 | |||
| 108 | View Code Duplication | public function testSearchKrsEntityType() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 109 | { |
||
| 110 | $res = $this->oApi->searchKrsEntityType()->limit(1)->get(); |
||
| 111 | $this->assertInstanceOf(SearchResponse::class, $res); |
||
| 112 | $this->assertEquals(1, count($res->items)); |
||
| 113 | $this->assertInstanceOf(KrsEntityType::class, $res->items[0]->data); |
||
| 114 | } |
||
| 115 | |||
| 116 | View Code Duplication | public function testSearchProvince() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 117 | { |
||
| 118 | $res = $this->oApi->searchProvince()->limit(1)->get(); |
||
| 119 | $this->assertInstanceOf(SearchResponse::class, $res); |
||
| 120 | $this->assertEquals(1, count($res->items)); |
||
| 121 | $this->assertInstanceOf(Province::class, $res->items[0]->data); |
||
| 122 | } |
||
| 123 | |||
| 124 | View Code Duplication | public function testSearchKrsPerson() |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 125 | { |
||
| 126 | $res = $this->oApi->searchKrsPerson()->limit(1)->get(); |
||
| 127 | $this->assertInstanceOf(SearchResponse::class, $res); |
||
| 128 | $this->assertEquals(1, count($res->items)); |
||
| 129 | $this->assertInstanceOf(KrsPerson::class, $res->items[0]->data); |
||
| 130 | } |
||
| 131 | } |
||
| 132 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.