Skip to content

Commit d7ad8ae

Browse files
committed
Adding tests
1 parent 52d3a32 commit d7ad8ae

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/system/Database/BaseQueryTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function testNamedBinds()
269269
/**
270270
* @see https://github.com/codeigniter4/CodeIgniter4/issues/3566
271271
*/
272-
public function testNamedBindsWithColonElseWhere()
272+
public function testNamedBindsWithColonElsewhere()
273273
{
274274
$query = new Query($this->db);
275275
$query->setQuery('SELECT `email`, @total:=(total+1) FROM `users` WHERE `id` = :id:', ['id' => 10]);
@@ -278,6 +278,30 @@ public function testNamedBindsWithColonElseWhere()
278278
$this->assertSame($sql, $query->getQuery());
279279
}
280280

281+
/**
282+
* @see https://github.com/codeigniter4/CodeIgniter4/pull/5138
283+
*/
284+
public function testNamedBindsWithBindMarkerElsewhere()
285+
{
286+
$query = new Query($this->db);
287+
$query->setQuery('SELECT * FROM posts WHERE id = :id: AND title = \'The default bind marker is "?"\'', ['id' => 10]);
288+
289+
$sql = 'SELECT * FROM posts WHERE id = 10 AND title = \'The default bind marker is "?"\'';
290+
$this->assertSame($sql, $query->getQuery());
291+
}
292+
293+
/**
294+
* @see https://github.com/codeigniter4/CodeIgniter4/pull/5138
295+
*/
296+
public function testSimpleBindsWithNamedBindPlaceholderElsewhere()
297+
{
298+
$query = new Query($this->db);
299+
$query->setQuery('SELECT * FROM posts WHERE id = ? AND title = \'A named bind placeholder looks like ":foobar:"\'', 10);
300+
301+
$sql = 'SELECT * FROM posts WHERE id = 10 AND title = \'A named bind placeholder looks like ":foobar:"\'';
302+
$this->assertSame($sql, $query->getQuery());
303+
}
304+
281305
/**
282306
* @group single
283307
*

0 commit comments

Comments
 (0)