setValue($datatables, $input); $limitMethod = new ReflectionMethod(SafeDatatables::class, 'limit'); return $limitMethod->invoke($datatables); } function safeDatatablesAssert($condition, $message) { if (!$condition) { throw new RuntimeException($message); } } $database = new SafeDatatablesPaginationTestDatabase(null); $standard = new SafeDatatables($database); $showAll = new SafeDatatables($database, true); safeDatatablesAssert( safeDatatablesLimit($standard, ['start' => 0, 'length' => -1]) === ' LIMIT 0, 10 ', 'Standard tables must not be able to disable the page-size limit.' ); safeDatatablesAssert( safeDatatablesLimit($showAll, ['start' => 0, 'length' => -1]) === '', 'Explicit show-all tables must omit the SQL row limit.' ); safeDatatablesAssert( safeDatatablesLimit($showAll, ['start' => 5, 'length' => 1000]) === ' LIMIT 5, 100 ', 'Explicit show-all mode must retain the normal cap without the -1 sentinel.' ); echo "Safe Datatables pagination passed.\n";