From 12d2a7b108bdff6ab9644b460d56e03d5cd12d23 Mon Sep 17 00:00:00 2001 From: Albin Date: Sun, 7 Jan 2024 22:08:48 +0100 Subject: [PATCH] #1416 test environment --- Makefile | 4 ++-- sources/Afup/Bootstrap/Http.php | 8 +++---- sources/Afup/Utils/Configuration.php | 35 ++++++++++++---------------- sources/Afup/Utils/SymfonyKernel.php | 2 +- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 46616855c..d1dc78711 100644 --- a/Makefile +++ b/Makefile @@ -74,8 +74,8 @@ test: test-functional: data config htdocs/uploads CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) stop dbtest apachephptest planetetest mailcatcher CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) up -d dbtest apachephptest planetetest mailcatcher - CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm cliphp ./bin/behat - CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm cliphp ./bin/behat -c behat-planete.yml + CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm apachephptest ./bin/behat + CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm planetetest ./bin/behat -c behat-planete.yml CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) stop dbtest apachephptest planetetest mailcatcher data: diff --git a/sources/Afup/Bootstrap/Http.php b/sources/Afup/Bootstrap/Http.php index 7f7b961ef..cd9d83868 100644 --- a/sources/Afup/Bootstrap/Http.php +++ b/sources/Afup/Bootstrap/Http.php @@ -31,12 +31,12 @@ } // mise à jour des paramétrages PHP en fonction de la configuration -if ($_ENV['SYMFONY_ENV'] === 'dev') { - ini_set('error_reporting', E_ALL); - ini_set('display_errors', 1); -} else { +if (isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] === 'prod') { ini_set('error_reporting', E_ALL ^ E_WARNING); ini_set('display_errors', 0); +} else { + ini_set('error_reporting', E_ALL); + ini_set('display_errors', 1); } ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(__FILE__).'/../../../dependencies/PEAR/'); diff --git a/sources/Afup/Utils/Configuration.php b/sources/Afup/Utils/Configuration.php index 0e78803d7..0a9d097b2 100644 --- a/sources/Afup/Utils/Configuration.php +++ b/sources/Afup/Utils/Configuration.php @@ -2,8 +2,6 @@ namespace Afup\Site\Utils; -use Symfony\Component\Yaml\Yaml; - define('EURO', '€'); /** @@ -37,24 +35,21 @@ public function __construct($chemin_fichier) $this->_chemin_fichier = $chemin_fichier; $this->_valeurs = include($this->_chemin_fichier); - $parametersFile = dirname(__FILE__).'/../../../app/config/parameters.yml'; - if (is_file($parametersFile)) { - $parameters = Yaml::parseFile($parametersFile)['parameters']; - - $this->_valeurs['bdd']['hote'] = $parameters['database_host']; - $this->_valeurs['bdd']['base'] = $parameters['database_name']; - $this->_valeurs['bdd']['utilisateur'] = $parameters['database_user']; - $this->_valeurs['bdd']['mot_de_passe'] = $parameters['database_password']; - - $this->_valeurs['mails']['serveur_smtp'] = $parameters['mails_serveur_smtp']; - $this->_valeurs['mails']['tls'] = $parameters['mails_tls']; - $this->_valeurs['mails']['username'] = $parameters['mails_username']; - $this->_valeurs['mails']['password'] = $parameters['mails_password']; - $this->_valeurs['mails']['port'] = $parameters['mails_port']; - - $this->_valeurs['mails']['force_destinataire'] = $parameters['mails_force_destinataire']; - $this->_valeurs['mails']['bcc'] = $parameters['mails_bcc']; - } + $kernel = new SymfonyKernel(); + $container = $kernel->getKernel()->getContainer(); + + $this->_valeurs['bdd']['hote'] = $container->getParameter('database_host'); + $this->_valeurs['bdd']['base'] = $container->getParameter('database_name'); + $this->_valeurs['bdd']['utilisateur'] = $container->getParameter('database_user'); + $this->_valeurs['bdd']['mot_de_passe'] = $container->getParameter('database_password'); + + $this->_valeurs['mails']['serveur_smtp'] = $container->getParameter('mails_serveur_smtp'); + $this->_valeurs['mails']['tls'] = $container->getParameter('mails_tls'); + $this->_valeurs['mails']['username'] = $container->getParameter('mails_username'); + $this->_valeurs['mails']['password'] = $container->getParameter('mails_password'); + $this->_valeurs['mails']['port'] = $container->getParameter('mails_port'); + $this->_valeurs['mails']['force_destinataire'] = $container->getParameter('mails_force_destinataire'); + $this->_valeurs['mails']['bcc'] = $container->getParameter('mails_bcc'); } /** diff --git a/sources/Afup/Utils/SymfonyKernel.php b/sources/Afup/Utils/SymfonyKernel.php index 20e8f5352..fa6ffcf6a 100644 --- a/sources/Afup/Utils/SymfonyKernel.php +++ b/sources/Afup/Utils/SymfonyKernel.php @@ -21,7 +21,7 @@ public function __construct(Request $request = null) $env = 'prod'; $debug = false; - if ($_ENV['SYMFONY_ENV'] === 'dev') { + if (isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] === 'dev') { Debug::enable(E_WARNING); $debug = true; $env = 'dev';