diff --git a/inc/deploypackage_profile.class.php b/inc/deploypackage_profile.class.php index 9848ad5305..02ee70660b 100644 --- a/inc/deploypackage_profile.class.php +++ b/inc/deploypackage_profile.class.php @@ -95,11 +95,15 @@ public static function getProfiles($deploypackages_id) global $DB; $prof = []; - $query = "SELECT `glpi_plugin_glpiinventory_deploypackages_profiles`.* - FROM `glpi_plugin_glpiinventory_deploypackages_profiles` - WHERE `plugin_glpiinventory_deploypackages_id` = '$deploypackages_id'"; - foreach ($DB->request($query) as $data) { + $iterator = $DB->request([ + 'FROM' => 'glpi_plugin_glpiinventory_deploypackages_profiles', + 'WHERE' => [ + 'plugin_glpiinventory_deploypackages_id' => $deploypackages_id + ] + ]); + + foreach ($iterator as $data) { $prof[$data['profiles_id']][] = $data; } return $prof; diff --git a/inc/setup.class.php b/inc/setup.class.php index e58ed5ae11..ba91c99a45 100644 --- a/inc/setup.class.php +++ b/inc/setup.class.php @@ -66,7 +66,7 @@ public static function uninstall() $pfSetup->rrmdir(GLPI_PLUGIN_DOC_DIR . '/glpiinventory'); } - $result = $DB->query("SHOW TABLES;"); + $result = $DB->doQuery("SHOW TABLES;"); while ($data = $DB->fetchArray($result)) { if ( (strstr($data[0], "glpi_plugin_glpiinventory_")) diff --git a/install/update.php b/install/update.php index d6ff44cf85..b5abc70c97 100644 --- a/install/update.php +++ b/install/update.php @@ -2776,7 +2776,7 @@ function do_rulematchedlog_migration($migration) `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"; - $DB->query($query); + $DB->doQuery($query); } $migration->changeField( $newTable, @@ -3138,7 +3138,7 @@ function do_configlogfield_migration($migration) `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"; - $DB->query($query); + $DB->doQuery($query); } $migration->changeField( $newTable, @@ -3223,7 +3223,7 @@ function do_networkport_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -3349,7 +3349,7 @@ function do_networkport_migration($migration) `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"; - $DB->query($query); + $DB->doQuery($query); } $migration->changeField( $newTable, @@ -3421,7 +3421,7 @@ function do_networkport_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -3755,7 +3755,7 @@ function do_networkport_migration($migration) `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"; - $DB->query($query); + $DB->doQuery($query); } $migration->changeField( $newTable, @@ -4041,7 +4041,7 @@ function do_printer_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -4197,7 +4197,7 @@ function do_printer_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -4404,7 +4404,7 @@ function do_printer_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -4679,7 +4679,7 @@ function do_networkequipment_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -4872,7 +4872,7 @@ function do_networkequipment_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -5101,7 +5101,7 @@ function do_configsecurity_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query('CREATE TABLE `' . $newTable . '` ( + $DB->doQuery('CREATE TABLE `' . $newTable . '` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC'); @@ -5296,7 +5296,7 @@ function do_statediscovery_migration($migration) renamePluginFields($migration, $newTable); if (!$DB->tableExists($newTable)) { - $DB->query("CREATE TABLE `" . $newTable . "` ( + $DB->doQuery("CREATE TABLE `" . $newTable . "` ( `id` int unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"); @@ -5901,7 +5901,7 @@ function do_deployuserinteraction_migration($migration) KEY `entities_id` (`entities_id`), KEY `is_recursive` (`is_recursive`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"; - $DB->query($query); + $DB->doQuery($query); } } @@ -8235,7 +8235,7 @@ function migratePluginTables($migration, $a_table) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC"; } - $DB->query($query); + $DB->doQuery($query); } foreach ($a_table['renamefields'] as $old => $new) { @@ -8588,7 +8588,7 @@ function migrateTablesFromFusinvDeploy($migration) //migrate fusinvdeploy_files if ($DB->tableExists("glpi_plugin_fusinvdeploy_files")) { - $DB->query("TRUNCATE TABLE `glpi_plugin_glpiinventory_deployfiles`"); + $DB->doQuery("TRUNCATE TABLE `glpi_plugin_glpiinventory_deployfiles`"); if ($DB->fieldExists("glpi_plugin_fusinvdeploy_files", "filesize")) { $f_iterator = $DB->request([ 'SELECT' => [ diff --git a/setup.php b/setup.php index 922c071c7e..e5b3ebc512 100644 --- a/setup.php +++ b/setup.php @@ -35,7 +35,7 @@ define("PLUGIN_GLPIINVENTORY_VERSION", "1.3.1"); // Minimal GLPI version, inclusive -define('PLUGIN_GLPI_INVENTORY_GLPI_MIN_VERSION', '10.0.10'); +define('PLUGIN_GLPI_INVENTORY_GLPI_MIN_VERSION', '10.0.11'); // Maximum GLPI version, exclusive define('PLUGIN_GLPI_INVENTORY_GLPI_MAX_VERSION', '10.0.99'); // Used for use config values in 'cache' diff --git a/tests/Installation/DatabaseTestsCommons.php b/tests/Installation/DatabaseTestsCommons.php index 4750668a35..aec74f974a 100644 --- a/tests/Installation/DatabaseTestsCommons.php +++ b/tests/Installation/DatabaseTestsCommons.php @@ -99,7 +99,7 @@ public function checkInstall($pluginname = '', $when = '') $a_tables = []; // SHOW TABLES; $query = "SHOW TABLES"; - $result = $DB->query($query); + $result = $DB->doQuery($query); while ($data = $DB->fetchArray($result)) { if ( (strstr($data[0], "tracker") @@ -143,7 +143,7 @@ public function checkInstall($pluginname = '', $when = '') foreach ($a_tables as $table) { $query = "SHOW CREATE TABLE " . $table; - $result = $DB->query($query); + $result = $DB->doQuery($query); while ($data = $DB->fetchArray($result)) { $a_lines = explode("\n", $data['Create Table']); @@ -283,9 +283,10 @@ public function checkInstall($pluginname = '', $when = '') /* * Verify in taskjob definition PluginFusinvsnmpIPRange not exist */ - $query = "SELECT * FROM `glpi_plugin_glpiinventory_taskjobs`"; - $result = $DB->query($query); - while ($data = $DB->fetchArray($result)) { + $request = $DB->request([ + 'FROM' => 'glpi_plugin_glpiinventory_taskjobs' + ]); + foreach ($request as $data) { $snmprangeip = 0; if (strstr($data['targets'], "PluginFusinvsnmpIPRange")) { $snmprangeip = 1; diff --git a/tests/Installation/InstallationTest.php b/tests/Installation/InstallationTest.php index 6ddf9125c3..75f357474f 100644 --- a/tests/Installation/InstallationTest.php +++ b/tests/Installation/InstallationTest.php @@ -53,7 +53,7 @@ public function testInstall() // Delete if Table of FusionInventory or Tracker yet in DB $query = "SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'"; - $result = $DB->query($query); + $result = $DB->doQuery($query); while ($data = $DB->fetchArray($result)) { if (strstr($data[0], "fusi")) { $DB->dropView($data[0]); @@ -61,7 +61,7 @@ public function testInstall() } $query = "SHOW TABLES"; - $result = $DB->query($query); + $result = $DB->doQuery($query); while ($data = $DB->fetchArray($result)) { if ( strstr($data[0], "tracker") @@ -71,7 +71,7 @@ public function testInstall() $DB->dropTable($data[0]); } } - $DB->query('TRUNCATE TABLE glpi_plugins'); + $DB->doQuery('TRUNCATE TABLE glpi_plugins'); $this->install(); } diff --git a/tests/Installation/UpdateTest.php b/tests/Installation/UpdateTest.php index b90d7eceaf..47072dc82d 100644 --- a/tests/Installation/UpdateTest.php +++ b/tests/Installation/UpdateTest.php @@ -93,7 +93,7 @@ public function update($version = '', $verify = false, $nbrules = 0) $plugin->uninstall($plugin->fields['id']); $query = "SHOW TABLES"; - $result = $DB->query($query); + $result = $DB->doQuery($query); while ($data = $DB->fetchArray($result)) { if ( strstr($data[0], "tracker") diff --git a/tests/Integration/RestURLTest.php b/tests/Integration/RestURLTest.php index 5689c9444d..c6bf4c4266 100644 --- a/tests/Integration/RestURLTest.php +++ b/tests/Integration/RestURLTest.php @@ -37,7 +37,6 @@ class RestURLTest extends TestCase { public static function setUpBeforeClass(): void { - // Delete all entities except root entity $entity = new Entity(); $items = $entity->find(); @@ -100,15 +99,19 @@ public function prepareDb() $ret = $entity->update($input); $this->assertTrue($ret); - // active all modules - $query = "UPDATE `glpi_plugin_glpiinventory_agentmodules`" - . " SET `is_active`='1'"; - $DB->query($query); + // active all modules + $DB->update( + 'glpi_plugin_glpiinventory_agentmodules', + ['is_active' => 1], + [new QueryExpression("1=1")] + ); } /** * @test + * + * @depends prepareDb */ public function getCollectUrlEnt1Entity() { @@ -146,6 +149,8 @@ public function getCollectUrlEnt1Entity() /** * @test + * + * @depends prepareDb */ public function getDeployUrlRootEntity() { @@ -182,6 +187,8 @@ public function getDeployUrlRootEntity() /** * @test + * + * @depends prepareDb */ public function getEsxUrlRootEntity() { @@ -218,6 +225,8 @@ public function getEsxUrlRootEntity() /** * @test + * + * @depends prepareDb */ public function getCollectUrlRootEntity() { diff --git a/tests/Integration/Tasks/CronTaskTest.php b/tests/Integration/Tasks/CronTaskTest.php index 031327fb04..38f1a2ee4e 100644 --- a/tests/Integration/Tasks/CronTaskTest.php +++ b/tests/Integration/Tasks/CronTaskTest.php @@ -498,8 +498,8 @@ public function prepareTaskNotRePrepareIfSuccessful() $pfTask = new PluginGlpiinventoryTask(); $deploycommon = new PluginGlpiinventoryDeployCommon(); - $DB->query("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjoblogs`"); - $DB->query("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjobstates`"); + $DB->doQuery("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjoblogs`"); + $DB->doQuery("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjobstates`"); $pfTask->getFromDBByCrit(['name' => 'deploy']); $this->assertArrayHasKey('id', $pfTask->fields); @@ -692,8 +692,8 @@ public function cleanTasksAndJobs() $pfTask->delete(['id' => $pfTask->fields['id']], true); //Clean all taskjoblogs & states - $DB->query("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjoblogs`"); - $DB->query("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjobstates`"); + $DB->doQuery("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjoblogs`"); + $DB->doQuery("TRUNCATE TABLE `glpi_plugin_glpiinventory_taskjobstates`"); //Find the on demand task $tasks = $pfTask->find(['name' => 'ondemand']); @@ -705,10 +705,12 @@ public function cleanTasksAndJobs() //Prepare the task PluginGlpiinventoryTask::cronTaskscheduler(); - //Set the first job as successfull - $query = "SELECT DISTINCT `plugin_glpiinventory_taskjobstates_id` - FROM glpi_plugin_glpiinventory_taskjoblogs LIMIT 1"; - foreach ($DB->request($query) as $data) { + //Set the first job as successfull + $iterator = $DB->request([ + 'FROM' => 'glpi_plugin_glpiinventory_taskjoblogs', + 'LIMIT' => 1 + ]); + foreach ($iterator as $data) { $pfTaskJobstate->changeStatusFinish($data['plugin_glpiinventory_taskjobstates_id'], 0, ''); } @@ -721,9 +723,11 @@ public function cleanTasksAndJobs() $datetime = new Datetime($_SESSION['glpi_currenttime']); $datetime->modify('-4 days'); - $query = "UPDATE `glpi_plugin_glpiinventory_taskjoblogs` - SET `date`='" . $datetime->format('Y-m-d') . " 00:00:00'"; - $DB->query($query); + $DB->update( + 'glpi_plugin_glpiinventory_taskjoblogs', + ['date' => $datetime->format('Y-m-d') . " 00:00:00"], + [new QueryExpression("1=1")] + ); //No task & jobs should be removed because ask for cleaning 5 days from now $index = $pfTask->cleanTasksAndJobs(5); @@ -770,15 +774,19 @@ public function cleanTasksAndJobs() )); //Set the first job as successfull - $query = "SELECT DISTINCT `plugin_glpiinventory_taskjobstates_id` - FROM glpi_plugin_glpiinventory_taskjoblogs"; - foreach ($DB->request($query) as $data) { + $request = $DB->request([ + 'DISTINCT' => 'plugin_glpiinventory_taskjobstates_id', + 'FROM' => 'glpi_plugin_glpiinventory_taskjoblogs', + ]); + foreach ($request as $data) { $pfTaskJobstate->changeStatusFinish($data['plugin_glpiinventory_taskjobstates_id'], 0, ''); } - $query = "UPDATE `glpi_plugin_glpiinventory_taskjoblogs` - SET `date`='" . $datetime->format('Y-m-d') . " 00:00:00'"; - $DB->query($query); + $DB->update( + 'glpi_plugin_glpiinventory_taskjoblogs', + ['date' => $datetime->format('Y-m-d') . " 00:00:00"], + [new QueryExpression("1=1")] + ); //One taskjob is finished and should be cleaned $index = $pfTask->cleanTasksAndJobs(2); diff --git a/tests/Unit/Deploy/DeploygroupTest.php b/tests/Unit/Deploy/DeploygroupTest.php index 3b3193d5d3..e9d79e9a06 100644 --- a/tests/Unit/Deploy/DeploygroupTest.php +++ b/tests/Unit/Deploy/DeploygroupTest.php @@ -53,7 +53,7 @@ public static function setUpBeforeClass(): void $computer->delete(['id' => $item['id']], true); } - $DB->query("truncate table glpi_computers"); + $DB->doQuery("TRUNCATE TABLE glpi_computers"); } @@ -291,7 +291,7 @@ public function ImportCsvStaticGroup() // Add some computers, with the ID $computer = new Computer(); - $DB->query("ALTER TABLE glpi_computers AUTO_INCREMENT = 12345;"); + $DB->doQuery("ALTER TABLE glpi_computers AUTO_INCREMENT = 12345;"); $input = [ 'entities_id' => 0, diff --git a/tests/Unit/Deploy/PackageJsonTest.php b/tests/Unit/Deploy/PackageJsonTest.php index 4477263fca..45a04f4b35 100644 --- a/tests/Unit/Deploy/PackageJsonTest.php +++ b/tests/Unit/Deploy/PackageJsonTest.php @@ -128,11 +128,20 @@ public function Migration_to_91() KEY `entities_id` (`entities_id`), KEY `date_mod` (`date_mod`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;"; - $DB->query($query); - - $query = "INSERT INTO `glpi_plugin_glpiinventory_deploypackages` (`id`, `name`, `comment`, `entities_id`, `is_recursive`, `date_mod`, `uuid`) VALUES - (16, 'INST VLC 2.1.5', 'Install VLC 2.1.5 unintall all VLC', 0, 0, '2014-10-17 11:11:02', NULL);"; - $DB->query($query); + $DB->doQuery($query); + + $DB->insert( + 'glpi_plugin_glpiinventory_deploypackages', + [ + 'id' => 16, + 'name' => 'INST VLC 2.1.5', + 'comment' => 'Install VLC 2.1.5 unintall all VLC', + 'entities_id' => 0, + 'is_recursive' => 0, + 'date_mod' => '2014-10-17 11:11:02', + 'uuid' => null + ] + ); // glpi_plugin_glpiinventory_deployorders $DB->dropTable('glpi_plugin_glpiinventory_deployorders', true); @@ -145,13 +154,29 @@ public function Migration_to_91() `json` longtext, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;"; - $DB->query($query); - - $query = "INSERT INTO `glpi_plugin_glpiinventory_deployorders` (`id`, `type`, `create_date`, `plugin_glpiinventory_deploypackages_id`, `json`) VALUES - (31, 0, '2013-04-29 09:58:58', 16, '{\"jobs\":{\"checks\":[],\"actions\":[{\"mkdir\":{\"list\":[\"c:\\\\packages\\\\vlc\"]}},{\"move\":{\"from\":\"*.*\",\"to\":\"c:\\\\packages\\\\vlc\"}},{\"cmd\":{\"exec\":\"c:\\\\packages\\\\vlc\\\\vlcinstall.cmd\"}}],\"associatedFiles\":[\"1f54a4730571d165a488f7f343e49d71f7e06c639091959df7065019971d1c3080f97da6517a94173083a50625dc1c1ba11f685d0c6f15705a75d5265c708cee\"]},\"associatedFiles\":{\"1f54a4730571d165a488f7f343e49d71f7e06c639091959df7065019971d1c3080f97da6517a94173083a50625dc1c1ba11f685d0c6f15705a75d5265c708cee\":{\"name\":\"vlc.zip\",\"p2p\":1,\"p2p-retention-duration\":16,\"uncompress\":1}}}'), - (32, 1, '2013-04-29 09:58:58', 16, '{\"jobs\":{\"checks\":[],\"actions\":[{\"cmd\":{\"exec\":\"vlcuninstall.cmd\"}}],\"associatedFiles\":[\"b16d6a078538842df7b6e572be62845b16870d5f325ec39ac4ae3d6705b2845990684c5a39206c7f23db177226781660324fab14330d98e71f2315658d13584b\"]},\"associatedFiles\":{\"b16d6a078538842df7b6e572be62845b16870d5f325ec39ac4ae3d6705b2845990684c5a39206c7f23db177226781660324fab14330d98e71f2315658d13584b\":{\"name\":\"vlcuninstall.cmd\",\"p2p\":0,\"p2p-retention-duration\":5,\"uncompress\":0}}}');"; + $DB->doQuery($query); + + $DB->insert( + 'glpi_plugin_glpiinventory_deployorders', + [ + 'id' => 31, + 'type' => 0, + 'create_date' => '2013-04-29 09:58:58', + 'plugin_glpiinventory_deploypackages_id' => 16, + 'json' => '{\"jobs\":{\"checks\":[],\"actions\":[{\"mkdir\":{\"list\":[\"c:\\\\packages\\\\vlc\"]}},{\"move\":{\"from\":\"*.*\",\"to\":\"c:\\\\packages\\\\vlc\"}},{\"cmd\":{\"exec\":\"c:\\\\packages\\\\vlc\\\\vlcinstall.cmd\"}}],\"associatedFiles\":[\"1f54a4730571d165a488f7f343e49d71f7e06c639091959df7065019971d1c3080f97da6517a94173083a50625dc1c1ba11f685d0c6f15705a75d5265c708cee\"]},\"associatedFiles\":{\"1f54a4730571d165a488f7f343e49d71f7e06c639091959df7065019971d1c3080f97da6517a94173083a50625dc1c1ba11f685d0c6f15705a75d5265c708cee\":{\"name\":\"vlc.zip\",\"p2p\":1,\"p2p-retention-duration\":16,\"uncompress\":1}}}' + ] + ); + $DB->insert( + 'glpi_plugin_glpiinventory_deployorders', + [ + 'id' => 32, + 'type' => 1, + 'create_date' => '2013-04-29 09:58:58', + 'plugin_glpiinventory_deploypackages_id' => 16, + 'json' => '{\"jobs\":{\"checks\":[],\"actions\":[{\"cmd\":{\"exec\":\"vlcuninstall.cmd\"}}],\"associatedFiles\":[\"b16d6a078538842df7b6e572be62845b16870d5f325ec39ac4ae3d6705b2845990684c5a39206c7f23db177226781660324fab14330d98e71f2315658d13584b\"]},\"associatedFiles\":{\"b16d6a078538842df7b6e572be62845b16870d5f325ec39ac4ae3d6705b2845990684c5a39206c7f23db177226781660324fab14330d98e71f2315658d13584b\":{\"name\":\"vlcuninstall.cmd\",\"p2p\":0,\"p2p-retention-duration\":5,\"uncompress\":0}}}' + ] + ); - $DB->query($query); // run migration packages require_once(PLUGIN_GLPI_INVENTORY_DIR . "/install/update.php"); $migration = new Migration('9.1'); diff --git a/tests/autoload.php b/tests/autoload.php index a162fc4e98..e7b55ec81e 100644 --- a/tests/autoload.php +++ b/tests/autoload.php @@ -38,6 +38,7 @@ ini_set('display_errors', 'On'); error_reporting(E_ALL); +define('GLPI_STRICT_DEPRECATED', true); //enable strict depreciations define('GLPI_ROOT', __DIR__ . '/../../../'); define('GLPI_CONFIG_DIR', __DIR__ . '/../../../tests/config'); define('GLPI_VAR_DIR', __DIR__ . '/files'); @@ -147,4 +148,8 @@ class GlpitestPHPnotice extends \Exception class GlpitestSQLError extends \Exception { } -// @codingStandardsIgnoreEnd \ No newline at end of file +// @codingStandardsIgnoreEnd + +set_error_handler(static function (int $errno, string $errstr): never { + throw new Exception($errstr, $errno); +}, E_ALL);