From 10a75f44e9f7a7165c03ca3b99e829c90ec840a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 1 Sep 2023 16:09:54 +0200 Subject: [PATCH] Ensure kernel shutdown after abstract export tests --- .../Test/Export/AbstractExportTest.php | 47 +------------------ .../Test/Export/AbstractFilterTest.php | 2 +- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php index 342236a6c..38298490e 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractExportTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Test\Export; use Chill\MainBundle\Test\PrepareClientTrait; +use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\NativeQuery; use Doctrine\ORM\QueryBuilder; use RuntimeException; @@ -29,8 +30,6 @@ use function is_string; * * The tests provided by this class will check basic things, like * the type of value are conform to the expected, etc. - * - * @internal */ abstract class AbstractExportTest extends WebTestCase { @@ -78,8 +77,7 @@ abstract class AbstractExportTest extends WebTestCase static::bootKernel(); } - $em = static::$kernel->getContainer() - ->get('doctrine.orm.entity_manager'); + $em = static::$container->get(EntityManagerInterface::class); $centers = $em->getRepository(\Chill\MainBundle\Entity\Center::class) ->findAll(); @@ -244,11 +242,6 @@ abstract class AbstractExportTest extends WebTestCase is_callable($closure, false), 'test that the `getLabels` for key is a callable' ); - $this->assertTrue( - is_string((string) call_user_func($closure, $value)), - sprintf('test that the callable return by `getLabels` for key %s ' - . 'is a string or an be converted to a string', $key) - ); $this->assertTrue( // conditions @@ -320,42 +313,6 @@ abstract class AbstractExportTest extends WebTestCase } } - /** - * Test that the translated title of the export is present the list, - * and that the list of exports (under `/fr/exports/`) is still successfull. - */ - public function testListExportPage() - { - /** @var HttpBrowser $client */ - $client = new HttpBrowser(); - - $export = $this->getExport(); - $prophet = new \Prophecy\Prophet(); - $container = static::$kernel->getContainer(); - - // store the locale in a request - $request = new Request(); - $request->setLocale('fr'); - $container->get('request_stack')->push($request); - // translate the title - $title = $container->get('translator')->trans($export->getTitle()); - - // performs the request to /fr/exports - $crawler = $client->request('GET', '/fr/exports/'); - - // and finally make tests - $this->assertTrue( - $client->getResponse()->isSuccessful(), - 'test that the response of /fr/exports/ is successful' - ); - $this->assertStringContainsString( - $title, - $crawler->text(), - 'test that the page /fr/exports/ contains the title of the ' - . "exports ('{$title}')" - ); - } - /** * Test required role is an instance of Role. */ diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index 37455799d..2f79abc3d 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -38,7 +38,7 @@ abstract class AbstractFilterTest extends KernelTestCase $this->prophet = $this->getProphet(); } - protected function tearDown(): void + public static function tearDownAfterClass(): void { self::ensureKernelShutdown(); }