@@ -1478,6 +1478,36 @@ public function testOrderBys()
1478
1478
$ this ->assertEquals ([1 , 1 , 'news ' , 'opinion ' ], $ builder ->getBindings ());
1479
1479
}
1480
1480
1481
+ public function testLatest ()
1482
+ {
1483
+ $ builder = $ this ->getBuilder ();
1484
+ $ builder ->select ('* ' )->from ('users ' )->latest ();
1485
+ $ this ->assertSame ('select * from "users" order by "created_at" desc ' , $ builder ->toSql ());
1486
+
1487
+ $ builder = $ this ->getBuilder ();
1488
+ $ builder ->select ('* ' )->from ('users ' )->latest ()->limit (1 );
1489
+ $ this ->assertSame ('select * from "users" order by "created_at" desc limit 1 ' , $ builder ->toSql ());
1490
+
1491
+ $ builder = $ this ->getBuilder ();
1492
+ $ builder ->select ('* ' )->from ('users ' )->latest ('updated_at ' );
1493
+ $ this ->assertSame ('select * from "users" order by "updated_at" desc ' , $ builder ->toSql ());
1494
+ }
1495
+
1496
+ public function testOldest ()
1497
+ {
1498
+ $ builder = $ this ->getBuilder ();
1499
+ $ builder ->select ('* ' )->from ('users ' )->oldest ();
1500
+ $ this ->assertSame ('select * from "users" order by "created_at" asc ' , $ builder ->toSql ());
1501
+
1502
+ $ builder = $ this ->getBuilder ();
1503
+ $ builder ->select ('* ' )->from ('users ' )->oldest ()->limit (1 );
1504
+ $ this ->assertSame ('select * from "users" order by "created_at" asc limit 1 ' , $ builder ->toSql ());
1505
+
1506
+ $ builder = $ this ->getBuilder ();
1507
+ $ builder ->select ('* ' )->from ('users ' )->oldest ('updated_at ' );
1508
+ $ this ->assertSame ('select * from "users" order by "updated_at" asc ' , $ builder ->toSql ());
1509
+ }
1510
+
1481
1511
public function testOrderBysSqlServer ()
1482
1512
{
1483
1513
$ builder = $ this ->getSqlServerBuilder ();
0 commit comments