Skip to content

Commit

Permalink
increase test coverage, fix validator order
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed Aug 14, 2023
1 parent 8aadbfd commit ee9f3ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/OpenTok/Util/Validators.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ public static function validateAutoArchiveResolution($archiveResolution)

public static function validateLayoutClassListItem($layoutClassList)
{
if (!is_string($layoutClassList['id'])) {
throw new InvalidArgumentException('Each element in the streamClassArray must have an id string.');
}

if (!is_array($layoutClassList)) {
throw new InvalidArgumentException('Each element in the streamClassArray must have a layoutClassList array.');
}

if (!is_string($layoutClassList['id'])) {
throw new InvalidArgumentException('Each element in the streamClassArray must have an id string.');
}

if (!isset($layoutClassList['layoutClassList'])) {
throw new InvalidArgumentException('layoutClassList not set in array');
}
Expand Down
21 changes: 14 additions & 7 deletions tests/OpenTokTest/Validators/ValidatorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testWillPassCorrectForceMutePayload(): void
'streamId1',
'streamId2'
],
'active' => true
'active' => true
];

Validators::validateForceMuteAllOptions($options);
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testWillFailWhenStreamIdsAreNotCorrect(): void
3536,
'streamId2'
],
'active' => true
'active' => true
];

Validators::validateForceMuteAllOptions($options);
Expand All @@ -121,7 +121,7 @@ public function testWillFailWhenActiveIsNotBool(): void
'streamId1',
'streamId2'
],
'active' => 'true'
'active' => 'true'
];

Validators::validateForceMuteAllOptions($options);
Expand All @@ -133,7 +133,7 @@ public function testWillFailWhenStreamIdsIsNotArray(): void

$options = [
'excludedStreams' => 'streamIdOne',
'active' => false
'active' => false
];

Validators::validateForceMuteAllOptions($options);
Expand All @@ -143,7 +143,7 @@ public function testWillValidateWebsocketConfiguration(): void
{
$this->expectNotToPerformAssertions();
$websocketConfig = [
'uri' => 'ws://valid-websocket',
'uri' => 'ws://valid-websocket',
'streams' => [
'525503c7-913e-43a1-84b4-31b2e9fe668b',
'14026813-4f50-4a5a-9b72-fea25430916d'
Expand All @@ -163,14 +163,14 @@ public function testWillThrowExceptionOnInvalidWebsocketConfiguration(): void
]
];
Validators::validateWebsocketOptions($websocketConfig);
}
}

/**
* @dataProvider resolutionProvider
*/
public function testValidResolutions($resolution, $isValid): void
{
if (!$isValid) {
if ( ! $isValid) {
$this->expectException(InvalidArgumentException::class);
} else {
$this->expectNotToPerformAssertions();
Expand All @@ -179,6 +179,13 @@ public function testValidResolutions($resolution, $isValid): void
Validators::validateResolution($resolution);
}

public function testValidLayoutClassListItemErrorOnString(): void
{
$input = 'example_id';
$this->expectException(\InvalidArgumentException::class);
Validators::validateLayoutClassListItem($input);
}

public function testValidLayoutClassListItem(): void
{
$layoutClassList = [
Expand Down

0 comments on commit ee9f3ad

Please sign in to comment.