Wunderbyte-GmbH / moodle-mod_booking

Moodle Booking Module
https://www.wunderbyte.at
21 stars 39 forks source link

TEST: Save entities in bookingoption form #593

Closed eynimeni closed 1 month ago

eynimeni commented 2 months ago

In a bookingoptionform, if plugin entities is installed and entitites are given, it should be possible to save to select an entity, save it, see it selected in the bookingoption card and the link should work Screenshot 2024-07-30 at 11 07 12

Screenshot 2024-07-30 at 11 07 23

Screenshot 2024-07-30 at 11 08 45

Tests:

semteacher commented 2 months ago

The "entites" local plugin does not included in the list of required plugin for GitHub actions. To create Behat test it has to be included. In case of phpunit - it will be possible to create test which will could be fully executed only locally, in presence of the "entites" plugin . @georgmaisser what is your opinin - should I add "entites" as dependencies to the booking or should I try with phpunit only?

eynimeni commented 2 months ago

entities should not be required for booking plugin. but for the actions in github we can require it. if this can not be done seperately, just proceed with phpuni

semteacher commented 1 month ago

Behat suports both optiob-level entity and option date-level entity. Have created a phpunit. It works for optiob-level entity but fails to assign date-level entity. What is the correct wat to add it in code? Have tried below but no location for date in option's settings is shown:

        $record->optiondateid_1 = "0";
        $record->daystonotify_1 = "0";
        $record->coursestarttime_1 = strtotime('20 June 2050');
        $record->courseendtime_1 = strtotime('20 July 2050');
        $record->er_saverelationsforoptiondates = 1;
        $record->local_entities_entityarea_1 = "optiondate";
        $record->local_entities_entityid_1 = $entityid2; // Option date entity.

After some debugging I found:

  1. Strange code in the entities->prepare_save_field() which is newer in use because $option never instantiated there (and logic looks outdated - it intends to force the same entity all the time) image

  2. I need some hints about logic of optiondte->save() because entity id seems like being lost there
    image

    • but it happens only during phpunit test. Value had been preserved for manual or behat as expected...

UPD: found workaround for the phpunit. Option date had been saved but not shown in option's settings up to

$session = reset($settings->sessions);
$entities = $handler->get_instance_data($session->optiondateid);