@@ -259,6 +259,66 @@ public function testDeleteSqlite()
259
259
260
260
261
261
262
+ /**
263
+ * @covers \Nova\ORM\Entity
264
+ * @covers \Nova\ORM\Entity::query
265
+ * @covers \Nova\ORM\Entity::save
266
+ * @covers \Nova\ORM\Query
267
+ * @covers \Nova\ORM\Query::all
268
+ * @covers \Nova\ORM\Query::limit
269
+ * @covers \Nova\ORM\Query::offset
270
+ */
271
+ public function executeTestLimit ()
272
+ {
273
+ // Creating 20 cars
274
+ for ($ i = 0 ; $ i < 20 ; $ i ++) {
275
+ $ car = new Car ();
276
+ $ car ->make = 'Nova Cars ' ;
277
+ $ car ->model = 'Framework_ORM_Test_Limit_ ' . $ i ;
278
+ $ car ->costs = 9900 ;
279
+
280
+ $ result = $ car ->save ();
281
+ $ this ->assertEquals (1 , $ result );
282
+ }
283
+
284
+ $ all = Car::find ()->all ();
285
+ $ this ->assertGreaterThanOrEqual (22 , count ($ all ));
286
+
287
+ // Limit test
288
+ $ first = Car::find ()->limit (10 )->all ();
289
+ $ this ->assertEquals (10 , count ($ first ));
290
+
291
+
292
+ $ second = Car::find ()->limit (10 )->offset (10 )->all ();
293
+ $ this ->assertEquals (10 , count ($ second ));
294
+
295
+ // No duplicates allowed, should be 2 arrays with exactly different carid values!
296
+ foreach ($ first as $ entityHere ) {
297
+ foreach ($ second as $ entityThere ) {
298
+ $ this ->assertNotEquals ($ entityHere ->carid , $ entityThere ->carid );
299
+ }
300
+ }
301
+ }
302
+
303
+ /**
304
+ * @covers \Nova\ORM\Entity
305
+ * @covers \Nova\ORM\Entity::query
306
+ * @covers \Nova\ORM\Query
307
+ * @covers \Nova\ORM\Query::all
308
+ * @covers \Nova\ORM\Query::limit
309
+ * @covers \Nova\ORM\Query::offset
310
+ */
311
+ public function testLimit ()
312
+ {
313
+ Utils::switchDatabase ('sqlite ' );
314
+ $ this ->executeTestLimit ();
315
+
316
+ Utils::switchDatabase ('mysql ' );
317
+ $ this ->executeTestLimit ();
318
+ }
319
+
320
+
321
+
262
322
/**
263
323
* Cleanup
264
324
*
0 commit comments