13 require_once
'./PU_Framework_TestDocument.php';
22 $d = new_doc($this->dbaccess,
$a);
23 $this->assertTrue(
$d->isAlive() , sprintf(
"document %d not alive",
$a));
33 $d = new_doc($this->dbaccess,
$a,
true);
37 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$d->id));
38 $slock = intval($slock);
39 $this->assertEquals(
$d->userid, $slock, sprintf(
"document %d not locked",
$a));
41 $this->markTestIncomplete(sprintf(_(
'Document %d is locked.') ,
$a));
44 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
54 $d = new_doc($this->dbaccess,
$a,
true);
56 if (
$d->canUnLock()) {
58 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$d->id));
59 $slock = intval($slock);
60 $this->assertEquals(0, $slock, sprintf(
"document %d still locked",
$a));
62 $this->markTestIncomplete(sprintf(_(
'Document %d is locked.') ,
$a));
65 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
75 $d = new_doc($this->dbaccess,
$a,
true);
80 $slock = $this->
_DBGetValue(sprintf(
"select locked from docread where id=%d",
$d->id));
81 $slock = intval($slock);
82 if (
$d->userid == 1) $this->markTestIncomplete(sprintf(_(
'Admin cannot auto lock.')));
83 else $this->assertEquals(-(
$d->userid) , ($slock) , sprintf(
"document %d not locked",
$a));
85 $this->markTestIncomplete(sprintf(_(
'Document %d is locked.') ,
$a));
88 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
97 $d = new_doc($this->dbaccess,
$a,
true);
99 $val =
"testing " . time();
100 $err =
$d->setValue(
"ba_desc", $val);
101 $this->assertEquals(
"",
$err, sprintf(
"cannot object update",
$a));
102 $this->assertEquals($val,
$d->getValue(
"ba_desc") , sprintf(
"document not updated",
$a));
104 $this->assertEquals(
"", $err, sprintf(
"cannot database update",
$a));
106 $sval = $this->
_DBGetValue(sprintf(
"select ba_desc from doc2 where id=%d",
$d->id));
107 $this->assertEquals($val, $sval, sprintf(
"document %d not locked",
$a));
109 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
118 $d = new_doc($this->dbaccess,
$a,
true);
120 $val =
"testing " . time();
121 $err =
$d->setValue(
"ba_desc", $val);
122 $this->assertFalse(
$err ==
"", sprintf(_(
"cannot object update %s") ,
$a));
124 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
134 $da = new_doc($this->dbaccess,
$a,
true);
135 $db = new_doc($this->dbaccess, $b,
true);
136 if ($da->isAlive() &&
$db->isAlive()) {
138 $err = $da->addFile(
$db->initid);
140 $this->assertEquals(
"",
$err, sprintf(_(
"error ::addFile %s %s") ,
$a,
$err));
141 $sval = $this->
_DBGetValue(sprintf(
"select childid from fld where dirid=%d and childid=%d", $da->initid,
$db->initid));
143 $this->assertEquals(
$db->initid, $sval, sprintf(
"not inserted %s",
$a));
145 $this->markTestIncomplete(sprintf(_(
'Cannot insert : %s.') ,
$err));
148 $this->markTestIncomplete(sprintf(_(
'Document %d not alive.') ,
$a));
158 $da = new_doc($this->dbaccess,
$a,
true);
159 $db = new_doc($this->dbaccess, $b,
true);
160 $dc = new_doc($this->dbaccess,
$c,
true);
161 if ($da->isAlive() &&
$db->isAlive() && $dc->isAlive()) {
162 $sval = $this->
_DBGetValue(sprintf(
"select childid from fld where dirid=%d and childid=%d", $da->initid, $dc->initid));
165 if ($dc->initid != $sval) {
166 $this->markTestSkipped(sprintf(_(
"not present %s in %s") ,
$c,
$a));
168 $this->assertEquals($dc->initid, $sval, sprintf(
"not present %s in %s",
$c,
$a));
169 $err = $da->moveDocument($dc->initid,
$db->initid);
171 $this->assertEquals(
"",
$err, sprintf(_(
"error ::moveDocument %s %s") ,
$a,
$err));
172 $sval = $this->
_DBGetValue(sprintf(
"select childid from fld where dirid=%d and childid=%d", $da->initid, $dc->initid));
173 $this->assertFalse($sval, sprintf(
"not unlinked %s",
$a));
174 $sval = $this->
_DBGetValue(sprintf(
"select childid from fld where dirid=%d and childid=%d",
$db->initid, $dc->initid));
175 $this->assertEquals($dc->initid, $sval, sprintf(
"not inserted %s",
$a));
176 $sval = $this->
_DBGetValue(sprintf(
"select prelid from docread where initid=%d and locked != -1", $dc->initid));
177 $this->assertEquals(
$db->initid, $sval, sprintf(
"primary relation not updated %s",
$c));
179 $this->markTestIncomplete(sprintf(_(
'Cannot move : %s.') ,
$err));
182 $this->markTestIncomplete(sprintf(_(
'One of these documents %s not alive.') ,
$a .
"," . $b .
',' .
$c));