Skip to content

Commit ee9f3ad

Browse files
committed
increase test coverage, fix validator order
1 parent 8aadbfd commit ee9f3ad

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/OpenTok/Util/Validators.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,14 @@ public static function validateAutoArchiveResolution($archiveResolution)
421421

422422
public static function validateLayoutClassListItem($layoutClassList)
423423
{
424-
if (!is_string($layoutClassList['id'])) {
425-
throw new InvalidArgumentException('Each element in the streamClassArray must have an id string.');
426-
}
427-
428424
if (!is_array($layoutClassList)) {
429425
throw new InvalidArgumentException('Each element in the streamClassArray must have a layoutClassList array.');
430426
}
431427

428+
if (!is_string($layoutClassList['id'])) {
429+
throw new InvalidArgumentException('Each element in the streamClassArray must have an id string.');
430+
}
431+
432432
if (!isset($layoutClassList['layoutClassList'])) {
433433
throw new InvalidArgumentException('layoutClassList not set in array');
434434
}

tests/OpenTokTest/Validators/ValidatorsTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testWillPassCorrectForceMutePayload(): void
6767
'streamId1',
6868
'streamId2'
6969
],
70-
'active' => true
70+
'active' => true
7171
];
7272

7373
Validators::validateForceMuteAllOptions($options);
@@ -106,7 +106,7 @@ public function testWillFailWhenStreamIdsAreNotCorrect(): void
106106
3536,
107107
'streamId2'
108108
],
109-
'active' => true
109+
'active' => true
110110
];
111111

112112
Validators::validateForceMuteAllOptions($options);
@@ -121,7 +121,7 @@ public function testWillFailWhenActiveIsNotBool(): void
121121
'streamId1',
122122
'streamId2'
123123
],
124-
'active' => 'true'
124+
'active' => 'true'
125125
];
126126

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

134134
$options = [
135135
'excludedStreams' => 'streamIdOne',
136-
'active' => false
136+
'active' => false
137137
];
138138

139139
Validators::validateForceMuteAllOptions($options);
@@ -143,7 +143,7 @@ public function testWillValidateWebsocketConfiguration(): void
143143
{
144144
$this->expectNotToPerformAssertions();
145145
$websocketConfig = [
146-
'uri' => 'ws://valid-websocket',
146+
'uri' => 'ws://valid-websocket',
147147
'streams' => [
148148
'525503c7-913e-43a1-84b4-31b2e9fe668b',
149149
'14026813-4f50-4a5a-9b72-fea25430916d'
@@ -163,14 +163,14 @@ public function testWillThrowExceptionOnInvalidWebsocketConfiguration(): void
163163
]
164164
];
165165
Validators::validateWebsocketOptions($websocketConfig);
166-
}
166+
}
167167

168168
/**
169169
* @dataProvider resolutionProvider
170170
*/
171171
public function testValidResolutions($resolution, $isValid): void
172172
{
173-
if (!$isValid) {
173+
if ( ! $isValid) {
174174
$this->expectException(InvalidArgumentException::class);
175175
} else {
176176
$this->expectNotToPerformAssertions();
@@ -179,6 +179,13 @@ public function testValidResolutions($resolution, $isValid): void
179179
Validators::validateResolution($resolution);
180180
}
181181

182+
public function testValidLayoutClassListItemErrorOnString(): void
183+
{
184+
$input = 'example_id';
185+
$this->expectException(\InvalidArgumentException::class);
186+
Validators::validateLayoutClassListItem($input);
187+
}
188+
182189
public function testValidLayoutClassListItem(): void
183190
{
184191
$layoutClassList = [

0 commit comments

Comments
 (0)