Skip to content

Commit

Permalink
Test suggestion (#17389)
Browse files Browse the repository at this point in the history
* Logout same in tests as normal

* Rely on fields array rather than getFields() method

* Add tests common functions in autoloaded file
  • Loading branch information
trasher authored Jul 1, 2024
1 parent 057f637 commit f68bdee
Show file tree
Hide file tree
Showing 5 changed files with 749 additions and 709 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
"psr-4": {
"Glpi\\Tools\\": "tools/src/",
"Glpi\\Tests\\": "tests/src/"
}
},
"files": ["tests/src/autoload/functions.php"]
},
"scripts": {
"testdb": "atoum -p 'php -d memory_limit=512M' --debug --force-terminal --use-dot-report --bootstrap-file tests/bootstrap.php --no-code-coverage --max-children-number 1 -d tests/database",
Expand Down
5 changes: 2 additions & 3 deletions tests/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ protected function login(
*/
protected function logOut()
{
$ctime = $_SESSION['glpi_currenttime'];
\Session::destroy();
$_SESSION['glpi_currenttime'] = $ctime;
\Session::start();
}

/**
Expand Down Expand Up @@ -121,7 +120,7 @@ protected function checkInput(CommonDBTM $object, $id = 0, $input = [])

$this->integer($id)->isGreaterThan($object instanceof Entity ? -1 : 0);
$this->boolean($object->getFromDB($id))->isTrue();
$this->variable($object->getField('id'))->isEqualTo($id);
$this->variable($object->fields['id'])->isEqualTo($id);

if (count($input)) {
foreach ($input as $k => $v) {
Expand Down
Loading

0 comments on commit f68bdee

Please sign in to comment.