Skip to content

Commit

Permalink
chore: add test coverage for whereDate
Browse files Browse the repository at this point in the history
  • Loading branch information
patoui committed Jan 18, 2025
1 parent 0e07fb6 commit cc41a96
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/Feature/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tests/Feature/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc41a96

Please sign in to comment.