Browse Source

Merge pull request #13415 from cakephp/collection-skip-test

Add tests for skip() overflow.
Mark Story 6 years ago
parent
commit
72cac845fe
1 changed files with 14 additions and 0 deletions
  1. 14 0
      tests/TestCase/Collection/CollectionTest.php

+ 14 - 0
tests/TestCase/Collection/CollectionTest.php

@@ -2104,10 +2104,24 @@ class CollectionTest extends TestCase
         $collection = new Collection([1, 2, 3, 4, 5]);
         $this->assertEquals([3, 4, 5], $collection->skip(2)->toList());
 
+        $this->assertEquals([1, 2, 3, 4, 5], $collection->skip(0)->toList());
+        $this->assertEquals([4, 5], $collection->skip(3)->toList());
         $this->assertEquals([5], $collection->skip(4)->toList());
     }
 
     /**
+     * Test skip() with an overflow
+     *
+     * @return void
+     */
+    public function testSkipOverflow()
+    {
+        $collection = new Collection([1, 2, 3]);
+        $this->assertEquals([], $collection->skip(3)->toArray());
+        $this->assertEquals([], $collection->skip(4)->toArray());
+    }
+
+    /**
      * Tests the skip() method with a traversable non-iterator
      *
      * @return void