13 require_once
'PU_testcase_dcp_commonfamily.php';
25 "PU_data_dcp_somebasicdoc.ods",
26 "PU_data_dcp_fileattr.ods"
37 $this->assertTrue(
$d->isAlive() , sprintf(
"document %s not alive",
$a));
66 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$d->id));
67 $slock = intval($slock);
68 $this->assertEquals(
$d->userid, $slock, sprintf(
"document %d not locked",
$a));
70 $this->markTestIncomplete(sprintf(_(
'Document %d is locked.') ,
$a));
73 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
85 if (
$d->canUnLock()) {
87 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$d->id));
88 $slock = intval($slock);
89 $this->assertEquals(0, $slock, sprintf(
"document %d still locked",
$a));
91 $this->markTestIncomplete(sprintf(_(
'Document %d is locked.') ,
$a));
94 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
110 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$d->id));
111 $slock = intval($slock);
112 if (
$d->userid == 1) {
115 }
else $this->assertEquals(-(
$d->userid) , ($slock) , sprintf(
"document %d not locked",
$a));
117 $this->markTestIncomplete(sprintf(_(
'Document %d is locked.') ,
$a));
120 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
133 $this->markTestIncomplete(sprintf(_(
'Document %s exists.') , $name));
138 $this->assertFalse(
$nd, sprintf(
"cannot create document BASE"));
141 $this->assertEmpty(
$err, sprintf(
"error when create document BASE : %s",
$err));
142 $this->assertTrue((
$nd->id > 0) , sprintf(
"no id when create document BASE"));
144 $err =
$nd->setLogicalName($name);
145 $this->assertEmpty(
$err, sprintf(
"cannot set name %s : %s", $name,
$err));
148 $this->assertEmpty(
$err, sprintf(
"error when delete document BASE : %s",
$err));
149 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$nd->id));
150 $this->assertEquals(-1, $slock, sprintf(
"document %s not locked fix", $name));
151 $sdoctype = $this->
_DBGetValue(sprintf(
"select doctype from docread where id=%d",
$nd->id));
152 $this->assertEquals(
'Z', $sdoctype, sprintf(
"document %s not deleted fix", $name));
155 $this->assertEmpty(
$err, sprintf(
"error when undelete document BASE : %s",
$err));
156 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$nd->id));
157 $this->assertGreaterThan(-1, $slock, sprintf(
"document %s locked fix", $name));
158 $sdoctype = $this->
_DBGetValue(sprintf(
"select doctype from docread where id=%d",
$nd->id));
159 $this->assertNotEquals(
'Z', $sdoctype, sprintf(
"document %s not revived fix", $name));
160 $sname = $this->
_DBGetValue(sprintf(
"select name from docread where id=%d",
$nd->id));
161 $this->assertEquals($name, $sname, sprintf(
"document %s not restore its name fix", $name));
165 $this->assertEmpty(
$err, sprintf(
"error when delete document BASE(1) : %s",
$err));
170 $this->assertEmpty(
$err, sprintf(
"error when create document BASE(2) : %s",
$err));
171 $err = $nd2->setLogicalName($name);
172 $this->assertEmpty(
$err, sprintf(
"cannot set name %s : %s", $name,
$err));
174 $this->assertEmpty(
$err, sprintf(
"error when undelete document BASE(1) : %s",
$err));
175 $sname = $this->
_DBGetValue(sprintf(
"select name from docread where id=%d",
$nd->id));
176 $this->assertEmpty($sname, sprintf(
"document %s name must be empty", $name));
189 $this->markTestIncomplete(sprintf(_(
'Document %s exists.') , $name));
193 if (!
$nd) $this->assertFalse(
$nd, sprintf(
"cannot create document BASE"));
195 $this->assertEmpty(
$err, sprintf(
"error when create document BASE : %s",
$err));
197 $this->assertTrue((
$nd->id > 0) , sprintf(
"no id when create document BASE"));
199 $err =
$nd->setLogicalName($name);
200 $this->assertEmpty(
$err, sprintf(
"cannot set name %s : %s", $name,
$err));
203 $this->assertEmpty(
$err, sprintf(
"error when delete document BASE : %s",
$err));
205 $sid = $this->
_DBGetValue(sprintf(
"select id from docread where id=%d",
$nd->id));
206 $this->assertFalse($sid, sprintf(
"document %s not really deleted (docread)",
$nd->id));
208 $sid = $this->
_DBGetValue(sprintf(
"select id from docname where name='%s'", $name));
209 $this->assertFalse($sid, sprintf(
"document %s not really deleted (docname)", $name));
211 $sid = $this->
_DBGetValue(sprintf(
"select id from docfrom where id='%s'",
$nd->id));
212 $this->assertFalse($sid, sprintf(
"document %s not really deleted (docfrom)",
$nd->id));
215 $this->assertNotEmpty(
$err, sprintf(
"error when undelete document BASE : %s",
$err));
225 public function testStoreFile($docId, $attrName, $filePathName, $fileName, $index = - 1)
228 $this->assertTrue(
$doc->isAlive() , sprintf(
"could not get document with id '%s'", $docId));
230 $err =
$doc->setFile($attrName, $filePathName, $fileName, $index);
231 $this->assertEmpty($err, sprintf(
"storeFile(%s, %s, %s, %s) returned with error: %s", $attrName, $filePathName, $fileName, $index, $err));
233 $value =
$doc->getMultipleRawValues($attrName,
'', $index);
234 $this->assertNotEmpty(
$value, sprintf(
"value of '%s' at index %s should not be empty", $attrName, $index));
244 public function testSaveFile($docId, $attrName, $filePathName, $fileName =
'', $index = - 1)
249 $fd = @fopen($filePathName,
'r');
250 $this->assertFalse(($fd ===
false) , sprintf(
"error openging file '%s': %s", $filePathName, isset($php_errormsg) ? $php_errormsg :
''));
253 $this->assertTrue(
$doc->isAlive() , sprintf(
"could not get document with id '%s'", $docId));
255 $err =
$doc->saveFile($attrName, $fd, $fileName, $index);
256 $this->assertEmpty($err, sprintf(
"saveFile(%s, %s, %s, %s) returned with error: %s", $attrName, $filePathName, $fileName, $index, $err));
258 $value =
$doc->getMultipleRawValues($attrName,
'', $index);
259 $this->assertNotEmpty(
$value, sprintf(
"value of '%s' at index %s should not be empty", $attrName, $index));
269 public function testSetFile($docId, $attrName, $filePathName, $fileName, $index = - 1)
272 $this->assertTrue(
$doc->isAlive() , sprintf(
"could not get document with id '%s'", $docId));
274 $err =
$doc->setFile($attrName, $filePathName, $fileName, $index);
275 $this->assertEmpty($err, sprintf(
"setFile(%s, %s, %s, %s) returned with error: %s", $attrName, $filePathName, $fileName, $index, $err));
277 $value =
$doc->getMultipleRawValues($attrName,
'', $index);
278 $this->assertNotEmpty(
$value, sprintf(
"value of '%s' at index %s should not be empty", $attrName, $index));
288 public function testVaultRegisterFile($docId,
$filename, $ftitle, $expectedFileName, $expectSuccess)
291 $this->assertTrue(
$doc->isAlive() , sprintf(
"could not get document with id '%s'", $docId));
303 $exception = $e->getMessage();
305 if ($expectSuccess) {
306 $this->assertEmpty($exception, sprintf(
"vaultRegisterFile thrown exception for file '%s': %s",
$filename, $exception));
307 $ret = preg_match(
'/^.*|\d+|.*$/', $vid);
308 $this->assertTrue(((
$ret !==
false) && (
$ret > 0)) , sprintf(
"vaultRegisterFile returned a malformed VID '%s' for file '%s'", $vid,
$filename));
309 $this->assertTrue(($expectedFileName ==
$info->name) , sprintf(
"Stored file name '%s' does not match expected file name '%s'.",
$info->name, $expectedFileName));
311 $this->assertNotEmpty($exception, sprintf(
"vaultRegisterFile did not thrown expected exception for file '%s'",
$filename));
353 "PU_data_dcp_logicalname.xml",
367 "DCPTEST/Layout/tst_file.odt",
368 "tst_file_single_file.odt",
374 "DCPTEST/Layout/tst_file.odt",
375 "tst_file_array_file.odt",
381 "DCPTEST/Layout/tst_file.odt",
382 "tst_file_multiple_file.odt",
393 "DCPTEST/Layout/tst_file.odt",
394 "tst_file_single_file.odt",
400 "DCPTEST/Layout/tst_file.odt",
401 "tst_file_array_file.odt",
407 "DCPTEST/Layout/tst_file.odt",
408 "tst_file_multiple_file.odt",
419 "DCPTEST/Layout/tst_file.odt",
420 "tst_file_single_file.odt",
426 "DCPTEST/Layout/tst_file.odt",
427 "tst_file_array_file.odt",
433 "DCPTEST/Layout/tst_file.odt",
434 "tst_file_multiple_file.odt",
443 "TST_VAULTREGISTERFILE_1",
444 "DCPTEST/Layout/tst_file.odt",
450 "TST_VAULTREGISTERFILE_1",
451 "DCPTEST/Layout/tst_file.odt",
457 "TST_VAULTREGISTERFILE_1",
458 "DCPTEST/Layout/this_file_does_not_exists.odt",
static getCommonImportFile()
testReallyDelete($name, $familyName)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
testStoreFile($docId, $attrName, $filePathName, $fileName, $index=-1)
Exception class use exceptionCode to identifiy correctly exception.
static importDocument($file)
testSetFile($docId, $attrName, $filePathName, $fileName, $index=-1)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
testLogicalName($file, array $ln)
if($file) if($subject==""&&$file) if($subject=="") $err
testDelete($name, $familyName)