use DataTables\Adapters\ResultSet;
use DataTables\ParamsParser;
use Phalcon\Mvc\Model\Query;
describe("ResultSet", function () {
    beforeEach(function () {
        $di = \Phalcon\DI::getDefault();
        $query = $di->get('modelsManager')->createQuery("SELECT * FROM \\Spec\\Models\\User");
        $this->query = $query->execute();
    });
    it("should work without params", function () {
        $dataTables = new ResultSet(20);
        $dataTables->setResultSet($this->query);
        $dataTables->setParser(new ParamsParser(10));
        $response = $dataTables->getResponse();
        expect($dataTables->getParser())->toBeA("object");
        expect(array_keys($response))->toBe(['draw', 'recordsTotal', 'recordsFiltered', 'data']);
        expect($response['recordsTotal'])->toBe(100);
        expect($response['recordsFiltered'])->toBe(100);
        expect(count($response['data']))->toBe(10);
        foreach ($response['data'] as $data) {
            expect(array_keys($data))->toBe(['id', 'name', 'email', 'balance', 'DT_RowId']);
            expect($data['DT_RowId'])->toBe($data['id']);
        }
    });
    describe("Limit&Offset", function () {
        beforeEach(function () {
            $_GET = ['start' => 2, 'length' => 1];
        });
        it("should work with start&length", function () {
            $di = \Phalcon\DI::getDefault();