Skip to content

Commit 2645b5d

Browse files
authored
[9.x] Improve test for inRandomOrder in Query Builder Class (#44292)
1 parent 660e017 commit 2645b5d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Database/DatabaseQueryBuilderTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,27 @@ public function testOldest()
15081508
$this->assertSame('select * from "users" order by "updated_at" asc', $builder->toSql());
15091509
}
15101510

1511+
public function testInRandomOrderMySql()
1512+
{
1513+
$builder = $this->getBuilder();
1514+
$builder->select('*')->from('users')->inRandomOrder();
1515+
$this->assertSame('select * from "users" order by RANDOM()', $builder->toSql());
1516+
}
1517+
1518+
public function testInRandomOrderPostgres()
1519+
{
1520+
$builder = $this->getPostgresBuilder();
1521+
$builder->select('*')->from('users')->inRandomOrder();
1522+
$this->assertSame('select * from "users" order by RANDOM()', $builder->toSql());
1523+
}
1524+
1525+
public function testInRandomOrderSqlServer()
1526+
{
1527+
$builder = $this->getSqlServerBuilder();
1528+
$builder->select('*')->from('users')->inRandomOrder();
1529+
$this->assertSame('select * from [users] order by NEWID()', $builder->toSql());
1530+
}
1531+
15111532
public function testOrderBysSqlServer()
15121533
{
15131534
$builder = $this->getSqlServerBuilder();

0 commit comments

Comments
 (0)