MDL-77917 communication_matrix: Topic must not be null
The Matrix space/room topic must always be a string. We should normalise this on the way out of the API.
This commit is contained in:
@@ -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 ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user