File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
tests/OpenTokTest/Validators Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -423,8 +423,12 @@ public static function validateDTMFDigits(string $digits): void
423423 // Helpers
424424
425425 // credit: http://stackoverflow.com/a/173479
426- protected static function isAssoc ($ arr )
426+ public static function isAssoc ($ arr ): bool
427427 {
428+ if (array () === $ arr ) {
429+ return false ;
430+ }
431+
428432 return array_keys ($ arr ) !== range (0 , count ($ arr ) - 1 );
429433 }
430434
Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments