-
-
Notifications
You must be signed in to change notification settings - Fork 632
Expand file tree
/
Copy pathFakesQueriesTest.php
More file actions
61 lines (50 loc) · 1.52 KB
/
Copy pathFakesQueriesTest.php
File metadata and controls
61 lines (50 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace Tests\Query;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Facades\User;
use Tests\TestCase;
class FakesQueriesTest extends TestCase
{
#[Test]
public function it_supports_to_sql()
{
$query = User::query()->where('name', 'Jack');
$this->assertSame('select * from users where name = ?', $query->toSql());
}
#[Test]
public function it_supports_to_raw_sql()
{
$query = User::query()->where('name', 'Jack');
$this->assertSame("select * from users where name = 'Jack'", $query->toRawSql());
}
#[Test]
public function it_converts_date_bindings_to_the_app_timezone_in_raw_sql()
{
Carbon::setTestNow('2026-07-04 10:00:00');
$query = User::query()->where('created_at', Carbon::today('Europe/Zurich'));
$this->assertSame(
"select * from users where created_at = '2026-07-03 22:00:00'",
$query->toRawSql()
);
Carbon::setTestNow();
}
#[Test]
public function it_supports_dump_raw_sql()
{
$query = User::query()->where('name', 'Jack');
$this->assertSame($query, $query->dumpRawSql());
}
#[Test]
public function it_supports_dd_raw_sql()
{
$query = User::query()->where('name', 'Jack');
$this->assertIsCallable([$query, 'ddRawSql']);
}
#[Test]
public function it_supports_ray()
{
$query = User::query()->where('name', 'Jack');
$this->assertIsCallable([$query, 'ray']);
}
}