Пример #1
0
 public function testCollectionPagerAndSelection()
 {
     $author = new Author();
     foreach (range(1, 10) as $i) {
         $ret = $author->create(array('name' => 'Foo-' . $i, 'email' => 'foo@foo' . $i, 'identity' => 'foo' . $i, 'confirmed' => true));
         ok($author->confirmed, 'is true');
         ok($ret->success);
     }
     $authors = new AuthorCollection();
     $authors->where()->equal('confirmed', true);
     foreach ($authors as $author) {
         ok($author->confirmed);
     }
     is(10, $authors->size());
     /* page 1, 10 per page */
     $pager = $authors->pager(1, 10);
     ok($pager);
     $pager = $authors->pager();
     ok($pager);
     ok($pager->items());
     $array = $authors->toArray();
     ok($array[0]);
     ok($array[9]);
     ok($authors->items());
     is(10, count($authors->items()));
     foreach ($authors as $a) {
         $ret = $a->delete();
         ok($ret->success);
     }
 }