Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Velhron committed Jul 9, 2020
1 parent d47969a commit fbdb872
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
21 changes: 14 additions & 7 deletions tests/Service/DadataCleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

namespace Velhron\DadataBundle\Tests\Service;

use Velhron\DadataBundle\Service\DadataClean;

class DadataCleanTest extends DadataServiceTest
{
protected function createService(string $mockFilepath): DadataClean
{
return new DadataClean('', '', $this->resolver, $this->getMockHttpClient($mockFilepath));
}

public function testCleanAddress(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/address.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/address.json');
$result = $service->cleanAddress('мск сухонска 11/-89');

$this->assertEquals(0, $result->qc);
Expand All @@ -18,7 +25,7 @@ public function testCleanAddress(): void

public function testCleanPhone(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/phone.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/phone.json');
$result = $service->cleanPhone('раб 846)231.60.14 *139');

$this->assertEquals('+7 846 231-60-14 доб. 139', $result->phone);
Expand All @@ -27,7 +34,7 @@ public function testCleanPhone(): void

public function testCleanPassport(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/passport.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/passport.json');
$result = $service->cleanPassport('4509 235857');

$this->assertEquals('45 09', $result->series);
Expand All @@ -36,23 +43,23 @@ public function testCleanPassport(): void

public function testCleanBirthdate(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/birthdate.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/birthdate.json');
$result = $service->cleanBirthdate('24/3/12');

$this->assertEquals('24.03.2012', $result->birthdate);
}

public function testCleanVehicle(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/vehicle.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/vehicle.json');
$result = $service->cleanVehicle('бмв');

$this->assertEquals('BMW', $result->brand);
}

public function testCleanName(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/name.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/name.json');
$result = $service->cleanName('Срегей владимерович иванов');

$this->assertEquals('Иванов', $result->surname);
Expand All @@ -62,7 +69,7 @@ public function testCleanName(): void

public function testCleanEmail(): void
{
$service = $this->createCleanService(__DIR__.'/../Mock/Clean/email.json');
$service = $this->createService(__DIR__.'/../mocks/Clean/email.json');
$result = $service->cleanEmail('serega@yandex/ru');

$this->assertEquals('[email protected]', $result->email);
Expand Down
11 changes: 9 additions & 2 deletions tests/Service/DadataGeolocateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

namespace Velhron\DadataBundle\Tests\Service;

use Velhron\DadataBundle\Service\DadataGeolocate;

class DadataGeolocateTest extends DadataServiceTest
{
protected function createService(string $mockFilepath): DadataGeolocate
{
return new DadataGeolocate('', '', $this->resolver, $this->getMockHttpClient($mockFilepath));
}

public function testGeolocateAddress(): void
{
$service = $this->createGeolocateService(__DIR__.'/../Mock/Geolocate/address.json');
$service = $this->createGeolocateService(__DIR__.'/../mocks/Geolocate/address.json');
$result = $service->geolocateAddress(55.878, 37.653);

$this->assertEquals('г Москва, ул Сухонская, д 11', $result[0]->value);
Expand All @@ -17,7 +24,7 @@ public function testGeolocateAddress(): void

public function testGeolocatePostalUnit(): void
{
$service = $this->createGeolocateService(__DIR__.'/../Mock/Geolocate/postalUnit.json');
$service = $this->createGeolocateService(__DIR__.'/../mocks/Geolocate/postalUnit.json');
$result = $service->geolocatePostalUnit(55.878, 37.653, ['radius_meters' => 1000]);

$this->assertEquals('127642', $result[0]->postalCode);
Expand Down
9 changes: 8 additions & 1 deletion tests/Service/DadataIplocateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@

namespace Velhron\DadataBundle\Tests\Service;

use Velhron\DadataBundle\Service\DadataIplocate;

class DadataIplocateTest extends DadataServiceTest
{
protected function createService(string $mockFilepath): DadataIplocate
{
return new DadataIplocate('', '', $this->resolver, $this->getMockHttpClient($mockFilepath));
}

public function testIplocateAddress(): void
{
$service = $this->createIplocateService(__DIR__.'/../Mock/Iplocate/address.json');
$service = $this->createIplocateService(__DIR__.'/../mocks/Iplocate/address.json');
$result = $service->iplocateAddress('46.226.227.20');

$this->assertEquals('г Белгород', $result->value);
Expand Down

0 comments on commit fbdb872

Please sign in to comment.