Skip to content

Commit

Permalink
fix + test cases for findByName method when no results found [closes d…
Browse files Browse the repository at this point in the history
  • Loading branch information
filipmelik authored and dfridrich committed Mar 25, 2019
1 parent 4acfec4 commit df1867e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Ares.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ public function findVatById($id)
}

/**
* @param $name
* @param null $city
* @param string $name
* @param null $city
*
* @throws InvalidArgumentException
* @throws \Exception
* @throws AresException
*
* @return array|AresRecord[]|AresRecords
*/
Expand Down Expand Up @@ -350,7 +350,7 @@ public function findByName($name, $city = null)
$data = $aresResponse->children($ns['are']);
$elements = $data->children($ns['dtt'])->V->S;

if (!count($elements)) {
if (empty($elements)) {
throw new AresException('Nic nebylo nalezeno.');
}

Expand Down
19 changes: 17 additions & 2 deletions tests/AresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,30 @@ public function testFindByEmptyStringException()
$this->ares->findByIdentificationNumber('');
}

public function testFindByName()
{
$results = $this->ares->findByName('sever');

$this->assertGreaterThan(0, count($results));
}

/**
* @expectedException \Defr\Ares\AresException
* @expectedExceptionMessage Nic nebylo nalezeno.
*/
public function testFindByNameNonExistentName()
{
$this->ares->findByName('some non-existent company name');
}

public function testGetCompanyPeople()
{
if ($this->isTravis()) {
$this->markTestSkipped('Travis cannot connect to Justice.cz');
}

$record = $this->ares->findByIdentificationNumber(27791394);
$companyPeople
= $record->getCompanyPeople();
$companyPeople = $record->getCompanyPeople();
$this->assertCount(2, $companyPeople);
}

Expand Down

0 comments on commit df1867e

Please sign in to comment.