public function testSetData()
 {
     $col = new Collection();
     $col->setData(array());
     $this->assertEquals(array(), $col->getArrayCopy(), 'setData() can set data to an empty array');
     $data = array('bar1', 'bar2', 'bar3');
     $col = new Collection();
     $col->setData($data);
     $this->assertEquals($data, $col->getArrayCopy(), 'setData() sets the collection data');
 }
Example #2
0
 public function testIsEven()
 {
     $col = new Collection();
     $this->assertTrue($col->isEven(), 'isEven() returns true on an empty collection');
     $data = array('bar1', 'bar2', 'bar3');
     $col = new Collection();
     $col->setData($data);
     foreach ($col as $key => $value) {
         $this->assertEquals(!(bool) ($key % 2), $col->isEven(), 'isEven() returns true only when the key is even');
     }
 }
Example #3
0
 public function setData($data)
 {
     parent::setData($data);
     $this->rebuildIndex();
 }