Skip to content

Commit

Permalink
Merge pull request #92 from IonBazan/bugfix/post-city
Browse files Browse the repository at this point in the history
add post city (MiejscowoscPoczty)
  • Loading branch information
johnzuk authored Apr 18, 2020
2 parents bc6da0b + 43e3e6a commit 2b3df8b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/GusApi/SearchReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class SearchReport implements JsonSerializable
*/
private $activityEndDate;

/**
* @var string
*/
private $postCity;

/**
* SearchReport constructor.
*
Expand All @@ -118,6 +123,7 @@ public function __construct(SearchResponseCompanyData $data)
$this->regon14 = $this->makeRegon14($this->getRegon());
$this->silo = $data->getSilosID();
$this->activityEndDate = $data->getDataZakonczeniaDzialalnosci();
$this->postCity = $data->getMiejscowoscPoczty();
}

/**
Expand Down Expand Up @@ -266,6 +272,14 @@ public function getActivityEndDate(): string
return $this->activityEndDate;
}

/**
* @return string
*/
public function getPostCity(): string
{
return $this->postCity;
}

/**
* @param string $regon
*
Expand Down
13 changes: 13 additions & 0 deletions src/GusApi/Type/Response/SearchResponseCompanyData.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class SearchResponseCompanyData
*/
public $DataZakonczeniaDzialalnosci = '';

/**
* @var string
*/
public $MiejscowoscPoczty = '';

/**
* @return string
*/
Expand Down Expand Up @@ -197,4 +202,12 @@ public function getDataZakonczeniaDzialalnosci(): string
{
return $this->DataZakonczeniaDzialalnosci;
}

/**
* @return string
*/
public function getMiejscowoscPoczty(): string
{
return $this->MiejscowoscPoczty;
}
}
6 changes: 5 additions & 1 deletion tests/ExampleCompanyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

trait ExampleCompanyTrait
{
protected function assertValidExampleCompany(SearchReport $report)
protected function assertValidExampleCompany(SearchReport $report, bool $checkPostCity = true)
{
$this->assertSame('610188201', $report->getRegon());
$this->assertSame('61018820100000', $report->getRegon14());
Expand All @@ -25,6 +25,9 @@ protected function assertValidExampleCompany(SearchReport $report)
$this->assertSame(SearchReport::TYPE_JURIDICAL_PERSON, $report->getType());
$this->assertSame(6, $report->getSilo());
$this->assertSame('', $report->getActivityEndDate());
if ($checkPostCity) {
$this->assertSame('Płock', $report->getPostCity());
}
}

protected function getExampleResponseData(): SearchResponseCompanyData
Expand All @@ -45,6 +48,7 @@ protected function getExampleResponseData(): SearchResponseCompanyData
$responseData->method('getTyp')->willReturn('p');
$responseData->method('getSilosID')->willReturn(6);
$responseData->method('getDataZakonczeniaDzialalnosci')->willReturn('');
$responseData->method('getMiejscowoscPoczty')->willReturn('Płock');

return $responseData;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/GusApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testGetExampleCompanyByNips()
{
$result = self::$apiClient->getByNips(['7740001454']);
$this->assertCount(1, $result);
$this->assertValidExampleCompany($result[0]);
$this->assertValidExampleCompany($result[0], false);
}

public function testGetByInvalidNipAndGetMessage()
Expand All @@ -65,21 +65,21 @@ public function testGetExampleCompanyByRegons()
{
$result = self::$apiClient->getByRegons9(['610188201']);
$this->assertCount(1, $result);
$this->assertValidExampleCompany($result[0]);
$this->assertValidExampleCompany($result[0], false);
}

public function testGetExampleCompanyByKrs()
{
$result = self::$apiClient->getByKrs('0000028860');
$this->assertCount(1, $result);
$this->assertValidExampleCompany($result[0]);
$this->assertValidExampleCompany($result[0], false);
}

public function testGetExampleCompanyByKrses()
{
$result = self::$apiClient->getByKrses(['0000028860']);
$this->assertCount(1, $result);
$this->assertValidExampleCompany($result[0]);
$this->assertValidExampleCompany($result[0], false);
}

public function testGetStatus()
Expand Down
4 changes: 3 additions & 1 deletion tests/SearchReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function testIsJsonSerializable(): void
$companyData->Typ = 'P';
$companyData->SilosID = '6';
$companyData->DataZakonczeniaDzialalnosci = '2029-02-22';
$companyData->MiejscowoscPoczty = 'Płock';

$this->assertEquals([
'regon' => '02092251199990',
Expand All @@ -38,12 +39,13 @@ public function testIsJsonSerializable(): void
'zipCode' => '50-038',
'street' => 'ul. Test-Krucza',
'type' => 'p',
'silo' => '6',
'silo' => 6,
'nip' => '9988660000',
'nipStatus' => 'U',
'propertyNumber' => '33',
'apartmentNumber' => '34B',
'activityEndDate' => '2029-02-22',
'postCity' => 'Płock',
], \json_decode(\json_encode(new SearchReport($companyData)), true));
}
}

0 comments on commit 2b3df8b

Please sign in to comment.