diff --git a/src/Ares.php b/src/Ares.php index 87346c1..dcf9244 100644 --- a/src/Ares.php +++ b/src/Ares.php @@ -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 */ @@ -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.'); } diff --git a/tests/AresTest.php b/tests/AresTest.php index eba224b..5c06d5c 100644 --- a/tests/AresTest.php +++ b/tests/AresTest.php @@ -52,6 +52,22 @@ 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()) { @@ -59,8 +75,7 @@ public function testGetCompanyPeople() } $record = $this->ares->findByIdentificationNumber(27791394); - $companyPeople - = $record->getCompanyPeople(); + $companyPeople = $record->getCompanyPeople(); $this->assertCount(2, $companyPeople); }