Skip to content

Commit

Permalink
Added test for Collection::insert()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 9, 2014
1 parent 68e90dd commit 1538bd3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/TestCase/Collection/CollectionTest.php
Expand Up @@ -839,4 +839,20 @@ public function testNestObjects() {
$this->assertEquals($expected, $collection->toArray());
}

/**
* Tests insert
*
* @return void
*/
public function testInsert() {
$items = [['a' => 1], ['b' => 2]];
$collection = new Collection($items);
$iterator = $collection->insert('c', [3, 4]);
$this->assertInstanceOf('\Cake\Collection\Iterator\InsertIterator', $iterator);
$this->assertEquals(
[['a' => 1, 'c' => 3], ['b' => 2, 'c' => 4]],
iterator_to_array($iterator)
);
}

}

0 comments on commit 1538bd3

Please sign in to comment.