diff --git a/.travis.yml b/.travis.yml
index 641c415..593a583 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,5 @@
language: php
php:
- - 5.6
- - 7.0
- 7.1
- 7.2
- 7.3
diff --git a/README.md b/README.md
index 74fdf33..b24ea7b 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,8 @@ Librarie PHP pentru verificarea gratuita a contribuabililor care sunt inregistra
Date care pot fi obtinute:
- Denumire/Adresa companie
+ - Numar Registrul Comertului
+ - Numar de telefon
- Platitor/Neplatitor TVA
- Platitor TVA la incasare
- ~~Platitor Split TVA~~ **OUG 23/2017 privind plata defalcată a TVA a fost abrogata incepand cu 1 februarie 2020**
@@ -35,63 +37,89 @@ $anaf = new \Itrack\Anaf\Client();
### Pentru a verifica doar un CUI foloseste metoda
```php
-$cui = "123456";
+$cif = "123456";
$dataVerificare = "YYYY-MM-DD";
-$anaf->addCui($cui, $dataVerificare);
+$anaf->addCif($cif, $dataVerificare);
```
#### Conform exemplului de mai jos:
```php
-$cui = "123456";
+$cif = "123456";
$dataVerificare = "2019-05-20";
-$anaf->addCui($cui, $dataVerificare);
-$raspuns = $anaf->getOneResult();
+$anaf->addCif($cif, $dataVerificare);
+$company = $anaf->first();
+
+// Metode disponibile
+echo $company->getName();
+echo $company->getCIF();
+echo $company->getRegCom();
+echo $company->getPhone();
+
+echo $company->getFullAddress();
+echo $company->getAddress()->getCounty();
+echo $company->getAddress()->getCounty();
+echo $company->getAddress()->getStreet();
+echo $company->getAddress()->getStreetNumber();
+echo $company->getAddress()->getOthers();
+
+echo $company->getTVA()->hasTVA();
+echo $company->getTVA()->getTVAEnrollDate();
+echo $company->getTVA()->getTVAEndDate();
+
+echo $company->getTVA()->hasTVACollection();
+echo $company->getTVA()->getTVACollectionEnrollDate();
+echo $company->getTVA()->getTVACollectionEndDate();
+
+echo $company->getTVA()->hasTVASplit();
+echo $company->getTVA()->getTVASplitEnrollDate();
+echo $company->getTVA()->getTVASplitEndDate();
+echo $company->getTVA()->getTVASplitIBAN();
+
+echo $company->getReactivationDate();
+echo $company->getInactivationDate();
+echo $company->getDeletionDate();
+echo $company->isActive();
```
### Pentru a verifica mai multe CUI-uri in acelasi timp foloseste urmeaza exemplul de mai jos:
```php
-$anaf->addCui("123456", "2019-05-20");
-$anaf->addCui("RO654321"); // Daca data nu este setata, valoarea default va fi data de azi
-$raspuns = $anaf->getResults();
+$anaf->addCif("123456", "2019-05-20");
+$anaf->addCif("RO654321"); // Daca data nu este setata, valoarea default va fi data de azi
+$raspuns = $anaf->get();
// SAU
-$cuis = [
+$cifs = [
"123456",
"RO6543221"
];
-$anaf->addCui($cuis, "2019-05-20");
-$raspuns = $anaf->getResults();
+$anaf->addCif($cuis, "2019-05-20");
+$raspuns = $anaf->get();
```
-# Exemplu raspuns
-![Raspuns ANAF](https://github.com/itrack/anaf/blob/master/response.PNG?raw=true)
-
-
# Limite
Poti solicita raspuns pentru maxim 500 de CUI-uri simultan cu o rata de 1 request / secunda.
# Requirements
-* PHP >= 5.5
+* PHP >= 7.1
* Ext-Curl
* Ext-Json
* Ext-Mbstring
-# Tratarea exceptiilor
-Din versiunea 2.0.0 am adaugat exceptii pentru tratarea erorilor, pentru a nu afecta mediile de productie te rog sa tratezi aceste exceptii prin try -> catch
-
-Exceptii:
+# Exceptii:
* Itrack\Anaf\Exceptions\LimitExceeded - Ai depasit limita de 500 de CUI-uri / request;
* Itrack\Anaf\Exceptions\ResponseFailed - Raspunsul primit de la ANAF nu este in format JSON, exceptia returneaza body-ul raspunsului pentru a fi verificat manual;
* Itrack\Anaf\Exceptions\RequestFailed - Raspunsul primit de la ANAF nu are status de succes, verifica manual raspunsul primit in exceptie.
+# Upgrade de la 2 la 3
+Versiunea 2 nu este compatibila cu versiunea 3, daca aveti o implementare vechie, trebuie refacuta pentru a fi compatibila.
+
# Contribuitori
[![Contribuitori](https://contributors-img.firebaseapp.com/image?repo=itrack/anaf)](https://github.com/itrack/anaf/graphs/contributors)
# Linkuri utile
-https://blog.turma.ro/api-anaf/
-https://webservicesp.anaf.ro/PlatitorTvaRest/api/v4/
+https://webservicesp.anaf.ro/PlatitorTvaRest/api/v5/
diff --git a/composer.json b/composer.json
index 06bd389..69d7a8c 100644
--- a/composer.json
+++ b/composer.json
@@ -1,29 +1,31 @@
{
"name": "itrack/anaf",
"type": "library",
- "version": "2.0.1",
+ "version": "3.0.0",
"description": "API ANAF pentru verificarea contribuabililor care sunt inregistrati conform art. 316 din Codul Fiscal",
"authors": [{
"name": "Alex Stoica",
"email": "0x01.alex+github@gmail.com"
}],
"keywords": [
+ "api anaf",
"verificare tva",
"inregistrat tva",
- "api anaf",
- "webservie anaf"
+ "webservie anaf",
+ "date firma",
+ "mfinante"
],
"license": [
"MIT"
],
"require": {
- "php": ">=5.5",
+ "php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*"
},
"require-dev": {
- "phpunit/phpunit": "^5.7 || ^8.5"
+ "phpunit/phpunit": "^7.5.20 || ^9.5.2"
},
"autoload": {
"psr-4": {
diff --git a/example.php b/example.php
deleted file mode 100644
index cbb75ef..0000000
--- a/example.php
+++ /dev/null
@@ -1,70 +0,0 @@
-addCui(123456, "2019-05-31");
-$anaf->addCui("RO16826034");
-
-print_r($anaf->getResults());
-
-// Gather data about more CUI's using an array
-$anaf = new \Itrack\Anaf\Client();
-
-$cuis = [
- "RO123456",
- "123456",
- 123456
-];
-$anaf->addCui($cuis);
-
-print_r($anaf->getResults());
-
-// Gather data about one CUI
-$anaf = new \Itrack\Anaf\Client();
-
-$anaf->addCui("14080700");
-
-print_r($anaf->getOneResult());
-
-/*
-Output example:
-
-stdClass Object
-(
- [cui] => 14080700
- [data] => 2019-06-01
- [denumire] => REALITATEA MEDIA SA
- [adresa] => stdClass Object
- (
- [raw] => MUNICIPIUL BUCUREŞTI, SECTOR 1, ŞOS. BUCUREŞTI-PLOIEŞTI, NR.172-176, BL.CORP A, ET.3, AP.CAMERA 5
- [judet] => Municipiul Bucureşti
- [localitate] => Sector 1
- [strada] => Şos. Bucureşti-Ploieşti
- [numar] => 172-176
- [altele] => Bl.corp A, Et.3, Ap.camera 5
- )
-
- [scpTVA] => 1
- [data_inceput_ScpTVA] => 2001-08-01
- [data_sfarsit_ScpTVA] =>
- [data_anul_imp_ScpTVA] =>
- [mesaj_ScpTVA] => platitor IN SCOPURI de TVA la data cautata
- [dataInceputTvaInc] =>
- [dataSfarsitTvaInc] =>
- [dataActualizareTvaInc] =>
- [dataPublicareTvaInc] =>
- [tipActTvaInc] =>
- [statusTvaIncasare] =>
- [dataInactivare] =>
- [dataReactivare] =>
- [dataPublicare] =>
- [dataRadiere] =>
- [statusInactivi] =>
- [dataInceputSplitTVA] => 2018-03-01
- [dataAnulareSplitTVA] =>
- [statusSplitTVA] => 1
- [iban] => RO53TREZ701505001XXXXTVA
-)
- */
\ No newline at end of file
diff --git a/examples/getMoreCIFs.php b/examples/getMoreCIFs.php
new file mode 100644
index 0000000..2190654
--- /dev/null
+++ b/examples/getMoreCIFs.php
@@ -0,0 +1,21 @@
+addCif("14080700");
+$anaf->addCif("RO16826034");
+$companies = $anaf->get();
+
+foreach ($companies as $company) {
+ echo $company->getName();
+ echo $company->getCIF();
+ echo $company->getRegCom();
+ echo $company->getPhone();
+ echo $company->getAddress()->getCounty();
+ echo $company->getAddress()->getCounty();
+ echo $company->getAddress()->getStreet();
+ echo $company->getAddress()->getStreetNumber();
+
+ // ... etc
+}
diff --git a/examples/getOneCIF.php b/examples/getOneCIF.php
new file mode 100644
index 0000000..59d7c35
--- /dev/null
+++ b/examples/getOneCIF.php
@@ -0,0 +1,18 @@
+addCif("14080700");
+$company = $anaf->first();
+
+echo $company->getName();
+echo $company->getCIF();
+echo $company->getRegCom();
+echo $company->getPhone();
+echo $company->getAddress()->getCounty();
+echo $company->getAddress()->getCounty();
+echo $company->getAddress()->getStreet();
+echo $company->getAddress()->getStreetNumber();
+
+// ... etc
\ No newline at end of file
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index d86ec31..e4565ca 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,19 +1,17 @@
-
-
-
-
- tests/
-
-
-
-
-
- src/
-
- ./tests
- ./vendor
-
-
-
-
\ No newline at end of file
+
+
+
+ src/
+
+
+ ./tests
+ ./vendor
+
+
+
+
+ ./tests/
+
+
+
diff --git a/response.PNG b/response.PNG
deleted file mode 100644
index 27ae7da..0000000
Binary files a/response.PNG and /dev/null differ
diff --git a/src/Client.php b/src/Client.php
index 3aab1dd..a522441 100644
--- a/src/Client.php
+++ b/src/Client.php
@@ -1,48 +1,45 @@
cuis[] = [
- "cui" => $cui,
+ // Add cif to list
+ $this->cifs[] = [
+ "cui" => $cif,
"data" => $date
];
}
@@ -51,131 +48,30 @@ public function addCui($fiscals, $date = null)
}
/**
- * Get results of request
- * @return array
+ * @return Company[]
* @throws Exceptions\LimitExceeded
* @throws Exceptions\RequestFailed
* @throws Exceptions\ResponseFailed
*/
- public function getResults()
+ public function get(): array
{
- $results = $this->callApi();
- foreach($results as $company) {
- $company->adresa = $this->parseAddress($company->adresa);
+ $companies = [];
+ $results = Http::call($this->cifs);
+ foreach ($results as $result) {
+ $companies[] = new Company(new Parser($result));
}
-
- return $results;
+ return $companies;
}
/**
- * Get first result
- * @return mixed
+ * @return Company
* @throws Exceptions\LimitExceeded
* @throws Exceptions\RequestFailed
* @throws Exceptions\ResponseFailed
*/
- public function getOneResult()
- {
- $company = $this->callApi()[0];
- $company->adresa = $this->parseAddress($company->adresa);
-
- return $company;
- }
-
- /**
- * Call ANAF API
- * @return mixed
- * @throws Exceptions\LimitExceeded
- * @throws Exceptions\RequestFailed
- * @throws Exceptions\ResponseFailed
- */
- private function callApi()
- {
- // Limit maxim numbers of cuis
- if(count($this->cuis) >= self::ANAF_CUI_LIMIT) {
- throw new Exceptions\LimitExceeded('Poti verifica simultam pana la 500 de CUI-uri.');
- }
-
- // Make request
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => self::apiURL,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_TIMEOUT => 10,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => json_encode($this->cuis),
- CURLOPT_HTTPHEADER => array(
- "Cache-Control: no-cache",
- "Content-Type: application/json"
- )
- ));
-
- $response = curl_exec($curl);
- $info = curl_getinfo($curl);
- curl_close($curl);
-
- // Check http code
- if (!isset($info['http_code']) || $info['http_code'] !== 200) {
- throw new Exceptions\ResponseFailed("Response status: {$info['http_code']} | Response body: {$response}");
- }
-
- // Get items
- $items = json_decode($response);
-
- // Check if have json because ANAF return errors in plain text
- if(json_last_error() !== JSON_ERROR_NONE) {
- throw new Exceptions\ResponseFailed("Json parse error | Response body: {$response}");
- }
-
- // Check success stats
- if ("SUCCESS" !== $items->message || 200 !== $items->cod) {
- throw new Exceptions\RequestFailed("Response message: {$items->message} | Response body: {$response}");
- }
-
- return $items->found;
- }
-
- /**
- * Parse company address
- * @param $raw
- * @return stdClass
- */
- private function parseAddress($raw)
+ public function first(): Company
{
- // Check if raw is empty
- if(empty($raw)) {
- return $raw;
- }
-
- // Normal case from all uppercase
- $rawText = mb_convert_case($raw, MB_CASE_TITLE, 'UTF-8');
-
- // Parse address
- $list = array_map('trim', explode(",", $rawText, 5));
- list($judet, $localitate, $strada, $numar, $altele) = array_pad($list, 5, '');
-
- // Parse county
- $judet = trim(str_replace('Jud.', '', $judet));
-
- // Parse city
- $localitate = trim(str_replace(['Mun.', 'Orş.'], ['', 'Oraş'], $localitate));
-
- // Parse street
- $strada = trim(str_replace('Str.', '', $strada));
-
- // Parse number
- $numar = trim(str_replace('Nr.', '', $numar));
-
- // New object for address
- $address = new stdClass;
-
- $address->raw = $raw;
- $address->judet = $judet;
- $address->localitate = $localitate;
- $address->strada = $strada;
- $address->numar = $numar;
- $address->altele = $altele;
-
- return $address;
+ $results = Http::call($this->cifs);
+ return new Company(new Parser($results[0]));
}
}
diff --git a/src/Http.php b/src/Http.php
new file mode 100644
index 0000000..ed5a340
--- /dev/null
+++ b/src/Http.php
@@ -0,0 +1,65 @@
+= self::CIF_LIMIT) {
+ throw new Exceptions\LimitExceeded('You can check one time up to 500 cifs.');
+ }
+
+ // Make request
+ $curl = curl_init();
+ curl_setopt_array($curl, array(
+ CURLOPT_URL => self::apiURL,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_TIMEOUT => 10,
+ CURLOPT_CUSTOMREQUEST => "POST",
+ CURLOPT_POSTFIELDS => json_encode($cifs),
+ CURLOPT_HTTPHEADER => array(
+ "Cache-Control: no-cache",
+ "Content-Type: application/json"
+ )
+ ));
+
+ $response = curl_exec($curl);
+ $info = curl_getinfo($curl);
+ curl_close($curl);
+
+ // Check http code
+ if (!isset($info['http_code']) || $info['http_code'] !== 200) {
+ throw new Exceptions\ResponseFailed("Response status: {$info['http_code']} | Response body: {$response}");
+ }
+
+ // Get items
+ $responseData = json_decode($response, true);
+
+ // Check if have json because ANAF return errors in plain text
+ if(json_last_error() !== JSON_ERROR_NONE) {
+ throw new Exceptions\ResponseFailed("Json parse error | Response body: {$response}");
+ }
+
+ // Check success stats
+ if ("SUCCESS" !== $responseData['message'] || 200 !== $responseData['cod']) {
+ throw new Exceptions\RequestFailed("Response message: {$responseData['message']} | Response body: {$response}");
+ }
+
+ return $responseData['found'];
+ }
+
+}
diff --git a/src/Models/Company.php b/src/Models/Company.php
new file mode 100644
index 0000000..3344f63
--- /dev/null
+++ b/src/Models/Company.php
@@ -0,0 +1,111 @@
+parser = $parser;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCIF(): string
+ {
+ return $this->parser->getData()['cui'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getRegCom(): string
+ {
+ return $this->parser->getData()['nrRegCom'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getName(): string
+ {
+ return $this->parser->getData()['denumire'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getPhone(): string
+ {
+ return $this->parser->getData()['telefon'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getFullAddress(): string
+ {
+ return $this->parser->getData()['adresa'];
+ }
+
+ /**
+ * @return bool
+ */
+ public function isActive(): bool
+ {
+ if (!is_bool($this->parser->getData()['statusInactivi'])) {
+ return false;
+ }
+
+ return !$this->parser->getData()['statusInactivi'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getInactivationDate(): string
+ {
+ return $this->parser->getData()['dataInactivare'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getReactivationDate(): string
+ {
+ return $this->parser->getData()['dataReactivare'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getDeletionDate(): string
+ {
+ return $this->parser->getData()['dataRadiere'];
+ }
+
+ /**
+ * @return CompanyTVA
+ */
+ public function getTVA(): CompanyTVA
+ {
+ return new CompanyTVA($this->parser);
+ }
+
+ /**
+ * @return CompanyAddress
+ */
+ public function getAddress(): CompanyAddress
+ {
+ return new CompanyAddress($this->parser);
+ }
+}
diff --git a/src/Models/CompanyAddress.php b/src/Models/CompanyAddress.php
new file mode 100644
index 0000000..b612ba4
--- /dev/null
+++ b/src/Models/CompanyAddress.php
@@ -0,0 +1,59 @@
+parser = $parser;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCounty(): string
+ {
+ return $this->parser->getAddress()['county'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getCity(): string
+ {
+ return $this->parser->getAddress()['city'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getStreet(): string
+ {
+ return $this->parser->getAddress()['street'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getStreetNumber(): string
+ {
+ return $this->parser->getAddress()['streetNumber'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getOthers(): string
+ {
+ return $this->parser->getAddress()['others'];
+ }
+}
diff --git a/src/Models/CompanyTVA.php b/src/Models/CompanyTVA.php
new file mode 100644
index 0000000..d0125aa
--- /dev/null
+++ b/src/Models/CompanyTVA.php
@@ -0,0 +1,99 @@
+parser = $parser;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasTVA(): bool
+ {
+ return $this->parser->getData()['scpTVA'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVAEnrollDate(): string
+ {
+ return $this->parser->getData()['data_inceput_ScpTVA'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVAEndDate(): string
+ {
+ return $this->parser->getData()['data_sfarsit_ScpTVA'];
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasTVACollection(): bool
+ {
+ return $this->parser->getData()['statusTvaIncasare'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVACollectionEnrollDate(): string
+ {
+ return $this->parser->getData()['dataInceputTvaInc'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVACollectionEndDate(): string
+ {
+ return $this->parser->getData()['dataSfarsitTvaInc'];
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasTVASplit(): bool
+ {
+ return $this->parser->getData()['statusSplitTVA'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVASplitEnrollDate(): string
+ {
+ return $this->parser->getData()['dataInceputSplitTVA'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVASplitEndDate(): string
+ {
+ return $this->parser->getData()['dataAnulareSplitTVA'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getTVASplitIBAN(): string
+ {
+ return $this->parser->getData()['iban'];
+ }
+}
diff --git a/src/Parser.php b/src/Parser.php
new file mode 100644
index 0000000..ebba597
--- /dev/null
+++ b/src/Parser.php
@@ -0,0 +1,66 @@
+data = $data;
+ }
+
+ /**
+ * @return array
+ */
+ public function getAddress(): array
+ {
+ $address = [];
+
+ // Normal case from all uppercase
+ $rawText = mb_convert_case($this->data['adresa'], MB_CASE_TITLE, 'UTF-8');
+
+ // Parse address
+ $list = array_map('trim', explode(",", $rawText, 5));
+ list($county, $city, $street, $number, $other) = array_pad($list, 5, '');
+
+ // Parse county
+ $address['county'] = trim(str_replace('Jud.', '', $county));
+
+ // Parse city
+ $address['city'] = trim(str_replace(['Mun.', 'Orş.'], ['', 'Oraş'], $city));
+
+ // Parse street
+ $address['street'] = trim(str_replace('Str.', '', $street));
+
+ // Parse street number
+ $address['streetNumber'] = trim(str_replace('Nr.', '', $number));
+
+ // Parse others
+ $address['others'] = trim($other);
+
+ return $address;
+ }
+
+ /**
+ * @return false|string
+ */
+ public function getRegisterDate()
+ {
+ $rawDate = trim(str_replace('INREGISTRAT din data ', '', $this->data['stare_inregistrare']));
+ return date("Y-m-d", strtotime($rawDate));
+ }
+
+ /**
+ * @return array
+ */
+ public function getData(): array
+ {
+ return $this->data;
+ }
+}
\ No newline at end of file
diff --git a/tests/Integrations/FlowTest.php b/tests/Integrations/FlowTest.php
new file mode 100644
index 0000000..b2dcd56
--- /dev/null
+++ b/tests/Integrations/FlowTest.php
@@ -0,0 +1,51 @@
+addCif("RO16826034");
+ $anaf->addCif("RO14399840");
+ $results = $anaf->get();
+
+ $this->assertEquals("DANTE INTERNATIONAL SA", $results[1]->getName());
+ }
+
+ public function testCUIList()
+ {
+ $anaf = new Client();
+ $anaf->addCif([
+ "RO16826034",
+ "RO14399840"
+ ]);
+ $results = $anaf->get();
+
+ $this->assertEquals("DANTE INTERNATIONAL SA", $results[1]->getName());
+ }
+
+ public function testOneCUI()
+ {
+ $anaf = new Client();
+ $anaf->addCif("RO14399840");
+ $results = $anaf->first();
+
+ $this->assertEquals("DANTE INTERNATIONAL SA", $results->getName());
+ }
+
+ public function testAddressParser()
+ {
+ $anaf = new Client();
+ $anaf->addCif("RO14399840");
+ $results = $anaf->first();
+
+ $this->assertEquals("Ilfov", $results->getAddress()->getCounty());
+ $this->assertEquals("Oraş Voluntari", $results->getAddress()->getCity());
+ $this->assertEquals("Şos. Bucureşti Nord", $results->getAddress()->getStreet());
+ $this->assertEquals("15-23", $results->getAddress()->getStreetNumber());
+ }
+}
diff --git a/tests/Test.php b/tests/Test.php
deleted file mode 100644
index 0bbe739..0000000
--- a/tests/Test.php
+++ /dev/null
@@ -1,50 +0,0 @@
-getInstance();
- $anaf->addCui("RO16826034");
- $anaf->addCui("RO14399840");
- $results = $anaf->getResults();
-
- $this->assertEquals("DANTE INTERNATIONAL SA", $results[1]->denumire);
- }
-
- public function testCUIList()
- {
- $anaf = $this->getInstance();
- $anaf->addCui([
- "RO16826034",
- "RO14399840"
- ]);
- $results = $anaf->getResults();
-
- $this->assertEquals("DANTE INTERNATIONAL SA", $results[1]->denumire);
- }
-
- public function testOneCUI()
- {
- $anaf = $this->getInstance();
- $anaf->addCui("RO14399840");
- $results = $anaf->getOneResult();
-
- $this->assertEquals("DANTE INTERNATIONAL SA", $results->denumire);
- }
-
- public function testAddressParser()
- {
- $anaf = $this->getInstance();
- $anaf->addCui("RO14399840");
- $results = $anaf->getOneResult();
-
- $this->assertEquals("Ilfov", $results->adresa->judet);
- $this->assertEquals("Oraş Voluntari", $results->adresa->localitate);
- $this->assertEquals("Şos. Bucureşti Nord", $results->adresa->strada);
- $this->assertEquals("15-23", $results->adresa->numar);
- }
-}
diff --git a/tests/TestCase.php b/tests/TestCase.php
deleted file mode 100644
index b3b748b..0000000
--- a/tests/TestCase.php
+++ /dev/null
@@ -1,17 +0,0 @@
-expectException(Exceptions\LimitExceeded::class);
+ $this->expectExceptionMessage("You can check one time up to 500 cifs.");
+
+ Http::call(array_fill(0, 501, '123456'));
+ }
+}
diff --git a/tests/Unit/Models/CompanyTest.php b/tests/Unit/Models/CompanyTest.php
new file mode 100644
index 0000000..b2b2cd4
--- /dev/null
+++ b/tests/Unit/Models/CompanyTest.php
@@ -0,0 +1,50 @@
+getMockBuilder(Parser::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $parset->expects($this->any())
+ ->method('getRegisterDate')
+ ->will($this->returnValue('2011-12-09'));
+
+ $address = [
+ 'county' => 'Municipiul Bucureşti',
+ 'city' => 'Sector 1',
+ 'street' => 'Şos. Bucureşti-Ploieşti',
+ 'streetNumber' => '172-176'
+ ];
+
+ $parset->expects($this->any())
+ ->method('getAddress')
+ ->will($this->returnValue($address));
+
+ $parset->expects($this->any())
+ ->method('getData')
+ ->will($this->returnValue([
+ 'cui' => 123456,
+ 'denumire' => 'Test',
+ 'telefon' => 07676000000,
+ ]));
+
+ $company = new Company($parset);
+ $this->assertEquals(123456, $company->getCIF());
+ $this->assertEquals("Test", $company->getName());
+ $this->assertEquals(07676000000, $company->getPhone());
+ $this->assertEquals("Municipiul Bucureşti", $company->getAddress()->getCounty());
+ $this->assertEquals("Sector 1", $company->getAddress()->getCity());
+ $this->assertEquals("Şos. Bucureşti-Ploieşti", $company->getAddress()->getStreet());
+ $this->assertEquals("172-176", $company->getAddress()->getStreetNumber());
+ }
+}
diff --git a/tests/Unit/ParserTest.php b/tests/Unit/ParserTest.php
new file mode 100644
index 0000000..7ea6e8f
--- /dev/null
+++ b/tests/Unit/ParserTest.php
@@ -0,0 +1,29 @@
+ 'MUNICIPIUL BUCUREŞTI, SECTOR 1, ŞOS. BUCUREŞTI-PLOIEŞTI, NR.172-176'
+ ]);
+
+ $this->assertEquals("Municipiul Bucureşti", $parser->getAddress()['county']);
+ $this->assertEquals("Sector 1", $parser->getAddress()['city']);
+ $this->assertEquals("Şos. Bucureşti-Ploieşti", $parser->getAddress()['street']);
+ $this->assertEquals("172-176", $parser->getAddress()['streetNumber']);
+ }
+
+ public function testRegisterDateParser()
+ {
+ $parser = new Parser([
+ 'stare_inregistrare' => 'INREGISTRAT din data 09.12.2011'
+ ]);
+
+ $this->assertEquals("2011-12-09", $parser->getRegisterDate());
+ }
+}