From 7316959cf835b92f8184cecc21b7d80ff9e8704d Mon Sep 17 00:00:00 2001 From: Albin Date: Sun, 7 Jan 2024 22:08:48 +0100 Subject: [PATCH] #1416 test environment --- .github/workflows/ci.yml | 15 ++++++-- Makefile | 4 +-- htdocs/pages/administration/configuration.php | 15 -------- sources/Afup/Bootstrap/Http.php | 8 ++--- sources/Afup/Utils/Configuration.php | 35 ++++++++----------- sources/Afup/Utils/SymfonyKernel.php | 2 +- 6 files changed, 34 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0deead04f..9d69e0b81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,12 @@ jobs: - name: Composer install run: composer install --no-scripts + - name: Config file + run: make configs/application/config.php + + - name: Parameters file + run: make app/config/parameters.yml + - name: Tests - Unit run: ./bin/atoum @@ -66,10 +72,10 @@ jobs: restore-keys: | ${{ runner.os }}-composer- - - name: CS fixer prerequisites config + - name: Config file run: make configs/application/config.php - - name: CS fixer prerequisites parameters + - name: Parameters file run: make app/config/parameters.yml - name: Composer install @@ -103,9 +109,12 @@ jobs: restore-keys: | ${{ runner.os }}-composer- - - name: Prerequisites + - name: Config file run: make configs/application/config.php + - name: Parameters file + run: make app/config/parameters.yml + - name: Composer install run: composer install --no-scripts --ignore-platform-req=php 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/htdocs/pages/administration/configuration.php b/htdocs/pages/administration/configuration.php index 49ea1c6ac..ad1139509 100644 --- a/htdocs/pages/administration/configuration.php +++ b/htdocs/pages/administration/configuration.php @@ -14,21 +14,6 @@ $formulaire->setDefaults($defaults); -$formulaire->addElement('header' , '' , 'Mails'); -$formulaire->addElement('text' , 'mails|email_expediteur' , 'Email expediteur' , array('size' => 30)); -$formulaire->addElement('text' , 'mails|nom_expediteur' , 'Nom expediteur' , array('size' => 30)); -$formulaire->addElement('textarea', 'mails|texte_adhesion_personne_physique', 'Texte adhesion personne physique', array('cols' => 42, 'rows' => 7)); -$formulaire->addElement('text' , 'mails|force_destinataire' , 'Force le destinaire du mail pour test' , array('size' => 30)); -$formulaire->addElement('text' , 'mails|bcc' , 'Ajout un email en bcc à tout les emailss' , array('size' => 30)); - - -$formulaire->addElement('header' , '' , 'Config SMTP'); -$formulaire->addElement('text' , 'mails|serveur_smtp' , 'Serveur SMTP' , array('size' => 30)); -$formulaire->addElement('advcheckbox', 'mails|tls' , 'Use TLS' , null, null, array(0, 1)); -$formulaire->addElement('text' , 'mails|port' , 'Port' , array('size' => 30)); -$formulaire->addElement('text' , 'mails|username' , 'Username' , array('size' => 30)); -$formulaire->addElement('text' , 'mails|password' , 'Password' , array('size' => 30)); - $formulaire->addElement('header' , '' , 'AFUP'); $formulaire->addElement('text' , 'afup|raison_sociale', 'Raison Sociale', array('size' => 30)); $formulaire->addElement('textarea', 'afup|adresse' , 'Adresse' , array('cols' => 42, 'rows' => 7)); 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';