Skip to content

Commit e642c5e

Browse files
committed
test validator method
1 parent 582f7ed commit e642c5e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/OpenTok/Util/Validators.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public static function validateDTMFDigits(string $digits): void
423423
// Helpers
424424

425425
// credit: http://stackoverflow.com/a/173479
426-
protected static function isAssoc($arr): bool
426+
public static function isAssoc($arr): bool
427427
{
428428
if (array() === $arr) {
429429
return false;

tests/OpenTokTest/Validators/ValidatorsTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,30 @@ public function testWillPassCorrectPayload(): void
2323
Validators::validateForceMuteAllOptions($options);
2424
}
2525

26+
public function testIsAssocWithValidArray(): void
27+
{
28+
$haystack = [
29+
'one' => '1',
30+
'two' => '2',
31+
'three' => '3',
32+
'four' => '4'
33+
];
34+
35+
$this->assertTrue(Validators::isAssoc($haystack));
36+
}
37+
38+
public function testIsAssocWithInvalidArray(): void
39+
{
40+
$haystack = [
41+
'one',
42+
'two',
43+
'three',
44+
'four'
45+
];
46+
47+
$this->assertFalse(Validators::isAssoc($haystack));
48+
}
49+
2650
public function testWillFailWhenStreamIdsAreNotCorrect(): void
2751
{
2852
$this->expectException(InvalidArgumentException::class);

0 commit comments

Comments
 (0)