Sokil\Mongo\CursorTest::testSlice PHP Method

testSlice() public method

public testSlice ( )
    public function testSlice()
    {
        // create new document
        $document = $this->collection->createDocument(array('key' => array('a', 'b', 'c', 'd', 'e', 'f')))->save();
        // only limit defined
        $this->assertEquals(array('a', 'b'), $this->collection->find()->slice('key', 2)->findOne()->key);
        $this->assertEquals(array('e', 'f'), $this->collection->find()->slice('key', -2)->findOne()->key);
        // limit and skip defined
        $this->assertEquals(array('c'), $this->collection->find()->slice('key', 1, 2)->findOne()->key);
        $this->assertEquals(array('e'), $this->collection->find()->slice('key', 1, -2)->findOne()->key);
    }