@@ -1735,8 +1735,26 @@ public function testUniqueStrict($collection)
1735
1735
#[DataProvider('collectionClassProvider ' )]
1736
1736
public function testCollapse ($ collection )
1737
1737
{
1738
+ // Normal case: a two-dimensional array with different elements
1738
1739
$ data = new $ collection ([[$ object1 = new stdClass ], [$ object2 = new stdClass ]]);
1739
1740
$ this ->assertEquals ([$ object1 , $ object2 ], $ data ->collapse ()->all ());
1741
+
1742
+ // Case including numeric and string elements
1743
+ $ data = new $ collection ([[1 ], [2 ], [3 ], ['foo ' , 'bar ' ], new $ collection (['baz ' , 'boom ' ])]);
1744
+ $ this ->assertEquals ([1 , 2 , 3 , 'foo ' , 'bar ' , 'baz ' , 'boom ' ], $ data ->collapse ()->all ());
1745
+
1746
+ // Case with empty two-dimensional arrays
1747
+ $ data = new $ collection ([[], [], []]);
1748
+ $ this ->assertEquals ([], $ data ->collapse ()->all ());
1749
+
1750
+ // Case with both empty arrays and arrays with elements
1751
+ $ data = new $ collection ([[], [1 , 2 ], [], ['foo ' , 'bar ' ]]);
1752
+ $ this ->assertEquals ([1 , 2 , 'foo ' , 'bar ' ], $ data ->collapse ()->all ());
1753
+
1754
+ // Case including collections and arrays
1755
+ $ collection = new $ collection (['baz ' , 'boom ' ]);
1756
+ $ data = new $ collection ([[1 ], [2 ], [3 ], ['foo ' , 'bar ' ], $ collection ]);
1757
+ $ this ->assertEquals ([1 , 2 , 3 , 'foo ' , 'bar ' , 'baz ' , 'boom ' ], $ data ->collapse ()->all ());
1740
1758
}
1741
1759
1742
1760
#[DataProvider('collectionClassProvider ' )]
0 commit comments