ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

Auth: Make `ilSessionTest` work

Open mjansenDatabay opened this issue 1 year ago • 2 comments

The tests in ilSessionTest are always ignored and reported as "skipped" when executing our PHPUnit test suite.

  • With this PR I mocked the database by delegating calls to the ilDBInterface to an "in memory" database (PDO sqlite).
  • Furthermore I removed a method which was/is not a test method at all: tstBasicSessionBehaviour

There is an alternative to this PR: Completely delete the test file. Since the code unter test only contains wrapped database calls, it is IMO only possible to test the database calls.

mjansenDatabay avatar Jan 22 '24 10:01 mjansenDatabay

The main reason why I did skip the old ilSession test was because it was flappy. The issue occured because of https://github.com/ILIAS-eLearning/ILIAS/blob/30e89b3bb44ea6bf4031d3d3563147fc5089ab2e/components/ILIAS/Authentication/classes/class.ilSession.php#L194C1-L199C1, which did run on arbitrary times. With the cron check around it, I would propose the following:

  • [x] Keep the old test with methode renamed back to testBasicSessionBehaviour
  • [x] Add a mock to that test that will return true when querying of the job auth_destroy_expired_sessions is active
  • [x] Add the current test as a second test

pascalseeland avatar Mar 03 '24 17:03 pascalseeland

@pascalseeland Done

mjansenDatabay avatar Mar 04 '24 07:03 mjansenDatabay

@pascalseeland This is ready to merge. I you don't have any objections, go go go!

mjansenDatabay avatar May 10 '24 08:05 mjansenDatabay

Merged, with all checklist items completed!

mjansenDatabay avatar May 21 '24 08:05 mjansenDatabay