Пример #1
0
 /**
  * Rewinds the cursor to its first position.
  */
 public function rewind()
 {
     if ($this->_started && $this->_resource) {
         throw new DatabaseException("PDO statement tesource doesn't support rewind operation.");
     }
     parent::rewind();
 }
Пример #2
0
            $value = $cursor->current();
            expect($value)->toBe(1);
        });
    });
    describe("->next()", function () {
        it("returns the next value", function () {
            $cursor = new Cursor(['data' => [1, 2, 3, 4, 5]]);
            expect($cursor->next())->toBe(1);
            expect($cursor->current())->toBe(1);
            expect($cursor->next())->toBe(2);
            expect($cursor->current())->toBe(2);
            expect($cursor->next())->toBe(3);
            expect($cursor->current())->toBe(3);
            expect($cursor->next())->toBe(4);
            expect($cursor->current())->toBe(4);
            expect($cursor->next())->toBe(5);
            expect($cursor->current())->toBe(5);
            expect($cursor->next())->toBe(false);
            // returns `false` just to follow a weird PHP convention
            expect($cursor->valid())->toBe(false);
        });
    });
    describe("->rewind()", function () {
        it("returns respectively the first and the last item of the collection", function () {
            $cursor = new Cursor(['data' => [1, 2, 3, 4, 5]]);
            expect($cursor->next())->toBe(1);
            $cursor->rewind();
            expect($cursor->next())->toBe(1);
        });
    });
});