MDL-78156 groups: Make groups_get_user_groups() order deterministic
commite12c760a1239df820cd0af22bbe247a98b3e98b2
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 8 May 2023 16:18:54 +0000 (8 18:18 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 8 May 2023 16:18:54 +0000 (8 18:18 +0200)
tree4b83ab81c6fb83f0b0798ecd776c73d64f663ba0
parent5d320dd7d18d2442fe2f585d653579909fe700f0
MDL-78156 groups: Make groups_get_user_groups() order deterministic

Right now the order of the groups returned by groups_get_user_groups()
is not fixed and, every DB, can return them in any order. While 99%
of times the order will be the creation one, depending of the RDBMS
decisions, they can be returned in any order.

This is specially noticeable with Oracle, but can affect to any DB.

And that makes some tests (expecting a given order) to fail.

This commit fixes the problem by making the order of the groups
deterministic, because that's the way we use to fix these problems.

Alternative is to relax the tests so only values are asserted by
using assertEqualsCanonicalizing().
lib/grouplib.php