Fix tests

This commit is contained in:
Julien Fastré 2023-09-01 16:10:04 +02:00
parent 10a75f44e9
commit 2c52a5bffa
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
9 changed files with 22 additions and 21 deletions

View File

@ -27,6 +27,12 @@ use function is_string;
*/
abstract class AbstractAggregatorTest extends KernelTestCase
{
public static function tearDownAfterClass(): void
{
self::ensureKernelShutdown();
}
/**
* provide data for `testAliasDidNotDisappears`.
*/

View File

@ -29,11 +29,6 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
private AddressRepository $addressRepository;
protected function setUp(): void
{
$this->addressRepository = self::$container->get(AddressRepository::class);
}
protected function tearDown(): void
{
self::ensureKernelShutdown();
@ -50,6 +45,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$this->addressRepository = self::$container->get(AddressRepository::class);
$address = $this->addressRepository->find($addressId);
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_REVIEWED, $address->getRefStatus());
@ -66,6 +62,7 @@ class AddressToReferenceMatcherControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
$this->addressRepository = self::$container->get(AddressRepository::class);
$address = $this->addressRepository->find($addressId);
$this->assertEquals(Address::ADDR_REFERENCE_STATUS_MATCH, $address->getRefStatus());

View File

@ -58,7 +58,7 @@ final class DefaultScopeResolverTest extends TestCase
public function getScopes(): iterable
{
return $this->scopes;
return [$this->scopeA, $this->scopeB];
}
};

View File

@ -50,7 +50,8 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
{
private array $slugs = [];
public function __construct(private readonly ExportAddressHelper $addressHelper, private readonly CustomFieldProvider $customFieldProvider, private readonly ListPersonHelper $listPersonHelper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringHelper $translatableStringHelper)
public function __construct(
private readonly ExportAddressHelper $addressHelper, private readonly CustomFieldProvider $customFieldProvider, private readonly ListPersonHelper $listPersonHelper, private readonly EntityManagerInterface $entityManager, private readonly TranslatableStringHelper $translatableStringHelper)
{
}

View File

@ -180,7 +180,6 @@ final class PersonControllerCreateTest extends WebTestCase
$form = $crawler->selectButton("Créer l'usager")->form();
$this->fillAValidCreationForm($form, uniqid(), uniqid());
$client = $this->client;
$client->submit($form);
self::assertResponseRedirects();

View File

@ -15,7 +15,6 @@ use Chill\MainBundle\Test\PrepareClientTrait;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Relationships\Relation;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
use function array_rand;
@ -116,7 +115,7 @@ final class RelationshipApiControllerTest extends WebTestCase
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/relations/relationship/by-person/%d.json', $personId));
$response = $this->client->getResponse();
$response = $client->getResponse();
$this->assertEquals(200, $response->getStatusCode(), 'Test to see that API response returns a status code 200');
}

View File

@ -27,7 +27,7 @@ final class CountAccompanyingPeriodWorkTest extends AbstractExportTest
{
self::bootKernel();
$this->export = self::$container->get('chill.person.export.count_social_work_actions');
$this->export = self::$container->get(CountAccompanyingPeriodWork::class);
}
public function getExport()

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Export\CountPerson;
/**
* Test CountPerson export.
@ -30,7 +31,7 @@ final class CountPersonTest extends AbstractExportTest
{
self::bootKernel();
$this->export = self::$container->get('chill.person.export.count_person');
$this->export = self::$container->get(CountPerson::class);
}
public function getExport()

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Export;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Chill\PersonBundle\Export\Export\ListPerson;
use DateTime;
@ -32,7 +33,7 @@ final class ListPersonTest extends AbstractExportTest
{
self::bootKernel();
$this->export = self::$container->get('chill.person.export.list_person');
$this->export = self::$container->get(ListPerson::class);
$request = $this->prophesize()
->willExtend(\Symfony\Component\HttpFoundation\Request::class);
@ -48,20 +49,17 @@ final class ListPersonTest extends AbstractExportTest
return $this->export;
}
public function getFormData(): array
public function getFormData(): iterable
{
return [
foreach ([
['fields' => ['id', 'firstName', 'lastName']],
['fields' => ['id', 'birthdate', 'gender', 'memo', 'email', 'phonenumber']],
['fields' => ['firstName', 'lastName', 'phonenumber']],
['fields' => ['id', 'nationality']],
['fields' => ['id', 'countryOfBirth']],
['fields' => ['id', 'address_street_address_1',
'address_street_address_2', 'address_valid_from',
'address_postcode_label', 'address_postcode_code',
'address_country_name', 'address_country_code', ],
'address_date' => DateTime::createFromFormat('Y-m-d', '2016-06-12'), ],
];
] as $base) {
yield [...$base, 'address_date' => new \DateTimeImmutable('today') ];
}
}
public function getModifiersCombination(): array