| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,50 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+namespace Telnyx; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * @internal |
|
| 7 |
+ * @covers \Telnyx\Util\CaseInsensitiveArray |
|
| 8 |
+ */ |
|
| 9 |
+class CaseInsensitiveArrayTest extends TestCase |
|
| 10 |
+{
|
|
| 11 |
+ public function testArrayAccess() |
|
| 12 |
+ {
|
|
| 13 |
+ $arr = new \Telnyx\Util\CaseInsensitiveArray(['One' => '1', 'TWO' => '2']); |
|
| 14 |
+ |
|
| 15 |
+ $arr['thrEE'] = '3'; |
|
| 16 |
+ |
|
| 17 |
+ static::assertSame('1', $arr['one']);
|
|
| 18 |
+ static::assertSame('1', $arr['One']);
|
|
| 19 |
+ static::assertSame('1', $arr['ONE']);
|
|
| 20 |
+ |
|
| 21 |
+ static::assertSame('2', $arr['two']);
|
|
| 22 |
+ static::assertSame('2', $arr['twO']);
|
|
| 23 |
+ static::assertSame('2', $arr['TWO']);
|
|
| 24 |
+ |
|
| 25 |
+ static::assertSame('3', $arr['three']);
|
|
| 26 |
+ static::assertSame('3', $arr['ThReE']);
|
|
| 27 |
+ static::assertSame('3', $arr['THREE']);
|
|
| 28 |
+ } |
|
| 29 |
+ |
|
| 30 |
+ public function testCount() |
|
| 31 |
+ {
|
|
| 32 |
+ $arr = new \Telnyx\Util\CaseInsensitiveArray(['One' => '1', 'TWO' => '2']); |
|
| 33 |
+ |
|
| 34 |
+ static::assertCount(2, $arr); |
|
| 35 |
+ } |
|
| 36 |
+ |
|
| 37 |
+ public function testIterable() |
|
| 38 |
+ {
|
|
| 39 |
+ $arr = new \Telnyx\Util\CaseInsensitiveArray(['One' => '1', 'TWO' => '2']); |
|
| 40 |
+ |
|
| 41 |
+ $seen = []; |
|
| 42 |
+ |
|
| 43 |
+ foreach ($arr as $k => $v) {
|
|
| 44 |
+ $seen[$k] = $v; |
|
| 45 |
+ } |
|
| 46 |
+ |
|
| 47 |
+ static::assertSame('1', $seen['one']);
|
|
| 48 |
+ static::assertSame('2', $seen['two']);
|
|
| 49 |
+ } |
|
| 50 |
+} |