diff options
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'; |