From 4a70ca10b94396d6444909466164c2dd074a39f9 Mon Sep 17 00:00:00 2001 From: Samuel Weirich <4281791+SamuelWei@users.noreply.github.com> Date: Tue, 28 Oct 2025 15:30:54 +0100 Subject: [PATCH 1/3] Add tests --- tests/unit/BigBlueButtonTest.php | 81 ++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/unit/BigBlueButtonTest.php b/tests/unit/BigBlueButtonTest.php index 9f804c42..dfd4060e 100644 --- a/tests/unit/BigBlueButtonTest.php +++ b/tests/unit/BigBlueButtonTest.php @@ -227,6 +227,87 @@ public function testCreateMeetingUrl(): void $this->assertUrlContainsAllRequestParameters($url, $params); } + /** + * Test create meeting URL. + */ + public function testCreate(): void + { + $createMeetingParams = $this->generateCreateParams(); + $params = $this->getCreateMock($createMeetingParams); + + $xml = ' + SUCCESS + '.$params->getMeetingID().' + 1a6938c707cdf5d052958672d66c219c30690c47-1524212045514 + 1453283819419 + '.$params->getVoiceBridge().' + 613-555-1234 + Wed Jan 20 04:56:59 EST 2016 + false + 20 + false + '; + + $this->transport->method('request') + ->with(self::callback(function ($request) { + $payload = $request->getPayload(); + + return $payload == ''; + })) + ->willReturn(new TransportResponse($xml, null)); + + $response = $this->bbb->createMeeting($params); + + $this->assertTrue($response->success()); + $this->assertFalse($response->isDuplicate()); + $this->assertFalse($response->isIdNotUnique()); + } + + public function testCreateWithPresentation(): void + { + $createMeetingParams = $this->generateCreateParams(); + $params = $this->getCreateMock($createMeetingParams); + $params->addPresentation('http://test-install.blindsidenetworks.com/default.pdf', null, 'presentation.pdf'); + $params->addPresentation('http://test-install.blindsidenetworks.com/file.pdf'); + $params->setClientSettingsOverride('{ "public": { "app": { "appName": "Test" } } }'); + + $xml = ' + SUCCESS + '.$params->getMeetingID().' + 1a6938c707cdf5d052958672d66c219c30690c47-1524212045514 + 1453283819419 + '.$params->getVoiceBridge().' + 613-555-1234 + Wed Jan 20 04:56:59 EST 2016 + false + 20 + false + '; + + $this->transport->method('request') + ->with(self::callback(function ($request) { + $payload = $request->getPayload(); + $xml = simplexml_load_string($payload); + + $presentations = $xml->module[0]; + $clientSettingsOverride = $xml->module[1]; + + return \count($xml->module) == 2 + && $presentations->attributes()['name']->__toString() == 'presentation' + && $clientSettingsOverride->attributes()['name']->__toString() == 'clientSettingsOverride' + && $presentations->children()[0]->attributes()['url']->__toString() == 'http://test-install.blindsidenetworks.com/default.pdf' + && $presentations->children()[0]->attributes()['filename']->__toString() == 'presentation.pdf' + && $presentations->children()[1]->attributes()['url']->__toString() == 'http://test-install.blindsidenetworks.com/file.pdf'; + })) + ->willReturn(new TransportResponse($xml, null)); + + $response = $this->bbb->createMeeting($params); + + $this->assertTrue($response->success()); + $this->assertFalse($response->isDuplicate()); + $this->assertFalse($response->isIdNotUnique()); + } + /* Join Meeting */ /** From b67a2dafbd7620de575b749aedee537f86bb1832 Mon Sep 17 00:00:00 2001 From: Samuel Weirich <4281791+SamuelWei@users.noreply.github.com> Date: Tue, 28 Oct 2025 15:31:50 +0100 Subject: [PATCH 2/3] Fix: getModules() should return empty string if no modules are attached --- src/Parameters/CreateMeetingParameters.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Parameters/CreateMeetingParameters.php b/src/Parameters/CreateMeetingParameters.php index 131ad623..ac8fb194 100644 --- a/src/Parameters/CreateMeetingParameters.php +++ b/src/Parameters/CreateMeetingParameters.php @@ -391,10 +391,22 @@ public function getPresentations(): array public function getModules(): string { $xml = new SimpleXMLElementExtended(''); + // Get empty xml as string + $emptyXML = $xml->asXML(); + + // Add modules $this->addPresentationsModule($xml); $this->addClientSettingsOverrideModule($xml); - return $xml->asXML(); + // Get xml as string after modules have been added + $resultXML = $xml->asXML(); + + // If xml was not modified (no modules added), return an empty string + if ($emptyXML === $resultXML) { + return ''; + } + + return $resultXML; } public function addClientSettingsOverrideModule(SimpleXMLElementExtended $xml): void From 05c5c57f3259711af6b1b373f04c295347e54de8 Mon Sep 17 00:00:00 2001 From: Samuel Weirich <4281791+SamuelWei@users.noreply.github.com> Date: Tue, 28 Oct 2025 15:36:15 +0100 Subject: [PATCH 3/3] Fix cs and docs --- tests/unit/BigBlueButtonTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/BigBlueButtonTest.php b/tests/unit/BigBlueButtonTest.php index dfd4060e..e211d8c0 100644 --- a/tests/unit/BigBlueButtonTest.php +++ b/tests/unit/BigBlueButtonTest.php @@ -228,7 +228,7 @@ public function testCreateMeetingUrl(): void } /** - * Test create meeting URL. + * Test create meeting without modules. */ public function testCreate(): void { @@ -252,7 +252,7 @@ public function testCreate(): void ->with(self::callback(function ($request) { $payload = $request->getPayload(); - return $payload == ''; + return $payload === ''; })) ->willReturn(new TransportResponse($xml, null)); @@ -263,6 +263,9 @@ public function testCreate(): void $this->assertFalse($response->isIdNotUnique()); } + /** + * Test create meeting with modules (presentations and clientSettingsOverride). + */ public function testCreateWithPresentation(): void { $createMeetingParams = $this->generateCreateParams();