Skip to content
Permalink
Browse files

Adding message in exception and removing some "use" statements

  • Loading branch information...
lorenzo committed Dec 27, 2013
1 parent c92077d commit 2ca58a1e1721472c20b577c8f6f9035fc10a42ac
Showing with 13 additions and 7 deletions.
  1. +10 −0 Cake/Test/TestCase/Utility/CollectionTest.php
  2. +3 −7 Cake/Utility/Collection.php
@@ -497,4 +497,14 @@ public function testToJson() {
$this->assertEquals(json_encode($data), json_encode($collection));
}
/**
* Tests that only arrays and Traversables are allowed in the constructor
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Only array or \Traversable are allowed for Collection
* @return void
*/
public function testInvalidConstructorArgument() {
new Collection('Derp');
}
}
@@ -16,15 +16,9 @@
use ArrayIterator;
use Cake\Utility\CollectionTrait;
use Cake\Utility\Iterator\ExtractIterator;
use Cake\Utility\Iterator\FilterIterator;
use Cake\Utility\Iterator\ReplaceIterator;
use Cake\Utility\Iterator\SortIterator;
use Cake\Utility\MapReduce;
use InvalidArgumentException;
use IteratorIterator;
use JsonSerializable;
use LimitIterator;
/**
* A collection is an immutable list of elements with a handful of functions to
@@ -46,8 +40,10 @@ public function __construct($items) {
}
if (!($items instanceof \Traversable)) {
throw new InvalidArgumentException;
$msg = __d('cake_dev', 'Only array or \Traversable are allowed for Collection');
throw new InvalidArgumentException($msg);
}
parent::__construct($items);
}

0 comments on commit 2ca58a1

Please sign in to comment.
You can’t perform that action at this time.