Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malkhazidartsmelidze committed Oct 15, 2024
1 parent 55176cd commit ec742da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Illuminate\Tests\Database;

use BadMethodCallException;
use Carbon\Month;
use Closure;
use DateTime;
use Illuminate\Contracts\Database\Query\ConditionExpression;
Expand Down Expand Up @@ -1405,11 +1404,6 @@ public function testWhereMonthBetween()
$this->assertSame('select * from "users" where month("created_at") between ? and ?', $builder->toSql());
$this->assertEquals([0 => '01', 1 => '10'], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->whereMonthBetween('created_at', [Month::January, Month::October]);
$this->assertSame('select * from "users" where month("created_at") between ? and ?', $builder->toSql());
$this->assertEquals([0 => '01', 1 => '10'], $builder->getBindings());

$builder = $this->getBuilder();
$builder->select('*')->from('users')->whereMonthBetween('created_at', [['1'], ['10', '12']]);
$this->assertSame('select * from "users" where month("created_at") between ? and ?', $builder->toSql());
Expand Down Expand Up @@ -1439,6 +1433,18 @@ public function testWhereMonthBetween()
$this->assertEquals([0 => now()->format('m'), 1 => now()->format('m')], $builder->getBindings());
}

public function testWhereMonthBetweenAcceptsMonthEnum()
{
if (! class_exists(\Carbon\Month::class)) {
$this->markTestSkipped('Carbon 3.0 is not installed.');
}

$builder = $this->getBuilder();
$builder->select('*')->from('users')->whereMonthBetween('created_at', [\Carbon\Month::January, \Carbon\Month::October]);
$this->assertSame('select * from "users" where month("created_at") between ? and ?', $builder->toSql());
$this->assertEquals([0 => '01', 1 => '10'], $builder->getBindings());
}

public function testWhereDayBetween()
{
$builder = $this->getBuilder();
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Database/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public function testWhereMonthBetween()
$this->assertSame(1, DB::table('posts')->whereMonthBetween('created_at', [1, 3])->count());
}

public function testWhereMonthBetweenUsinCarbon()
public function testWhereMonthBetweenUsingCarbon()
{
if (! class_exists(\Carbon\Month::class)) {
$this->markTestSkipped('Carbon 3.0 is not installed.');
Expand Down

0 comments on commit ec742da

Please sign in to comment.