summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php
index 1f62413cbe4..fb673b8092b 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -27,6 +27,11 @@ class Test_DB extends PHPUnit_Framework_TestCase {
*/
private $table3;
+ /**
+ * @var string
+ */
+ private $table4;
+
public function setUp() {
$dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml';
@@ -263,4 +268,54 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ? WHERE `fullname` = ?");
return $query->execute(array($uri, $fullname));
}
+
+ public function testILIKE() {
+ $table = "*PREFIX*{$this->table2}";
+
+ $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)");
+ $query->execute(array('fooBAR', 'foo', 'bar'));
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
+ $result = $query->execute(array('foobar'));
+ $this->assertCount(0, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
+ $result = $query->execute(array('foobar'));
+ $this->assertCount(1, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
+ $result = $query->execute(array('foo'));
+ $this->assertCount(0, $result->fetchAll());
+ }
+
+ public function testILIKEWildcard() {
+ $table = "*PREFIX*{$this->table2}";
+
+ $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)");
+ $query->execute(array('FooBAR', 'foo', 'bar'));
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
+ $result = $query->execute(array('%bar'));
+ $this->assertCount(0, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
+ $result = $query->execute(array('foo%'));
+ $this->assertCount(0, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
+ $result = $query->execute(array('%ba%'));
+ $this->assertCount(0, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
+ $result = $query->execute(array('%bar'));
+ $this->assertCount(1, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
+ $result = $query->execute(array('foo%'));
+ $this->assertCount(1, $result->fetchAll());
+
+ $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
+ $result = $query->execute(array('%ba%'));
+ $this->assertCount(1, $result->fetchAll());
+ }
}