Explicitely testing escape_like_str API
diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php
index 5068592..fe22543 100644
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ b/tests/codeigniter/database/query_builder/escape_test.php
@@ -13,6 +13,9 @@
Mock_Database_Schema_Skeleton::create_tables();
Mock_Database_Schema_Skeleton::create_data();
+
+ $this->pre = (strpos(DB_DRIVER, 'pgsql') === FALSE) ? '`' : '"';
+ $this->esc = (strpos(DB_DRIVER, 'mysql') === FALSE) ? '!' : '';
}
// ------------------------------------------------------------------------
@@ -22,13 +25,12 @@
*/
public function test_escape_like_percent_sign()
{
- $string = '\%foo'
-;
- $this->db->select('value');
- $this->db->from('misc');
- $this->db->like('key', $string, 'after');
- $res = $this->db->get();
+ $string = $this->db->escape_like_str('\%foo');
+ $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';";
+
+ $res = $this->db->query($sql)->result_array();
+
// Check the result
$this->assertEquals(1, count($res->result_array()));
}
@@ -40,13 +42,12 @@
*/
public function test_escape_like_backslash_sign()
{
- $string = '\\';
+ $string = $this->db->escape_like_str('\\');
- $this->db->select('value');
- $this->db->from('misc');
- $this->db->like('key', $string, 'after');
- $res = $this->db->get();
+ $sql = "SELECT {$this->pre}value{$this->pre} FROM {$this->pre}misc{$this->pre} WHERE {$this->pre}key{$this->pre} LIKE '$string%' ESCAPE '$this->esc';";
+ $res = $this->db->query($sql)->result_array();
+
// Check the result
$this->assertEquals(2, count($res->result_array()));
}