Skip to content
Snippets Groups Projects
Commit 90da0d4d authored by Julien LE GALL's avatar Julien LE GALL
Browse files

Merge branch '1249-simplifier-les-tests-d-integration' into 'master'

Suppression du LegacyObjectInstancier dans les tests d'integration

Closes #1249

See merge request libriciel/pole-plate-formes/s2low/s2low!817
parents 71b71c63 576dd440
No related branches found
No related tags found
No related merge requests found
Pipeline #92478 failed
......@@ -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
{
......
......@@ -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
......
......@@ -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'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment