Commit ddf3a8cb authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Nouvelle commande permettant de lancer des tests

Possibilité d'accéder au container directement depuis l'admin ou les tests avec OseAdmin ($os->getContainer()
parent cd68ad03
Loading
Loading
Loading
Loading
+1
Changes for Dockerfile: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ RUN ln -sf /dev/stderr /var/log/apache2/error.log

# Lien pour l'exécutable interne de OSE
RUN ln -sf /app/bin/ose /usr/local/bin/ose
RUN ln -sf /app/bin/ose-test /usr/local/bin/ose-test

# Config PHP.
ADD docker/${APPLICATION_ENV}/php.conf ${PHP_CONF_DIR}/fpm/conf.d/app.ini
+32 −3
Changes for admin/src/OseAdmin.php: 32 added lines, 3 removed lines.
Original line number Diff line number Diff line
<?php





class OseAdmin
{
    const OSE_ORIGIN  = 'https://git.unicaen.fr/open-source/OSE.git';
@@ -47,6 +44,8 @@ class OseAdmin
     */
    public $version;

    private ?\Psr\Container\ContainerInterface $container = null;



    private function __construct()
@@ -265,6 +264,36 @@ class OseAdmin



    public function getContainer(): \Psr\Container\ContainerInterface
    {
        if (empty($this->container)){
            require_once $this->getOseDir().'config/application.config.php';

            Application::init();
            Application::start();
            $this->container = Application::$container;
        }

        return $this->container;
    }



    public function test(string $action)
    {
        $cible = $this->getOseDir() . 'test/'.$action.'.php';

        if (!file_exists($cible)){
            $this->console->printDie("Le fichier $cible n'existe pas");
        }

        $oa = $this;
        $c = $this->console;
        require_once($cible);
    }



    public function getEnv(): string
    {
        return getenv('APPLICATION_ENV') ?: 'dev';
+x+10
Changes for bin/ose-test: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/usr/bin/env php
<?php

require_once dirname(__DIR__) . '/admin/src/OseAdmin.php';

$oa = OseAdmin::getInstance();

$c = $oa->getConsole();

$oa->test($c->getArg(1) ?: 'help');
 No newline at end of file