Exemplo n.º 1
0
 public function getCollection()
 {
     $collection = new Collection();
     $collection->add(1);
     $collection->add(2);
     $collection->add(3);
     $collection->add(4);
     $collection->add(5);
     $collection->add(6);
     return array(array(new Paginator($collection, 1, 1)));
 }
Exemplo n.º 2
0
 public function testSearchForAMissingElementReturnsFalse()
 {
     $collection = new Collection();
     $collection->add((object) array('property' => '12345'));
     $collection->add((object) array('property' => '12'));
     $collection->add((object) array('property' => '2'));
     $this->assertFalse($collection->exists(function ($element) {
         return $element->property === '1';
     }));
 }
Exemplo n.º 3
0
 public function testOrderIsCorrectWhenIteratingAfterSorting()
 {
     $collection = new Collection(array(3, 2, 1));
     $collection->sort(new \PHPExtra\Sorter\Sorter());
     $sortedValues = array();
     foreach ($collection as $item) {
         $sortedValues[] = $item;
     }
     $this->assertEquals(array(1, 2, 3), $sortedValues);
 }