root@05fa61441cd5:/siteroot# vendor/bin/phpunit "theme_snap_ws_course_card_categories_test" theme/snap/tests/webservice_ws_course_card_categories_test.php
Moodle 3.9.2+ (Build: 20200929), 47a9027d86d66847794f7c95c85d8374d1fb0d3a
Php: 7.2.24.0.0.18.04.3, pgsql: 9.6.17, OS: Linux 4.15.0-117-generic x86_64
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
..E 3 / 3 (100%)
Time: 1.51 seconds, Memory: 88.25 MB
There was 1 error:
1) theme_snap_ws_course_card_categories_test::test_service
dml_read_exception: Error reading from database (ERROR: function from_unixtime(bigint) does not exist
LINE 1: SELECT DISTINCT YEAR(FROM_UNIXTIME(c.enddate)) AS cat_year ,...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SELECT DISTINCT YEAR(FROM_UNIXTIME(c.enddate)) AS cat_year , COUNT(*) AS courses, MIN(c.enddate) AS stamp
FROM phpu_course c
JOIN (
SELECT DISTINCT e.courseid
FROM phpu_enrol e
JOIN phpu_user_enrolments ue ON (ue.enrolid = e.id AND ue.userid = $1)
WHERE ue.status = $2 AND e.status = $3 AND ue.timestart < $4
AND (ue.timeend = 0 OR ue.timeend > $5) UNION
SELECT DISTINCT e.courseid
FROM phpu_enrol e
WHERE e.enrol = 'guest' AND e.password = $6 AND e.status = $7) en ON (en.courseid = c.id)
LEFT JOIN phpu_context ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = $8)
WHERE c.id <> $9
GROUP BY cat_year
This line of code: https://github.com/open-lms-open-source/moodle-theme_snap/blob/master/classes/webservice/ws_course_cards_categories.php#L174
Uses the mysql function
FROM_UNIXTIME
- https://www.w3resource.com/mysql/date-and-time-functions/mysql-from_unixtime-function.phpThis won't work in moodles running postgres.
We also get the following unit test failure: