mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
test for postal code base importer
This commit is contained in:
parent
658e846120
commit
8129739d27
@ -59,6 +59,8 @@ class AddressReferenceBaseImporterTest extends KernelTestCase
|
|||||||
$this->assertCount(1, $addresses);
|
$this->assertCount(1, $addresses);
|
||||||
$this->assertEquals('Rue test abccc-guessed', $addresses[0]->getStreet());
|
$this->assertEquals('Rue test abccc-guessed', $addresses[0]->getStreet());
|
||||||
|
|
||||||
|
$previousAddressId = $addresses[0]->getId();
|
||||||
|
|
||||||
$this->entityManager->clear();
|
$this->entityManager->clear();
|
||||||
|
|
||||||
$this->importer->importAddress(
|
$this->importer->importAddress(
|
||||||
@ -81,6 +83,7 @@ class AddressReferenceBaseImporterTest extends KernelTestCase
|
|||||||
|
|
||||||
$this->assertCount('1', $addresses);
|
$this->assertCount('1', $addresses);
|
||||||
$this->assertEquals( 'Rue test abccc guessed fixed', $addresses[0]->getStreet());
|
$this->assertEquals( 'Rue test abccc guessed fixed', $addresses[0]->getStreet());
|
||||||
|
$this->assertEquals($previousAddressId, $addresses[0]->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Services\Import;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Repository\CountryRepository;
|
||||||
|
use Chill\MainBundle\Repository\PostalCodeRepository;
|
||||||
|
use Chill\MainBundle\Service\Import\PostalCodeBaseImporter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
|
||||||
|
class PostalCodeBaseImporterTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
private PostalCodeBaseImporter $importer;
|
||||||
|
|
||||||
|
private PostalCodeRepository $postalCodeRepository;
|
||||||
|
|
||||||
|
private CountryRepository $countryRepository;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
$this->entityManager = self::$container->get(EntityManagerInterface::class);
|
||||||
|
$this->importer = self::$container->get(PostalCodeBaseImporter::class);
|
||||||
|
$this->postalCodeRepository = self::$container->get(PostalCodeRepository::class);
|
||||||
|
$this->countryRepository = self::$container->get(CountryRepository::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testImportPostalCode(): void
|
||||||
|
{
|
||||||
|
$this->importer->importCode(
|
||||||
|
'BE',
|
||||||
|
'tested with pattern '. ($uniqid = uniqid()),
|
||||||
|
'12345',
|
||||||
|
$refPostalCodeId = 'test'.uniqid(),
|
||||||
|
'test',
|
||||||
|
50.0,
|
||||||
|
5.0,
|
||||||
|
4326
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->importer->finalize();
|
||||||
|
|
||||||
|
$postalCodes = $this->postalCodeRepository->findByPattern(
|
||||||
|
'with pattern '.$uniqid,
|
||||||
|
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertCount(1, $postalCodes);
|
||||||
|
$this->assertStringStartsWith('tested with pattern', $postalCodes[0]->getName());
|
||||||
|
|
||||||
|
$previousId = $postalCodes[0]->getId();
|
||||||
|
|
||||||
|
$this->entityManager->clear();
|
||||||
|
|
||||||
|
$this->importer->importCode(
|
||||||
|
'BE',
|
||||||
|
'tested with adapted pattern '. ($uniqid = uniqid()),
|
||||||
|
'12345',
|
||||||
|
$refPostalCodeId,
|
||||||
|
'test',
|
||||||
|
50.0,
|
||||||
|
5.0,
|
||||||
|
4326
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->importer->finalize();
|
||||||
|
|
||||||
|
$postalCodes = $this->postalCodeRepository->findByPattern(
|
||||||
|
'with pattern '.$uniqid,
|
||||||
|
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertCount(1, $postalCodes);
|
||||||
|
$this->assertStringStartsWith('tested with adapted pattern', $postalCodes[0]->getName());
|
||||||
|
$this->assertEquals($previousId, $postalCodes[0]->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user