From 9ab17b5320eada2024bbe733dd2677a959b1f5d9 Mon Sep 17 00:00:00 2001 From: Domingo Oropeza Date: Thu, 13 Sep 2018 16:03:20 -0400 Subject: [PATCH] feat(install): set default user for cli_install Signed-off-by: Domingo Oropeza --- phpunit/0_Install/FusinvInstallTest.php | 4 ++-- scripts/cli_install.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/phpunit/0_Install/FusinvInstallTest.php b/phpunit/0_Install/FusinvInstallTest.php index 87777213ea..12046f054b 100644 --- a/phpunit/0_Install/FusinvInstallTest.php +++ b/phpunit/0_Install/FusinvInstallTest.php @@ -95,9 +95,9 @@ public function testForceInstall() { function install($force = false) { $output = []; $returncode = 0; - $command = "php -f ".FUSINV_ROOT. "/scripts/cli_install.php -- --as-user 'glpi'"; + $command = "php -f ".FUSINV_ROOT. "/scripts/cli_install.php"; if ($force) { - $command.= " --force-install"; + $command.= " -- --as-user 'glpi' --force-install"; } exec($command, $output, $returncode); $this->assertEquals(0, $returncode, diff --git a/scripts/cli_install.php b/scripts/cli_install.php index 9549e9f780..137fdcdd9c 100755 --- a/scripts/cli_install.php +++ b/scripts/cli_install.php @@ -104,9 +104,14 @@ die("GLPI not installed\n"); } +$user = new User(); if (!is_null($args['--as-user'])) { - $user = new User(); $user->getFromDBbyName($args['--as-user']); +} elseif(is_null($args['--as-user'])) { + $user->getFromDBbyName('glpi'); +} + +if(!$user->isNewItem()){ $auth = new Auth(); $auth->auth_succeded = true; $auth->user = $user;