This repository has been archived on 2020-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
ext-collections/tests/047-distinct.phpt

24 lines
582 B
Plaintext
Raw Normal View History

2018-08-28 13:24:26 +00:00
--TEST--
Test Collection::distinct().
--FILE--
<?php
$array = [];
2018-08-28 16:36:50 +00:00
for ($i = 0; $i < 100; ++$i) {
$array[] = mt_rand(1, 10);
2018-08-28 14:11:09 +00:00
}
2018-08-28 13:24:26 +00:00
$collection = Collection::init($array)->distinct();
2018-08-28 14:11:09 +00:00
if ($collection->toArray() != array_values(array_unique($array))) {
2018-08-28 13:24:26 +00:00
echo 'Collection::distinct() failed.', PHP_EOL;
2018-08-28 14:11:09 +00:00
}
2018-08-28 13:24:26 +00:00
$array = [];
2018-08-28 16:36:50 +00:00
for ($i = 0; $i < 300; ++$i) {
$array[random_bytes(4)] = random_bytes(1);
2018-08-28 14:11:09 +00:00
}
2018-08-28 13:24:26 +00:00
$collection = Collection::init($array)->distinct();
2018-08-28 14:11:09 +00:00
if (array_diff($collection->toArray(), array_unique($array))) {
2018-08-28 13:24:26 +00:00
echo 'Collection::distinct() failed.', PHP_EOL;
2018-08-28 14:11:09 +00:00
}
2018-08-28 13:24:26 +00:00
?>
--EXPECT--