Skip to content

Commit

Permalink
Add test to make sure it's impossible pass DateTimeImmutable object
Browse files Browse the repository at this point in the history
  • Loading branch information
mnabialek committed May 21, 2020
1 parent 3965d77 commit dc591ea
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Objects/SqlQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ public function it_returns_valid_query_with_replaced_bindings()
$this->assertSame($expectedSql, $query->get());
}

/** @test */
public function it_returns_valid_query_with_replaced_bindings_for_immutable_date()
{
$sql = <<<EOF
SELECT * FROM tests WHERE a = ? AND CONCAT(?, '%'
, ?) = ? AND column = ?
EOF;

$bindings = ["'test", Carbon::yesterday(), new \DateTimeImmutable('tomorrow'), 453, 67.23];
$query = new SqlQuery(56, $sql, $bindings, 130);

$expectedSql = <<<EOF
SELECT * FROM tests WHERE a = '\'test' AND CONCAT('{$bindings[1]->toDateTimeString()}', '%'
, '{$bindings[2]->format('Y-m-d H:i:s')}') = 453 AND column = 67.23
EOF;

$this->assertSame($expectedSql, $query->get());
}

/** @test */
public function it_returns_valid_query_when_question_mark_in_quotes()
{
Expand Down

0 comments on commit dc591ea

Please sign in to comment.