diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-10-19 13:18:57 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-10-19 13:18:57 +0200 |
commit | 1c9929d44f9d826493de7222ad42ff220cfd0cab (patch) | |
tree | 2a903e1cd76ed7d4d28dd10f15c2c2be9d930e79 /tests/lib/db.php | |
parent | 03ff614265da769cfef8ce62a535004e4346d3f0 (diff) | |
download | nextcloud-server-1c9929d44f9d826493de7222ad42ff220cfd0cab.tar.gz nextcloud-server-1c9929d44f9d826493de7222ad42ff220cfd0cab.zip |
Added unit tests for OC_DB::insertIfNotExist()
Diffstat (limited to 'tests/lib/db.php')
-rw-r--r-- | tests/lib/db.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php index 2344f7d8ec4..5d30f6ac46c 100644 --- a/tests/lib/db.php +++ b/tests/lib/db.php @@ -24,6 +24,7 @@ class Test_DB extends UnitTestCase { $this->test_prefix = $r; $this->table1 = $this->test_prefix.'contacts_addressbooks'; $this->table2 = $this->test_prefix.'contacts_cards'; + $this->table3 = $this->test_prefix.'vcategory'; } public function tearDown() { @@ -67,4 +68,29 @@ class Test_DB extends UnitTestCase { $result = $query->execute(array('uri_3')); $this->assertTrue($result); } + + public function testinsertIfNotExist() { + $categoryentries = array( + array('user' => 'test', 'type' => 'contact', 'category' => 'Family'), + array('user' => 'test', 'type' => 'contact', 'category' => 'Friends'), + array('user' => 'test', 'type' => 'contact', 'category' => 'Coworkers'), + array('user' => 'test', 'type' => 'contact', 'category' => 'Coworkers'), + array('user' => 'test', 'type' => 'contact', 'category' => 'School'), + ); + + foreach($categoryentries as $entry) { + $result = OC_DB::insertIfNotExist('*PREFIX*'.$this->table3, + array( + 'uid' => $entry['user'], + 'type' => $entry['type'], + 'category' => $entry['category'], + )); + $this->assertTrue($result); + } + + $query = OC_DB::prepare('SELECT * FROM *PREFIX*'.$this->table3); + $result = $query->execute(); + $this->assertTrue($result); + $this->assertEqual($result->numRows(), '4'); + } } |