diff --git a/communication/provider/matrix/classes/matrix_rooms.php b/communication/provider/matrix/classes/matrix_rooms.php index 2a00f55128d..157351cd352 100644 --- a/communication/provider/matrix/classes/matrix_rooms.php +++ b/communication/provider/matrix/classes/matrix_rooms.php @@ -136,9 +136,9 @@ class matrix_rooms { /** * Get the matrix room topic. * - * @return string|null + * @return string */ - public function get_topic(): ?string { - return $this->record->topic; + public function get_topic(): string { + return $this->record->topic ?? ''; } } diff --git a/communication/provider/matrix/tests/matrix_rooms_test.php b/communication/provider/matrix/tests/matrix_rooms_test.php index f7f43c57bf1..7f9788252ba 100644 --- a/communication/provider/matrix/tests/matrix_rooms_test.php +++ b/communication/provider/matrix/tests/matrix_rooms_test.php @@ -49,6 +49,16 @@ class matrix_rooms_test extends \advanced_testcase { public function test_create_room_record(): void { $this->resetAfterTest(); + $room = matrix_rooms::create_room_record( + processorid: 10000, + topic: null, + ); + $this->assertInstanceOf(matrix_rooms::class, $room); + $this->assertEquals(10000, $room->get_processor_id()); + $this->assertNotNull('', $room->get_topic()); + $this->assertEquals('', $room->get_topic()); + $this->assertNull($room->get_room_id()); + $room = matrix_rooms::create_room_record( processorid: 12345, topic: 'The topic of this room is thusly',