diff --git a/.travis.yml b/.travis.yml index f739b5521..00b7debc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,12 +32,6 @@ php: - nightly matrix: - allow_failures: - - php: nightly - - env: GLPI_BRANCH=9.5/bugfixes -# - env: GLPI_BRANCH=master - -jobs: exclude: - php: 5.6 env: GLPI_BRANCH=9.5/bugfixes @@ -45,6 +39,10 @@ jobs: env: GLPI_BRANCH=9.5/bugfixes - php: 7.1 env: GLPI_BRANCH=9.5/bugfixes + allow_failures: + - php: nightly +# - env: GLPI_BRANCH=9.5/bugfixes +# - env: GLPI_BRANCH=master before_script: - | @@ -65,7 +63,7 @@ script: - if [ "${TRAVIS_PHP_VERSION:0:3}" = "$CS" ] && [ "$GLPI_BRANCH" = "$AFTER_SUCCESS_BRANCH" ]; then COVERAGE="--nccfc CommonTreeDropdown CommonDropdown CommonDBTM CommonGLPI CommonDBConnexity CommonDBRelation"; fi - # install GLPI with an old schema of the plugin and upgrade it - - export GLPI_CONFIG_DIR="tests/config-$OLD_DB_NAME" + - export TEST_GLPI_CONFIG_DIR="tests/config-$OLD_DB_NAME" - init_glpi $OLD_DB_NAME $DB_USER $DB_PASSWD && init_plugin - # upgrade test - echo status of plugins @@ -73,7 +71,7 @@ script: - plugin_test_upgrade - # install GLPI with a fresh install of the plugin - - export GLPI_CONFIG_DIR="tests/config-$DB_NAME" + - export TEST_GLPI_CONFIG_DIR="tests/config-$DB_NAME" - init_glpi $DB_NAME $DB_USER $DB_PASSWD && init_plugin - # fresh install test - plugin_test_install diff --git a/inc/field.class.php b/inc/field.class.php index 64edfee38..0e962b482 100644 --- a/inc/field.class.php +++ b/inc/field.class.php @@ -224,6 +224,7 @@ public final function updateParameters(PluginFormcreatorQuestion $question, arra $parameterInput['plugin_formcreator_questions_id'] = $this->question->getID(); if ($parameter->isNewItem()) { // In case of the parameter vanished in DB, just recreate it + unset($parameterInput['id']); $parameter->add($parameterInput); } else { $parameterInput['id'] = $parameter->getID(); diff --git a/inc/fields/actorfield.class.php b/inc/fields/actorfield.class.php index 5ab61a174..48bd3890d 100644 --- a/inc/fields/actorfield.class.php +++ b/inc/fields/actorfield.class.php @@ -189,8 +189,12 @@ public function getValueForTargetText($richText) { } else { $user = new User(); $user->getFromDB($item); - $value[] = Toolbox::addslashes_deep($user->getRawName()); - } + if (method_exists($user, 'getFriendlyName')) { + $value[] = Toolbox::addslashes_deep($user->getFriendlyName()); + } else { + $value[] = Toolbox::addslashes_deep($user->getRawName()); + } + } } if ($richText) { @@ -223,7 +227,11 @@ protected function sanitizeValue($value) { $user->getFromDB($item); if (!$user->isNewItem()) { // A user known in the DB - $knownUsers[$user->getID()] = $user->getRawName(); + if (method_exists($user, 'getFriendlyName')) { + $knownUsers[$user->getID()] = $user->getFriendlyName(); + } else { + $knownUsers[$user->getID()] = $user->getRawName(); + } } } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f9ce19b34..60f78be1d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -15,8 +15,8 @@ // glpi/inc/oolbox.class.php tests TU_USER to decide if it warns or not about mcrypt extension define('TU_USER', '_test_user'); -if (!$glpiConfigDir = getenv('GLPI_CONFIG_DIR')) { - echo "Environment var GLPI_CONFIG_DIR is not set" . PHP_EOL; +if (!$glpiConfigDir = getenv('TEST_GLPI_CONFIG_DIR')) { + echo "Environment var TEST_GLPI_CONFIG_DIR is not set" . PHP_EOL; exit(1); } diff --git a/tests/install_glpi.php b/tests/install_glpi.php index 4ec6265a7..bd0d25dec 100644 --- a/tests/install_glpi.php +++ b/tests/install_glpi.php @@ -4,11 +4,11 @@ * This script wraps the installer of GLPI to allow a custom CONFIG_DIR path similarly to cli installer in * GLPI 9.5 */ -if (!$glpiConfigDir = getenv('GLPI_CONFIG_DIR')) { - echo "Environment var GLPI_CONFIG_DIR is not set" . PHP_EOL; +if (!$glpiConfigDir = getenv('TEST_GLPI_CONFIG_DIR')) { + echo "Environment var TEST_GLPI_CONFIG_DIR is not set" . PHP_EOL; exit(1); } - + define('GLPI_ROOT', realpath(__DIR__ . '/../../../')); define("GLPI_CONFIG_DIR", GLPI_ROOT . "/$glpiConfigDir"); unset($glpiConfigDir); diff --git a/tests/script-functions.sh b/tests/script-functions.sh index e6015434d..5989c7745 100644 --- a/tests/script-functions.sh +++ b/tests/script-functions.sh @@ -43,19 +43,19 @@ init_glpi() { mysql -u$2 -p$3 -h$DB_HOST --execute "DROP DATABASE IF EXISTS \`$1\`;" echo Cleaning up cache directory rm -r ../../tests/files/_cache/* || true - rm ../../$GLPI_CONFIG_DIR/config_db.php || true + rm ../../$TEST_GLPI_CONFIG_DIR/config_db.php || true echo Installing GLPI on database $1 - mkdir -p ../../$GLPI_CONFIG_DIR + mkdir -p ../../$TEST_GLPI_CONFIG_DIR if [ -e ../../tools/cliinstall.php ] ; then php ./tests/install_glpi.php --host $DB_HOST --db=$1 --user=$2 --pass=$3 ; fi if [ -e ../../scripts/cliinstall.php ] ; then php ./tests/install_glpi.php --host $DB_HOST --db=$1 --user=$2 --pass=$3 ; fi - if [ -e ../../bin/console ]; then php ../../bin/console glpi:database:install --db-host=$DB_HOST --db-user=$2 --db-password=$3 --db-name=$1 --config-dir=../../$GLPI_CONFIG_DIR --no-interaction --no-plugins --force; fi + if [ -e ../../bin/console ]; then php ../../bin/console glpi:database:install --db-host=$DB_HOST --db-user=$2 --db-password=$3 --db-name=$1 --config-dir=../../$TEST_GLPI_CONFIG_DIR --no-interaction --no-plugins --force; fi } # Plugin upgrade test plugin_test_upgrade() { mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWD $OLD_DB_NAME < tests/plugin_formcreator_config_2.5.0.sql mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWD $OLD_DB_NAME < tests/plugin_formcreator_empty_2.5.0.sql - php scripts/cliinstall.php --tests $GLPI_CONFIG_DIR + php scripts/cliinstall.php --tests $TEST_GLPI_CONFIG_DIR } # Plugin test diff --git a/tests/suite-uninstall/Config.php b/tests/suite-uninstall/Config.php index 732e4b390..7eaf668f1 100644 --- a/tests/suite-uninstall/Config.php +++ b/tests/suite-uninstall/Config.php @@ -57,10 +57,10 @@ public function testUninstallPlugin() { }); $plugin->uninstall($plugin->getID()); ob_end_clean(); - $this->boolean($plugin->isInstalled($pluginName))->isFalse($log); // Check the plugin is not installed - $this->boolean($plugin->isInstalled($pluginName))->isFalse(); + $plugin->getFromDBbyDir(strtolower($pluginName)); + $this->integer((int) $plugin->fields['state'])->isEqualTo(\Plugin::NOTINSTALLED); // Check all plugin's tables are dropped $tables = [];