add unit test

This commit is contained in:
Jörn Friedrich Dreyer 2014-07-01 18:03:32 +02:00
parent 4161fd2408
commit b20018928d
1 changed files with 22 additions and 0 deletions

View File

@ -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';