Skip to content

Commit

Permalink
Add missing tests (#182)
Browse files Browse the repository at this point in the history
* Add meta param tests

* Add test for idNotUnique error

* Add test for recording preview width/height and caching

* Add test for remove presentation in insertDocuments

* Add missing properties
  • Loading branch information
SamuelWei committed Feb 27, 2024
1 parent bcd5208 commit f217d82
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Core/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class Record

/** @var PlaybackFormat[] */
private $playbackFormats = [];
private $playbackType;
private $playbackUrl;
private $playbackLength;

public function __construct(\SimpleXMLElement $xml)
{
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/create_meeting_not_unique_error.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<response>
<returncode>FAILED</returncode>
<messageKey>idNotUnique</messageKey>
<message>A meeting already exists with that meeting ID. Please use a different meeting ID.</message>
</response>
21 changes: 21 additions & 0 deletions tests/unit/Parameters/CreateMeetingParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ public function testCreateMeetingParameters()
$this->assertEquals($newId, $createMeetingParams->getMeetingID());
}

public function testMetaParameters(): void
{
$params = $this->generateCreateParams();
$createMeetingParams = $this->getCreateMock($params);
$createMeetingParams->addMeta('userdata-bbb_hide_presentation_on_join', true);
$createMeetingParams->addMeta('userdata-bbb_show_participants_on_login', false);
$createMeetingParams->addMeta('userdata-bbb_fullaudio_bridge', 'fullaudio');

// Test getters
$this->assertTrue($createMeetingParams->getMeta('userdata-bbb_hide_presentation_on_join'));
$this->assertFalse($createMeetingParams->getMeta('userdata-bbb_show_participants_on_login'));
$this->assertEquals('fullaudio', $createMeetingParams->getMeta('userdata-bbb_fullaudio_bridge'));

$params = urldecode($createMeetingParams->getHTTPQuery());

// Test HTTP query
$this->assertStringContainsString('meta_userdata-bbb_hide_presentation_on_join=true', $params);
$this->assertStringContainsString('meta_userdata-bbb_show_participants_on_login=false', $params);
$this->assertStringContainsString('meta_userdata-bbb_fullaudio_bridge=fullaudio', $params);
}

public function testDisabledFeatures(): void
{
$params = $this->generateCreateParams();
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Parameters/InsertDocumentParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@

final class InsertDocumentParametersTest extends TestCase
{
public function testIsMeetingRunningParameters(): void
public function testInsertingDocuments(): void
{
$meetingId = $this->faker->uuid;
$params = new InsertDocumentParameters($meetingId);

// Adding presentations
$params->addPresentation('http://localhost/foobar.png', 'Foobar.png');
$params->addPresentation('http://localhost/foobar.pdf', 'Foobar.pdf', true);
$params->addPresentation('http://localhost/foobar.svg', 'Foobar.svg', true, false);
$params->addPresentation('http://localhost/demo.pdf', 'Demo.pdf', true);

// Removing presentation
$params->removePresentation('http://localhost/demo.pdf');

$this->assertEquals($meetingId, $params->getMeetingID());

Expand Down
19 changes: 19 additions & 0 deletions tests/unit/Responses/CreateMeetingResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ protected function setUp(): void

public function testCreateMeetingResponseContent()
{
$this->assertTrue($this->meeting->success());
$this->assertFalse($this->meeting->failed());
$this->assertEquals('SUCCESS', $this->meeting->getReturnCode());

$this->assertEquals('random-1665177', $this->meeting->getMeetingId());
$this->assertEquals('1a6938c707cdf5d052958672d66c219c30690c47-1524212045514', $this->meeting->getInternalMeetingId());
$this->assertEquals('bbb-none', $this->meeting->getParentMeetingId());
Expand All @@ -54,7 +57,10 @@ public function testCreateMeetingResponseContent()
$this->assertEquals(20, $this->meeting->getDuration());
$this->assertFalse($this->meeting->hasBeenForciblyEnded());
$this->assertEquals('duplicateWarning', $this->meeting->getMessageKey());
$this->assertTrue($this->meeting->isDuplicate());
$this->assertEquals('This conference was already in existence and may currently be in progress.', $this->meeting->getMessage());

$this->assertFalse($this->meeting->isIdNotUnique());
}

public function testCreateMeetingResponseTypes()
Expand All @@ -65,4 +71,17 @@ public function testCreateMeetingResponseTypes()
$this->assertEachGetterValueIsInteger($this->meeting, ['getDuration', 'getVoiceBridge']);
$this->assertEachGetterValueIsBoolean($this->meeting, ['hasUserJoined', 'hasBeenForciblyEnded']);
}

public function testIdNotUnique()
{
$xml = $this->loadXmlFile(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'fixtures'.\DIRECTORY_SEPARATOR.'create_meeting_not_unique_error.xml');

$meeting = new CreateMeetingResponse($xml);

$this->assertFalse($meeting->success());
$this->assertTrue($meeting->failed());
$this->assertEquals('FAILED', $meeting->getReturnCode());

$this->assertTrue($meeting->isIdNotUnique());
}
}
6 changes: 6 additions & 0 deletions tests/unit/Responses/GetRecordingsResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,11 @@ public function testImagePreviews(): void

$this->assertEquals('Welcome to', $previews[0]->getAlt());
$this->assertEquals('https://demo.bigbluebutton.org/presentation/ffbfc4cc24428694e8b53a4e144f414052431693-1530718721124/presentation/d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1530718721134/thumbnails/thumb-1.png', $previews[0]->getUrl());
$this->assertEquals(176, $previews[0]->getWidth());
$this->assertEquals(136, $previews[0]->getHeight());

// Load previews again, check if same instance is returned (caching)
$newPreviews = $formats[1]->getImagePreviews();
$this->assertTrue($previews[0] === $newPreviews[0]);
}
}

0 comments on commit f217d82

Please sign in to comment.