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/034-take-while.phpt

21 lines
574 B
PHP

--TEST--
Test Collection::takeWhile() and Collection::takeLastWhile().
--FILE--
<?php
$array = ['a', 'b', 'C', 'D', 'e'];
$collection = Collection::init($array);
$collection1 = $collection->takeWhile(function ($value) {
return ord($value) > ord('Z');
});
if ($collection1->toArray() != ['a', 'b']) {
echo 'Collection::takeWhile() failed.', PHP_EOL;
}
$collection2 = $collection->takeLastWhile(function ($value) {
return $value != 'b';
});
if ($collection2->toArray() != ['C', 'D', 'e']) {
echo 'Collection::takeLastWhile() failed.', PHP_EOL;
}
?>
--EXPECT--