Exemplo n.º 1
0
 });
 describe("->first()/->rewind()/->end()", function () {
     it("returns respectively the first and the last item of the collection", function () {
         $collection = new Collection([1, 2, 3, 4, 5]);
         expect($collection->end())->toBe(5);
         expect($collection->rewind())->toBe(1);
         expect($collection->end())->toBe(5);
         expect($collection->first())->toBe(1);
     });
 });
 describe("->valid()", function () {
     it("returns true only when the collection is valid", function () {
         $collection = new Collection();
         expect($collection->valid())->toBe(false);
         $collection = new Collection([1, 5]);
         expect($collection->valid())->toBe(true);
     });
 });
 describe("->count()", function () {
     it("returns 0 on empty", function () {
         $collection = new Collection();
         expect($collection)->toHaveLength(0);
     });
     it("returns the number of items in the collection", function () {
         $collection = new Collection([5, null, 4, true, false, 'bob']);
         expect($collection)->toHaveLength(6);
     });
 });
 describe("->merge()", function () {
     it("merges two collection with key preservation", function () {
         $collection = new Collection([1, 2, 3]);