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 diff --git a/tests/unit/BigBlueButtonTest.php b/tests/unit/BigBlueButtonTest.php index 9f804c42..e211d8c0 100644 --- a/tests/unit/BigBlueButtonTest.php +++ b/tests/unit/BigBlueButtonTest.php @@ -227,6 +227,90 @@ public function testCreateMeetingUrl(): void $this->assertUrlContainsAllRequestParameters($url, $params); } + /** + * Test create meeting without modules. + */ + 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()); + } + + /** + * Test create meeting with modules (presentations and clientSettingsOverride). + */ + 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 */ /**