Skip to content

Commit 7efb21c

Browse files
authored
Updated PHPUnit to version 9 (fixes #89) (#158)
* Updated PHPUnit to version 9 (fixes #89) * Extended tests
1 parent 7ea8e13 commit 7efb21c

6 files changed

Lines changed: 98 additions & 38 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@
124124
"brainmaestro/composer-git-hooks": "^2.8",
125125
"extensions": {
126126
"phpunit/phpunit": {
127-
"fakerphp/faker": "^1.14"
127+
"fakerphp/faker": "1.20.*"
128128
}
129129
},
130130
"friendsofphp/php-cs-fixer": "^3.3",
131131
"php-coveralls/php-coveralls": "^2.4",
132-
"phpunit/phpunit": "^8",
132+
"phpunit/phpunit": "^9",
133133
"vimeo/psalm": "^4.22"
134134
}
135135
}

phpunit.xml.dist

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
4-
<phpunit backupGlobals="false"
5-
backupStaticAttributes="false"
6-
bootstrap="./tests/bootstrap.php"
7-
colors="true"
8-
convertDeprecationsToExceptions="false"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
processIsolation="false"
13-
stopOnFailure="false">
14-
15-
<filter>
16-
<whitelist processUncoveredFilesFromWhitelist="true">
17-
<directory suffix=".php">./src/</directory>
18-
</whitelist>
19-
</filter>
20-
21-
<testsuites>
22-
<testsuite name="BigBlueButton unit test suite">
23-
<directory>./tests/unit/</directory>
24-
</testsuite>
25-
<testsuite name="BigBlueButton integration test suite">
26-
<directory>./tests/integration/</directory>
27-
</testsuite>
28-
<testsuite name="BigBlueButton functional test suite">
29-
<directory>./tests/functional/</directory>
30-
</testsuite>
31-
</testsuites>
32-
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="./tests/bootstrap.php" colors="true" convertDeprecationsToExceptions="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="BigBlueButton unit test suite">
10+
<directory>./tests/unit/</directory>
11+
</testsuite>
12+
<testsuite name="BigBlueButton integration test suite">
13+
<directory>./tests/integration/</directory>
14+
</testsuite>
15+
<testsuite name="BigBlueButton functional test suite">
16+
<directory>./tests/functional/</directory>
17+
</testsuite>
18+
</testsuites>
3319
</phpunit>

src/Parameters/CreateMeetingParameters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public function getHTTPQuery(): string
526526

527527
if ($this->isBreakout()) {
528528
if ($this->parentMeetingID === null || $this->sequence === null) {
529-
trigger_error('Breakout rooms require a parentMeetingID and sequence number.', \E_USER_WARNING);
529+
throw new \RuntimeException('Breakout rooms require a parentMeetingID and sequence number.');
530530
}
531531
} else {
532532
$queries = $this->filterBreakoutRelatedQueries($queries);

tests/unit/BigBlueButtonTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
use BigBlueButton\Http\Transport\TransportResponse;
2828
use BigBlueButton\Parameters\DeleteRecordingsParameters;
2929
use BigBlueButton\Parameters\GetRecordingsParameters;
30+
use BigBlueButton\Parameters\GetRecordingTextTracksParameters;
3031
use BigBlueButton\Parameters\InsertDocumentParameters;
3132
use BigBlueButton\Parameters\PublishRecordingsParameters;
33+
use BigBlueButton\Parameters\PutRecordingTextTrackParameters;
3234
use PHPUnit\Framework\MockObject\MockObject;
3335

3436
/**
@@ -372,4 +374,77 @@ public function testGetInsertDocument(): void
372374

373375
$this->assertTrue($response->success());
374376
}
377+
378+
public function testGetRecordingTextTracks(): void
379+
{
380+
$params = new GetRecordingTextTracksParameters('foobar');
381+
382+
$json = '{
383+
"response": {
384+
"returncode": "SUCCESS",
385+
"tracks": [
386+
{
387+
"href": "https://captions.example.com/textTrack/0ab39e419c9bcb63233168daefe390f232c71343/183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1554230749920/subtitles_en-US.vtt",
388+
"kind": "subtitles",
389+
"label": "English",
390+
"lang": "en-US",
391+
"source": "upload"
392+
},
393+
{
394+
"href": "https://captions.example.com/textTrack/95b62d1b762700b9d5366a9e71d5fcc5086f2723/183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1554230749920/subtitles_pt-BR.vtt",
395+
"kind": "subtitles",
396+
"label": "Brazil",
397+
"lang": "pt-BR",
398+
"source": "upload"
399+
}
400+
]
401+
}
402+
}';
403+
$this->transport->method('request')->willReturn(new TransportResponse($json, null));
404+
405+
$response = $this->bbb->getRecordingTextTracks($params);
406+
407+
$this->assertTrue($response->success());
408+
$this->assertSame('SUCCESS', $response->getReturnCode());
409+
410+
$tracks = $response->getTracks();
411+
$this->assertCount(2, $tracks);
412+
$this->assertArrayHasKey(0, $tracks);
413+
$this->assertArrayHasKey(1, $tracks);
414+
415+
$this->assertSame('https://captions.example.com/textTrack/0ab39e419c9bcb63233168daefe390f232c71343/183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1554230749920/subtitles_en-US.vtt', $tracks[0]->getHref());
416+
$this->assertSame('subtitles', $tracks[0]->getKind());
417+
$this->assertSame('English', $tracks[0]->getLabel());
418+
$this->assertSame('en-US', $tracks[0]->getLang());
419+
$this->assertSame('upload', $tracks[0]->getSource());
420+
421+
$this->assertSame('https://captions.example.com/textTrack/95b62d1b762700b9d5366a9e71d5fcc5086f2723/183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1554230749920/subtitles_pt-BR.vtt', $tracks[1]->getHref());
422+
$this->assertSame('subtitles', $tracks[1]->getKind());
423+
$this->assertSame('Brazil', $tracks[1]->getLabel());
424+
$this->assertSame('pt-BR', $tracks[1]->getLang());
425+
$this->assertSame('upload', $tracks[1]->getSource());
426+
}
427+
428+
public function testPutRecordingTextTrack(): void
429+
{
430+
$params = new PutRecordingTextTrackParameters('foobar', 'subtitles', 'en-US', 'English');
431+
432+
$json = '{
433+
"response": {
434+
"messageKey": "upload_text_track_success",
435+
"message": "Text track uploaded successfully",
436+
"recordId": "baz",
437+
"returncode": "SUCCESS"
438+
}
439+
}';
440+
$this->transport->method('request')->willReturn(new TransportResponse($json, null));
441+
442+
$response = $this->bbb->putRecordingTextTrack($params);
443+
444+
$this->assertTrue($response->success());
445+
$this->assertNull($response->getMessageKey());
446+
$this->assertNull($response->getMessage());
447+
$this->assertSame('baz', $response->getRecordID());
448+
$this->assertSame('SUCCESS', $response->getReturnCode());
449+
}
375450
}

tests/unit/Parameters/CreateMeetingParametersTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use BigBlueButton\Core\GuestPolicy;
2323
use BigBlueButton\TestCase;
24-
use PHPUnit\Framework\Error\Warning;
2524

2625
/**
2726
* Class CreateMeetingParametersTest.
@@ -123,7 +122,7 @@ public function testCreateBreakoutMeeting()
123122

124123
public function testCreateBreakoutMeetingWithMissingParams()
125124
{
126-
$this->expectException(Warning::class);
125+
$this->expectException(\RuntimeException::class);
127126

128127
$params = new CreateMeetingParameters($this->faker->uuid, $this->faker->name);
129128
$params->setBreakout(true);

tools/.phpunit/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"phpunit/phpunit": "^8",
4-
"fakerphp/faker": "^1.14"
3+
"phpunit/phpunit": "^9.0",
4+
"fakerphp/faker": "1.20.*"
55
}
66
}

0 commit comments

Comments
 (0)