Exemplo n.º 1
0
 describe("->next()", function () {
     it("returns the next value", function () {
         $collection = new Collection(['data' => [1, 2, 3, 4, 5]]);
         $value = $collection->next();
         expect($value)->toBe(2);
     });
 });
 describe("->prev()", function () {
     it("navigates through collection", function () {
         $collection = new Collection(['data' => [1, 2, 3]]);
         $collection->rewind();
         expect($collection->next())->toBe(2);
         expect($collection->next())->toBe(3);
         expect($collection->next())->toBe(null);
         $collection->end();
         expect($collection->prev())->toBe(2);
         expect($collection->prev())->toBe(1);
         expect($collection->prev())->toBe(null);
     });
 });
 describe("->rewind/end()", function () {
     it("returns respectively the first and the last item of the collection", function () {
         $collection = new Collection(['data' => [1, 2, 3, 4, 5]]);
         expect($collection->end())->toBe(5);
         expect($collection->rewind())->toBe(1);
     });
 });
 describe("->valid()", function () {
     it("returns true only when the collection is valid", function () {
         $collection = new Collection();
         expect($collection->valid())->toBe(false);