diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-07-01 18:03:32 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-07-01 18:03:32 +0200 |
commit | b20018928d9500faba89d5f3af0fc483f866d4c7 (patch) | |
tree | f3aae974be82b1aec5a78462f70e793640134151 /tests | |
parent | 4161fd24083a5f12033805ff3d262b8a51780650 (diff) | |
download | nextcloud-server-b20018928d9500faba89d5f3af0fc483f866d4c7.tar.gz nextcloud-server-b20018928d9500faba89d5f3af0fc483f866d4c7.zip |
add unit test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/db.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/lib/db.php b/tests/lib/db.php index 2fca67b5638..5f65e88c3b0 100644 --- a/tests/lib/db.php +++ b/tests/lib/db.php @@ -125,6 +125,28 @@ class Test_DB extends PHPUnit_Framework_TestCase { $this->assertEquals(4, count($result->fetchAll())); } + public function testInsertIfNotExistNull() { + $categoryentries = array( + array('addressbookid' => 123, 'fullname' => null, 'expectedResult' => 1), + array('addressbookid' => 123, 'fullname' => null, 'expectedResult' => 0), + array('addressbookid' => 123, 'fullname' => 'test', 'expectedResult' => 1), + ); + + foreach($categoryentries as $entry) { + $result = OC_DB::insertIfNotExist('*PREFIX*'.$this->table2, + array( + 'addressbookid' => $entry['addressbookid'], + 'fullname' => $entry['fullname'], + )); + $this->assertEquals($entry['expectedResult'], $result); + } + + $query = OC_DB::prepare('SELECT * FROM `*PREFIX*'.$this->table2.'`'); + $result = $query->execute(); + $this->assertTrue((bool)$result); + $this->assertEquals(2, count($result->fetchAll())); + } + public function testinsertIfNotExistDontOverwrite() { $fullname = 'fullname test'; $uri = 'uri_1'; |