diff --git a/src/CommonDBTM.php b/src/CommonDBTM.php index 94c63e32964..533d32c8a95 100644 --- a/src/CommonDBTM.php +++ b/src/CommonDBTM.php @@ -1328,12 +1328,12 @@ public function add(array $input, $options = [], $history = true) } } - // Auto set date_creation if exsist + // Auto set date_creation if exist if (isset($table_fields['date_creation']) && !isset($this->input['date_creation'])) { $this->fields['date_creation'] = $_SESSION["glpi_currenttime"]; } - // Auto set date_mod if exsist + // Auto set date_mod if exist if (isset($table_fields['date_mod']) && !isset($this->input['date_mod'])) { $this->fields['date_mod'] = $_SESSION["glpi_currenttime"]; } diff --git a/src/DbUtils.php b/src/DbUtils.php index 2671cf3bdbb..ecd5a5a7260 100644 --- a/src/DbUtils.php +++ b/src/DbUtils.php @@ -210,6 +210,10 @@ public function getTableForItemType($itemtype) $table = substr($table, \strlen(NS_GLPI)); } } + //handle PHPUnit mocks + if (str_starts_with($table, 'mock_')) { + $table = preg_replace('/^mock_(.+)_.+$/', '$1', $table); + } $table = str_replace(['mock\\', '\\'], ['', '_'], $table); if (strstr($table, '_')) { $split = explode('_', $table);