diff --git a/integration_tests/ActesIntegrationTest.php b/integration_tests/ActesIntegrationTest.php index f1a35775d0cd067a05ccd850c90f0b14b72e56fb..62acc8ffec617414fd4a4ca659ea52afb559cfb1 100644 --- a/integration_tests/ActesIntegrationTest.php +++ b/integration_tests/ActesIntegrationTest.php @@ -20,9 +20,8 @@ class ActesIntegrationTest extends S2lowIntegrationTestCase protected function setUp(): void { - $this->setUpWithoutDeletingObjectInstancier(); - $this->actesTransactionsSQL = ObjectInstancierFactory::getObjetInstancier()->get(ActesTransactionsSQL::class); - ObjectInstancierFactory::resetObjectInstancier(); //DatabasePool utilise ObjectInstancier + parent::setUp(); + $this->actesTransactionsSQL = new ActesTransactionsSQL($this->sqlQuery); } protected function tearDown(): void { diff --git a/integration_tests/HeliosIntegrationTest.php b/integration_tests/HeliosIntegrationTest.php index bfdb417d52a68f12c57f1c5d982f1656fcf893c8..6450557373ec4601f08fc1dc25f4cd5a84d20b1c 100644 --- a/integration_tests/HeliosIntegrationTest.php +++ b/integration_tests/HeliosIntegrationTest.php @@ -18,9 +18,8 @@ class HeliosIntegrationTest extends S2lowIntegrationTestCase protected function setUp(): void { - $this->setUpWithoutDeletingObjectInstancier(); - $this->heliosTransactionsSQL = ObjectInstancierFactory::getObjetInstancier()->get(HeliosTransactionsSQL::class); - ObjectInstancierFactory::resetObjectInstancier(); + parent::setUp(); + $this->heliosTransactionsSQL = new HeliosTransactionsSQL($this->sqlQuery); } protected function tearDown(): void diff --git a/integration_tests/S2lowIntegrationTestCase.php b/integration_tests/S2lowIntegrationTestCase.php index 374418a3b9867ad281be50391f1e848d88401fa5..aea8bfab6b024fc62afb568a9edbe9423e8598f0 100644 --- a/integration_tests/S2lowIntegrationTestCase.php +++ b/integration_tests/S2lowIntegrationTestCase.php @@ -3,8 +3,6 @@ namespace IntegrationTests; use S2lowLegacy\Class\LegacyObjectsManager; -use S2lowLegacy\Lib\ObjectInstancier; -use S2lowLegacy\Lib\ObjectInstancierFactory; use S2lowLegacy\Lib\PemCertificateFactory; use S2lowLegacy\Lib\SQLQuery; use Symfony\Bundle\FrameworkBundle\KernelBrowser; @@ -12,7 +10,6 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class S2lowIntegrationTestCase extends WebTestCase { - /** @var SQLQuery */ protected SQLQuery $sqlQuery; protected PemCertificateFactory $pemCertificateFactory; @@ -31,14 +28,30 @@ class S2lowIntegrationTestCase extends WebTestCase */ protected function setUp(): void { - $this->setUpWithoutDeletingObjectInstancier(); - ObjectInstancierFactory::resetObjectInstancier(); //DatabasePool utilise ObjectInstancier + $_SESSION = []; + $_GET = []; + $_POST = []; + $_SERVER['QUERY_STRING'] = ''; + $this->sqlQuery = new SQLQuery(DB_DATABASE_TEST); + $this->sqlQuery->setCredential(DB_USER_TEST, DB_PASSWORD_TEST); + $this->sqlQuery->setDatabaseHost(DB_HOST_TEST); + $this->pemCertificateFactory = new PemCertificateFactory(); + $this->sqlQuery->exec(file_get_contents(__DIR__ . '/fixtures/s2low-test-init.sql')); + parent::setUp(); } protected function tearDown(): void { + self::ensureKernelShutdown(); + LegacyObjectsManager::resetObjectInstancier(); //Evite les interactions entre tests via + // L'objectInstancier. + // Normalement on ne devrait pas modifier l'ObjectInstancier pour les tests d'intégration + // Mais on ne sait jamais ... + $_SESSION = []; + $_GET = []; + $_POST = []; + $_SERVER['QUERY_STRING'] = ''; // Evite le message postgres phpunit désolé, trop de clients sont déjà connectés - // TODO : ce disconnect serait-il nécessaire ailleurs ? $this->sqlQuery->disconnect(); parent::tearDown(); } @@ -108,28 +121,6 @@ class S2lowIntegrationTestCase extends WebTestCase $certificatePem->getContentStrippedFromBegin() ); - ObjectInstancierFactory::resetObjectInstancier(); return $client; } - - /** - * @return void - */ - protected function setUpWithoutDeletingObjectInstancier(): void - { - parent::setUp(); - LegacyObjectsManager::resetObjectInstancier(); - $_SESSION = []; - $_GET = []; - $_POST = []; - //$_SERVER = []; - $_SERVER['QUERY_STRING'] = ''; - ObjectInstancierFactory::setObjectInstancier(new ObjectInstancier()); //DatabasePool utilise ObjectInstancier - $this->sqlQuery = new SQLQuery(DB_DATABASE_TEST); // On en crée un le temps de Mà J la BDD - $this->sqlQuery->setCredential(DB_USER_TEST, DB_PASSWORD_TEST); // On le ressettera ensuite - $this->sqlQuery->setDatabaseHost(DB_HOST_TEST); - ObjectInstancierFactory::getObjetInstancier()->set(SQLQuery::class, $this->sqlQuery); - $this->pemCertificateFactory = new PemCertificateFactory(); - $this->sqlQuery->exec(file_get_contents(__DIR__ . '/fixtures/s2low-test-init.sql')); - } }