HGustavs / LenaSYS

Code Viewer and Course Organization System used in some courses at University of Skövde
57 stars 31 forks source link

Create new tests for the microservices created from showDuggaservice.php #15162

Open f22linhe opened 6 months ago

f22linhe commented 6 months ago

For example in microservices/showDuggaservice we have the microservice updateActiveUsers_ms.php. It needs these parameters in: $hash=getOP('hash'); $AUtoken=getOP('AUtoken');

And depending on the values of the parameters it should have a expected-output, since it returns: echo json_encode($active);

We should create these tests similarly to how tests have been made for tests in e.g. sectionedserviceTest.php (e.g. getCourseGroupsAndMembers). If some test data need to exist in the database, create the inserts with the tables and values for your specific test. e.g.: 'query-before-test-1' => "INSERT INTO user_course (cid, vers, uid,groups,access) VALUES (1885,1337,3, 'No_2','W'), (1885,1337,101, 'No2','W');",

And also delete the test data after, e.g.: _'query-after-test-1' => "DELETE FROM usercourse WHERE uid=3 AND cid=1885;",

The tests themselves should be created in LenaSYS/DuggaSys/tests/microservices/. So according to the example above: _LenaSYS/DuggaSys/tests/microservices/showDuggaService/updateActiveUsers_mstest.php

a22melst commented 6 months ago

The includes at line 65 and 203 in test.php need to be changed to include_once( __DIR__ . "pathtofile"); in order to still work when test.php is included in a file whose directory has another depth compared to the folder "tests".

a22melst commented 6 months ago

Some of the microservices from showDuggaService have no output, while some such as updateActiveUsers_ms has very short output. I think it would be better to create a retrieveShowduggaService microservice such as the ones made for sectionedservice and coureedservice, which could then be called at the end of the microservices.