| 1 | <?php |
||
| 21 | class ArrayUtilsTest extends TestCase |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @covers ::toArray |
||
| 25 | */ |
||
| 26 | public function testToArrayWithNull() |
||
| 27 | { |
||
| 28 | $this->assertEquals([], ArrayUtils::toArray(null)); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @covers ::toArray |
||
| 33 | */ |
||
| 34 | public function testToArrayWithArray() |
||
| 35 | { |
||
| 36 | $this->assertEquals(['hello' => 'world'], ArrayUtils::toArray(['hello' => 'world'])); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @covers ::toArray |
||
| 41 | */ |
||
| 42 | public function testToArrayWithIterator() |
||
| 43 | { |
||
| 44 | $this->assertEquals(['hello' => 'world'], ArrayUtils::toArray(new ArrayIterator(['hello' => 'world']))); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @covers ::toArray |
||
| 49 | */ |
||
| 50 | public function testToArrayWithInvalidValue() |
||
| 51 | { |
||
| 52 | $this->expectException(InvalidArgumentException::class); |
||
| 53 | ArrayUtils::toArray('foo'); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |