This commit is contained in:
2022-10-05 15:23:28 +02:00
parent 58b1778544
commit a967e1ed17
194 changed files with 1580 additions and 1386 deletions

View File

@@ -1,5 +1,14 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Services\Import;
use Chill\MainBundle\Entity\PostalCode;
@@ -9,11 +18,18 @@ use Chill\MainBundle\Service\Import\AddressReferenceBaseImporter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class AddressReferenceBaseImporterTest extends KernelTestCase
/**
* @internal
* @coversNothing
*/
final class AddressReferenceBaseImporterTest extends KernelTestCase
{
private AddressReferenceBaseImporter $importer;
private AddressReferenceRepository $addressReferenceRepository;
private EntityManagerInterface $entityManager;
private AddressReferenceBaseImporter $importer;
private PostalCodeRepository $postalCodeRepository;
protected function setUp(): void
@@ -30,7 +46,7 @@ class AddressReferenceBaseImporterTest extends KernelTestCase
public function testImportAddress(): void
{
$postalCode = (new PostalCode())
->setRefPostalCodeId($postalCodeId = '1234'.uniqid())
->setRefPostalCodeId($postalCodeId = '1234' . uniqid())
->setPostalCodeSource('testing')
->setCode('TEST456')
->setName('testing');
@@ -54,7 +70,8 @@ class AddressReferenceBaseImporterTest extends KernelTestCase
$addresses = $this->addressReferenceRepository->findByPostalCodePattern(
$postalCode,
'Rue test abcc guessed');
'Rue test abcc guessed'
);
$this->assertCount(1, $addresses);
$this->assertEquals('Rue test abccc-guessed', $addresses[0]->getStreet());
@@ -79,12 +96,11 @@ class AddressReferenceBaseImporterTest extends KernelTestCase
$addresses = $this->addressReferenceRepository->findByPostalCodePattern(
$postalCode,
'abcc guessed fixed');
'abcc guessed fixed'
);
$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());
}
}
}

View File

@@ -1,5 +1,14 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Services\Import;
use Chill\MainBundle\Service\Import\GeographicalUnitBaseImporter;
@@ -8,7 +17,11 @@ use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\NullLogger;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class GeographicalUnitBaseImporterTest extends KernelTestCase
/**
* @internal
* @coversNothing
*/
final class GeographicalUnitBaseImporterTest extends KernelTestCase
{
private Connection $connection;
@@ -42,10 +55,10 @@ class GeographicalUnitBaseImporterTest extends KernelTestCase
$importer->finalize();
$unit = $this->connection->executeQuery("
$unit = $this->connection->executeQuery('
SELECT unitname, unitrefid, cmgul.refid AS layerrefid, cmgul.name AS layername, ST_AsText(ST_snapToGrid(ST_Transform(u.geom, 3812), 1)) AS geom
FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id
WHERE u.unitrefid = ?", ['layer_one']);
FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id
WHERE u.unitrefid = ?', ['layer_one']);
$results = $unit->fetchAssociative();
@@ -71,10 +84,10 @@ class GeographicalUnitBaseImporterTest extends KernelTestCase
$importer->finalize();
$unit = $this->connection->executeQuery("
$unit = $this->connection->executeQuery('
SELECT unitname, unitrefid, cmgul.refid AS layerrefid, cmgul.name AS layername, ST_AsText(ST_snapToGrid(ST_Transform(u.geom, 3812), 1)) AS geom
FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id
WHERE u.unitrefid = ?", ['layer_one']);
FROM chill_main_geographical_unit u JOIN chill_main_geographical_unit_layer cmgul on u.layer_id = cmgul.id
WHERE u.unitrefid = ?', ['layer_one']);
$results = $unit->fetchAssociative();
@@ -83,7 +96,5 @@ class GeographicalUnitBaseImporterTest extends KernelTestCase
$this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']);
$this->assertEquals($results['layerrefid'], 'test');
$this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))');
}
}
}

View File

@@ -1,5 +1,14 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Services\Import;
use Chill\MainBundle\Repository\CountryRepository;
@@ -8,16 +17,20 @@ use Chill\MainBundle\Service\Import\PostalCodeBaseImporter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class PostalCodeBaseImporterTest extends KernelTestCase
/**
* @internal
* @coversNothing
*/
final class PostalCodeBaseImporterTest extends KernelTestCase
{
private CountryRepository $countryRepository;
private EntityManagerInterface $entityManager;
private PostalCodeBaseImporter $importer;
private PostalCodeRepository $postalCodeRepository;
private CountryRepository $countryRepository;
protected function setUp(): void
{
parent::setUp();
@@ -34,9 +47,9 @@ class PostalCodeBaseImporterTest extends KernelTestCase
{
$this->importer->importCode(
'BE',
'tested with pattern '. ($uniqid = uniqid()),
'tested with pattern ' . ($uniqid = uniqid()),
'12345',
$refPostalCodeId = 'test'.uniqid(),
$refPostalCodeId = 'test' . uniqid(),
'test',
50.0,
5.0,
@@ -46,8 +59,8 @@ class PostalCodeBaseImporterTest extends KernelTestCase
$this->importer->finalize();
$postalCodes = $this->postalCodeRepository->findByPattern(
'with pattern '.$uniqid,
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
'with pattern ' . $uniqid,
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
);
$this->assertCount(1, $postalCodes);
@@ -59,7 +72,7 @@ class PostalCodeBaseImporterTest extends KernelTestCase
$this->importer->importCode(
'BE',
'tested with adapted pattern '. ($uniqid = uniqid()),
'tested with adapted pattern ' . ($uniqid = uniqid()),
'12345',
$refPostalCodeId,
'test',
@@ -71,7 +84,7 @@ class PostalCodeBaseImporterTest extends KernelTestCase
$this->importer->finalize();
$postalCodes = $this->postalCodeRepository->findByPattern(
'with pattern '.$uniqid,
'with pattern ' . $uniqid,
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
);
@@ -79,7 +92,4 @@ class PostalCodeBaseImporterTest extends KernelTestCase
$this->assertStringStartsWith('tested with adapted pattern', $postalCodes[0]->getName());
$this->assertEquals($previousId, $postalCodes[0]->getId());
}
}
}