(BBB Instance name): meetingevents: {$chats}
"; + +echo $OUTPUT->footer(); diff --git a/mod/bigbluebuttonbn/tests/local/extension_test.php b/mod/bigbluebuttonbn/tests/local/extension_test.php index 3b9b2c03dca3f..4ea3caa8c262a 100644 --- a/mod/bigbluebuttonbn/tests/local/extension_test.php +++ b/mod/bigbluebuttonbn/tests/local/extension_test.php @@ -17,6 +17,7 @@ use backup; use backup_controller; +use mod_bigbluebuttonbn\broker; use mod_bigbluebuttonbn\extension; use mod_bigbluebuttonbn\instance; use mod_bigbluebuttonbn\local\extension\mod_instance_helper; @@ -258,6 +259,51 @@ public function test_backup_restore(): void { $this->assertEquals(5, $oldfieldrecord->newfield); } + /** + * Test broker meeting_events with and without addons. + * @return void + * @covers \mod_bigbluebuttonbn\local\extension\broker_meeting_events_addons + */ + public function test_broker_meeting_events_addons(): void { + $this->resetAfterTest(); + global $DB; + // Enable plugin. + $this->enable_plugins(true); + $this->initialise_mock_server(); + [$bbactivitycontext, $bbactivitycm, $bbactivity] = $this->create_instance( + $this->get_course()); + $plugingenerator = $this->getDataGenerator()->get_plugin_generator('mod_bigbluebuttonbn'); + $user = $this->getDataGenerator()->create_user(); + $this->setUser($user); + // Now create a couple of events. + $instance = instance::get_from_instanceid($bbactivity->id); + set_config('bigbluebuttonbn_meetingevents_enabled', true); + $meeting = $plugingenerator->create_meeting([ + 'instanceid' => $instance->get_instance_id(), + 'groupid' => $instance->get_group_id(), + 'participants' => json_encode([$user->id]), + ]); + $events = [ + (object) ['name' => 'talks'], + (object) ['name' => 'raisehand'], + (object) ['name' => 'raisehand'], + ]; + foreach ($events as $edesc) { + $plugingenerator->add_meeting_event($user, $instance, $edesc->name, $edesc->data ?? ''); + } + $result = $plugingenerator->send_all_events($instance); + $this->assertNotEmpty($result->data); + $data = json_encode($result->data); + $reflection = new \ReflectionClass(broker::class); + $method = $reflection->getMethod('process_extension_actions'); + $method->setAccessible(true); + $method->invokeArgs(null, [$instance, $data]); + $addondata = $DB->get_field('bbbext_simple', 'meetingevents', ['bigbluebuttonbnid' => $bbactivity->id]); + $addondata = json_decode($addondata); + // Check that the data is received. + $this->assertEquals(json_encode($addondata), $data); + } + /** * Data provider for testing get_class_implementing *