Skip to content

Commit 393181b

Browse files
committed
test: add test to pass Stringable to $db->escape()
1 parent 2c524fd commit 393181b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/system/Database/Live/EscapeTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace CodeIgniter\Database\Live;
1515

1616
use CodeIgniter\Database\RawSql;
17+
use CodeIgniter\I18n\Time;
1718
use CodeIgniter\Test\CIUnitTestCase;
1819
use CodeIgniter\Test\DatabaseTestTrait;
1920

@@ -54,6 +55,14 @@ public function testEscape(): void
5455
$this->assertSame($expected, $sql);
5556
}
5657

58+
public function testEscapeStringable(): void
59+
{
60+
$expected = "SELECT * FROM brands WHERE name = '2024-01-01 12:00:00'";
61+
$sql = 'SELECT * FROM brands WHERE name = ' . $this->db->escape(new Time('2024-01-01 12:00:00'));
62+
63+
$this->assertSame($expected, $sql);
64+
}
65+
5766
public function testEscapeString(): void
5867
{
5968
$expected = "SELECT * FROM brands WHERE name = 'O" . $this->char . "'Doules'";

0 commit comments

Comments
 (0)