Commit 299e5188 authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski
Browse files

Fix tests var directories init

parent 8dacb0b5
...@@ -44,6 +44,8 @@ define( ...@@ -44,6 +44,8 @@ define(
include_once(GLPI_ROOT . '/inc/includes.php'); include_once(GLPI_ROOT . '/inc/includes.php');
\GlpiTests\Toolbox::initVarDirectories();
$command = new \GlpiTests\Command\TestUpdatedDataCommand(); $command = new \GlpiTests\Command\TestUpdatedDataCommand();
$app = new \Symfony\Component\Console\Application('Test empty data', GLPI_VERSION); $app = new \Symfony\Component\Console\Application('Test empty data', GLPI_VERSION);
......
...@@ -61,13 +61,7 @@ if (!file_exists(GLPI_CONFIG_DIR . '/config_db.php')) { ...@@ -61,13 +61,7 @@ if (!file_exists(GLPI_CONFIG_DIR . '/config_db.php')) {
die("\nConfiguration file for tests not found\n\nrun: bin/console glpi:database:install --config-dir=./tests ...\n\n"); die("\nConfiguration file for tests not found\n\nrun: bin/console glpi:database:install --config-dir=./tests ...\n\n");
} }
// Create subdirectories of GLPI_VAR_DIR based on defined constants \GlpiTests\Toolbox::initVarDirectories();
foreach (get_defined_constants() as $constant_name => $constant_value) {
if (preg_match('/^GLPI_[\w]+_DIR$/', $constant_name)
&& preg_match('/^' . preg_quote(GLPI_VAR_DIR, '/') . '\//', $constant_value)) {
is_dir($constant_value) or mkdir($constant_value, 0755, true);
}
}
//init cache //init cache
if (file_exists(GLPI_CONFIG_DIR . DIRECTORY_SEPARATOR . CacheManager::CONFIG_FILENAME)) { if (file_exists(GLPI_CONFIG_DIR . DIRECTORY_SEPARATOR . CacheManager::CONFIG_FILENAME)) {
......
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2021 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
namespace GlpiTests;
class Toolbox {
/**
* Create subdirectories of GLPI_VAR_DIR based on defined constants.
*
* @return void
*/
public static function initVarDirectories(): void {
foreach (get_defined_constants() as $name => $value) {
if (preg_match('/^GLPI_[\w]+_DIR$/', $name)
&& preg_match('/^' . preg_quote(GLPI_VAR_DIR, '/') . '\//', $value)
&& !is_dir($value)) {
mkdir($value, 0755, true);
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment