diff --git a/README.md b/README.md index 0c9f121..c715442 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Below is a list of currently untested methods or functionality. This does not me - `whereJsonLength` - `whereBetween` - `whereNotBetween` -- `whereDate`, `whereMonth`, `whereDay`, `whereYear`, `whereTime` +- `whereMonth`, `whereDay`, `whereYear`, `whereTime` - `orWhereColumn` - `whereExists` - Subquery Where Clauses diff --git a/tests/Feature/ModelTest.php b/tests/Feature/ModelTest.php index dba6141..9e1f7c3 100644 --- a/tests/Feature/ModelTest.php +++ b/tests/Feature/ModelTest.php @@ -53,6 +53,19 @@ public function test_where_string(): void ); } + public function test_where_date(): void + { + // Arrange + Analytic::create(['ts' => time(), 'analytic_id' => mt_rand(1000, 9999), 'status' => mt_rand(200, 599)]); + Analytic::create(['ts' => time(), 'analytic_id' => mt_rand(1000, 9999), 'status' => mt_rand(200, 599)]); + + // Act & Assert + self::assertSame( + 2, + Analytic::whereDate('ts', date('Y-m-d'))->count() + ); + } + public function test_where_null(): void { // Arrange diff --git a/tests/Feature/QueryTest.php b/tests/Feature/QueryTest.php index 46ca874..35ff5d0 100644 --- a/tests/Feature/QueryTest.php +++ b/tests/Feature/QueryTest.php @@ -75,6 +75,28 @@ public function test_multiple_wheres(): void ); } + public function test_where_date(): void + { + // Arrange + DB::connection('clickhouse')->insert( + 'analytics', + ['ts' => time(), 'analytic_id' => mt_rand(1000, 9999), 'status' => mt_rand(200, 599)] + ); + DB::connection('clickhouse')->insert( + 'analytics', + ['ts' => time(), 'analytic_id' => mt_rand(1000, 9999), 'status' => mt_rand(200, 599)] + ); + + // Act & Assert + self::assertSame( + 2, + DB::connection('clickhouse') + ->table('analytics') + ->whereDate('ts', date('Y-m-d')) + ->count() + ); + } + public function test_select(): void { // Arrange