Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
PU_test_dcp_editcontrol.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 namespace Dcp\Pu;
8 /**
9  * @author Anakeen
10  * @package Dcp\Pu
11  */
12 
13 require_once 'PU_testcase_dcp_commonfamily.php';
14 
16 {
17  protected static function getCommonImportFile()
18  {
19  return array(
20  "PU_data_dcp_editcontrol.ods"
21  );
22  }
23  /**
24  * Test withoutControl=true is retained after revise/modify
25  *
26  * @param $data
27  * @throws \Dcp\Exception
28  *
29  * @dataProvider dataEditControlAfterReviseModify
30  */
32  {
33  $this->sudo($data['login']);
34  $doc = new_doc(self::$dbaccess, $data['doc']);
35  $doc->disableEditControl();
36  $err = $doc->revise();
37  $this->assertEmpty($err, sprintf("revise() returned an unexpected error on document '%s' with user '%s': %s", $data['doc'], $data['login'], $err));
38  $err = $doc->modify();
39  $this->assertEmpty($err, sprintf("modify() returned an unexpected error on document '%s' with user '%s': %s", $data['doc'], $data['login'], $err));
40  $this->exitSudo();
41  }
42 
44  {
45  return array(
46  array(
47  array(
48  'login' => 'u_editcontrol',
49  'doc' => 'TST_EDITCONTROL_1'
50  )
51  )
52  );
53  }
54  /**
55  * Test revise() is forbidden without disableEditControl()
56  *
57  * @param $data
58  *
59  * @dataProvider dataRevise
60  */
61  public function testRevise($data)
62  {
63  $this->sudo($data['login']);
64  $doc = new_doc(self::$dbaccess, $data['doc']);
65  $docId = $doc->id;
66  $err = $doc->revise();
67  $revs = $this->_revs($docId);
68  $this->assertNotEmpty($err, sprintf("revise() did not returned an error on document '%s' with user '%s'.", $data['doc'], $data['login']));
69  $this->assertTrue((count($revs) <= 0) , sprintf("Document '%s' has been revised in database: %s", $data['doc'], var_export($revs, true)));
70  $this->exitSudo();
71  }
72 
73  public function dataRevise()
74  {
75  return array(
76  array(
77  array(
78  'login' => 'u_editcontrol',
79  'doc' => 'TST_EDITCONTROL_1'
80  )
81  )
82  );
83  }
84 
85  public function _revs($docId)
86  {
87  $q = sprintf("SELECT revs.id FROM doc, doc AS revs WHERE doc.id = '%s' AND doc.initid = revs.initid AND revs.id > doc.id ORDER BY revs.id", pg_escape_string($docId));
89  return $res;
90  }
91 }
static sudo($login)
$dbaccess
Definition: checkVault.php:17
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
if($file) if($subject==""&&$file) if($subject=="") $err
$data
← centre documentaire © anakeen