Skip to content

Commit

Permalink
Handle getTable for PHPUnit mocked objects
Browse files Browse the repository at this point in the history
Typos
  • Loading branch information
trasher committed Jul 31, 2024
1 parent 2990afe commit 6361505
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/CommonDBTM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
Expand Down
4 changes: 4 additions & 0 deletions src/DbUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6361505

Please sign in to comment.