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/027-get-set-remove.phpt

22 lines
738 B
PHP

--TEST--
Test Collection::get() and Collection::set().
--FILE--
<?php
$array = ['a' => 'b', 'c' => 'd'];
$collection = Collection::init($array);
$collection->set('a', 'foo');
$collection->set('e', 'bar');
$array['a'] = 'foo';
$array['e'] = 'bar';
if ($collection->toArray() != $array)
echo 'Collection::set() failed.', PHP_EOL;
if ($collection->get('a') != $array['a'] ||
$collection->get('f', function ($key) { return $key; }) != 'f')
echo 'Collection::get() failed.', PHP_EOL;
if (!$collection->remove('a') || !is_null($collection->get('a')))
echo 'Collection::remove() failed.', PHP_EOL;
if ($collection->remove('c', 'e') || $collection->get('c') != 'd')
echo 'Collection::remove() failed.', PHP_EOL;
?>
--EXPECT--