Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_folder.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * @author Anakeen
8  * @package Dcp\Pu
9  */
10 
11 namespace Dcp\Pu;
12 
13 require_once 'PU_testcase_dcp_commonfamily.php';
14 
16 {
17  /**
18  * import some documents
19  * @static
20  * @return string
21  */
22  protected static function getCommonImportFile()
23  {
24  return "PU_data_dcp_somebasicdoc.ods";
25  }
26  /**
27  * @dataProvider provider
28  */
29  public function testAlive($a)
30  {
31  $d = new_doc(self::$dbaccess, $a);
32  $this->assertTrue($d->isAlive() , sprintf("document %d not alive", $a));
33  return $d;
34  }
35  /**
36  * test ba_desc attribute set
37  * @dataProvider folderProvider
38  * @---depends testAlive
39  */
40  public function testSetbadesc($a)
41  {
42  $d = new_doc(self::$dbaccess, $a, true);
43  if ($d->isAlive()) {
44  $val = "testing " . time();
45  $err = $d->setValue("ba_desc", $val);
46  $this->assertEquals("", $err, sprintf("cannot object update", $a));
47  $this->assertEquals($val, $d->getRawValue("ba_desc") , sprintf("document not updated", $a));
48  $err = $d->modify();
49  $this->assertEquals("", $err, sprintf("cannot database update", $a));
50 
51  $sval = $this->_DBGetValue(sprintf("select ba_desc from doc2 where id=%d", $d->id));
52  $this->assertEquals($val, $sval, sprintf("document %d not locked", $a));
53  } else {
54  $this->markTestIncomplete(sprintf(_('Document %d not alive.') , $a));
55  }
56  }
57  /**
58  * @dataProvider searchProvider
59  * @---depends testAlive
60  */
61  public function testnotSetbadesc($a)
62  {
63  $d = new_doc(self::$dbaccess, $a, true);
64  if ($d->isAlive()) {
65  $val = "testing " . time();
66  $err = $d->setValue("ba_desc", $val);
67  $this->assertFalse($err == "", sprintf(_("cannot object update %s") , $a));
68  } else {
69  $this->markTestIncomplete(sprintf(_('Document %d not alive.') , $a));
70  }
71  }
72  /**
73  * insert $b in $a
74  * @dataProvider twoFolderProvider
75  * @---depends testAlive
76  */
77  public function testAddFile($a, $b)
78  {
79  /**
80  * @var \Dir $da
81  */
82  $da = new_doc(self::$dbaccess, $a, true);
83  $db = new_doc(self::$dbaccess, $b, true);
84  if ($da->isAlive() && $db->isAlive()) {
85 
86  $err = $da->insertDocument($db->initid);
87  if ($err == "") {
88  $this->assertEquals("", $err, sprintf(_("error ::addFile %s %s") , $a, $err));
89  $sval = $this->_DBGetValue(sprintf("select childid from fld where dirid=%d and childid=%d", $da->initid, $db->initid));
90 
91  $this->assertEquals($db->initid, $sval, sprintf("not inserted %s", $a));
92  } else {
93  $this->markTestIncomplete(sprintf(_('Cannot insert : %s.') , $err));
94  }
95  } else {
96  $this->markTestIncomplete(sprintf(_('Document %d not alive.') , $a));
97  }
98  }
99  /**
100  * move $c from $a to $b
101  * @dataProvider threeFolderProvider
102  * @---depends testAlive
103  */
104  public function testMoveDocument($a, $b, $c)
105  {
106  /**
107  * @var \Dir $da
108  */
109  $da = new_doc(self::$dbaccess, $a, true);
110  $db = new_doc(self::$dbaccess, $b, true);
111  $dc = new_doc(self::$dbaccess, $c, true);
112 
113  if ($da->isAlive() && $db->isAlive() && $dc->isAlive()) {
114  $sval = $this->_DBGetValue(sprintf("select childid from fld where dirid=%d and childid=%d", $da->initid, $dc->initid));
115  //$err=simpleQuery(self::$dbaccess,sprintf("select childid from fld where dirid=%d and childid=%d",$da->initid,$dc->initid),$sval,true,true);
116  //$this->assertEquals("",$err,sprintf("database select error",$a));
117  if ($dc->initid != $sval) {
118  $this->markTestSkipped(sprintf(_("not present %s in %s") , $c, $a));
119  }
120  $this->assertEquals($dc->initid, $sval, sprintf("not present %s in %s", $c, $a));
121  $err = $da->moveDocument($dc->initid, $db->initid);
122  if ($err == "") {
123  $this->assertEquals("", $err, sprintf(_("error ::moveDocument %s %s") , $a, $err));
124  $sval = $this->_DBGetValue(sprintf("select childid from fld where dirid=%d and childid=%d", $da->initid, $dc->initid));
125  $this->assertFalse($sval, sprintf("not unlinked %s", $a));
126  $sval = $this->_DBGetValue(sprintf("select childid from fld where dirid=%d and childid=%d", $db->initid, $dc->initid));
127  $this->assertEquals($dc->initid, $sval, sprintf("not inserted %s", $a));
128  $sval = $this->_DBGetValue(sprintf("select prelid from docread where initid=%d and locked != -1", $dc->initid));
129  $this->assertEquals($db->initid, $sval, sprintf("primary relation not updated %s", $c));
130  } else {
131  $this->markTestIncomplete(sprintf(_('Cannot move : %s.') , $err));
132  }
133  } else {
134  $this->markTestIncomplete(sprintf(_('One of these documents %s not alive.') , $a . "," . $b . ',' . $c));
135  }
136  }
137 
138  public function provider()
139  {
140  return array(
141  array(
142  'TST_FOLDER2'
143  ) ,
144  array(
145  'TST_FOLDER1'
146  ) ,
147  array(
148  11
149  ) ,
150  array(
151  12
152  )
153  );
154  }
155  public function folderProvider()
156  {
157  return array(
158  array(
159  'TST_FOLDER2'
160  ) ,
161  array(
162  'TST_FOLDER1'
163  )
164  );
165  }
166  public function searchProvider()
167  {
168  return array(
169  array(
170  11
171  ) ,
172  array(
173  12
174  ) ,
175  array(
176  13
177  )
178  );
179  }
180 
181  public function twoFolderProvider()
182  {
183  return array(
184  array(
185  'TST_FOLDER2',
186  'TST_FOLDER1'
187  ) ,
188  array(
189  'TST_FOLDER1',
190  'TST_FOLDER2'
191  )
192  );
193  }
194  public function threeFolderProvider()
195  {
196  return array(
197  array(
198  'TST_FOLDER1',
199  'TST_FOLDER2',
200  'TST_FOLDER3'
201  ) ,
202  array(
203  'TST_FOLDER2',
204  'TST_FOLDER6',
205  'TST_FOLDER4'
206  ) ,
207  array(
208  'TST_FOLDER4',
209  'TST_FOLDER5',
210  'TST_FOLDER5'
211  )
212  );
213  }
214 }
215 ?>
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
$d
Definition: dav.php:77
$db
Definition: updateclass.php:48
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen