@@ -156,7 +156,7 @@ public function testAddMultiple(): void
156156 public function testFilter (): void
157157 {
158158 // Given
159- $ items = [1 , 2 , 3 ,4 , 5 , 6 , 7 , 8 , 9 , 10 ];
159+ $ items = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ];
160160 $ collection = new Collection ($ items );
161161
162162 // When
@@ -584,4 +584,32 @@ public function testHasItems(): void
584584 $ this ->assertFalse ((new Collection ([]))->hasItems ());
585585 $ this ->assertTrue ((new Collection ([1 ]))->hasItems ());
586586 }
587+
588+ public function testToArray (): void
589+ {
590+ $ this ->assertSame ([], (new Collection ([]))->toArray ());
591+
592+ $ list = [1 , 2 , 3 ];
593+ $ this ->assertSame ($ list , (new Collection ($ list ))->toArray ());
594+
595+ $ keyValue = ['foo ' => 1 , 'bar ' => 2 , 'baz ' => 3 ];
596+ $ this ->assertSame ($ keyValue , (new Collection ($ keyValue ))->toArray ());
597+
598+ $ numberIndexed = [1 => 1 , 2 => 2 , 3 => 3 , 0 => 0 ];
599+ $ this ->assertSame ($ numberIndexed , (new Collection ($ numberIndexed ))->toArray ());
600+ }
601+
602+ public function testToList (): void
603+ {
604+ $ this ->assertSame ([], (new Collection ([]))->toList ());
605+
606+ $ list = [1 , 2 , 3 ];
607+ $ this ->assertSame ($ list , (new Collection ($ list ))->toList ());
608+
609+ $ keyValue = ['foo ' => 1 , 'bar ' => 2 , 'baz ' => 3 ];
610+ $ this ->assertSame ([1 , 2 , 3 ], (new Collection ($ keyValue ))->toList ());
611+
612+ $ numberIndexed = [1 => 1 , 2 => 2 , 3 => 3 , 0 => 0 ];
613+ $ this ->assertSame ([1 , 2 , 3 , 0 ], (new Collection ($ numberIndexed ))->toList ());
614+ }
587615}
0 commit comments