summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2014-09-19 12:07:56 +0200
committerRobin Appelman <robin@icewind.nl>2014-09-19 12:07:56 +0200
commit33f7af9207f941a2068023764188d7b7f29fb0f0 (patch)
treea98eab4c7548927011075e051fdab5d7e4674f65 /tests
parent786312d0e88b530319ffaf13d0b86a9efaff488a (diff)
parenta85f0ae2da4344826ee04f79bc362eb5d1a86f67 (diff)
downloadnextcloud-server-33f7af9207f941a2068023764188d7b7f29fb0f0.tar.gz
nextcloud-server-33f7af9207f941a2068023764188d7b7f29fb0f0.zip
Merge pull request #10958 from owncloud/db-ilike
Introduce cross-db ILIKE
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());
+ }
}