13 require_once
'PU_testcase_dcp_commonfamily.php';
25 "PU_data_dcp_docrel_family.ods"
28 private $base = array();
32 private function initBaseDocuments()
43 for ($i = 0; $i < 3; $i++) {
44 $bid = sprintf(
"%s%d", $L, $i);
45 $d->setValue(
"tst_title", $bid);
47 $this->base[$bid] =
$d->id;
48 if ($i < 2)
$d->revise();
53 $d->setLogicalName(
"TST_DOCREL_TITLE_CR");
54 $d->setTitle(
"xxx\rxxx");
58 $d->setLogicalName(
"TST_DOCREL_TITLE_LF");
59 $d->setTitle(
"xxx\nxxx");
63 $d->setLogicalName(
"TST_DOCREL_TITLE_TAB");
64 $d->setTitle(
"xxx\txxx");
68 $d->setLogicalName(
"TST_DOCREL_TITLE_BACKSLASH");
69 $d->setTitle(
"nnn\\nnn");
73 $d->setLogicalName(
"TST_DOCREL_TITLE_BACKSLASH_N");
82 private function translateName($val)
86 foreach ($val as $ka => $aVal) {
87 $tbs = explode(
"<BR>", $aVal);
89 foreach ($tbs as $single) {
90 if (isset($this->base[$single])) {
91 $tids[] = $this->base[$single];
97 $tb[] = implode(
'<BR>', $tids);
101 if (isset($this->base[$val])) {
102 return $this->base[$val];
113 $this->initBaseDocuments();
116 foreach ($initValues as $aid => $val) {
117 $err.=
$d->setValue($aid, $this->translateName($val));
120 $this->assertEmpty(
$err,
"add error $err");
121 foreach ($updateValues as $aid => $val) {
122 $err.=
$d->setValue($aid, $this->translateName($val));
125 $this->assertEmpty(
$err,
"update error $err");
127 $rel = new \DocRel();
128 $rel->sinitid =
$d->id;
129 $rels = $rel->getRelations();
131 $this->assertEquals(count($expectValues) , count($rels) , sprintf(
"Not correct relations %s", print_r($rels,
true)));
132 foreach ($expectValues as $expectProps) {
133 $aid = $expectProps[
"aid"];
134 $this->assertEquals($expectProps[
"title"], $this->getRelTitle($rels, $aid, $expectProps[
"title"]) , sprintf(
"not correct title $aid expect %s : %s", $expectProps[
"title"], print_r($rels,
true)));
135 $this->assertEquals($this->translateName($expectProps[
"id"]) , $this->getRelId($rels, $aid, $this->translateName($expectProps[
"id"])) ,
"not correct id $aid");
139 private function getRelTitle(array $rels, $key, $expect)
141 foreach ($rels as $rel) {
142 if ($rel[
"type"] == $key && $rel[
"ctitle"] == $expect)
return $rel[
"ctitle"];
147 private function getRelId(array $rels, $key, $expect)
149 foreach ($rels as $rel) {
150 if ($rel[
"type"] == $key && $rel[
"cinitid"] == $expect)
return $rel[
"cinitid"];
183 "update" => array() ,
198 "update" => array() ,
211 "aid" =>
"tst_rels3",
221 "tst_rels3" => array(
227 "update" => array() ,
240 "aid" =>
"tst_rels3",
248 "tst_rels3" => array(
254 "update" => array() ,
258 "aid" =>
"tst_rels3",
263 "aid" =>
"tst_rels3",
272 "tst_rels2" => array(
278 "update" => array() ,
282 "aid" =>
"tst_rels2",
287 "aid" =>
"tst_rels2",
292 "aid" =>
"tst_rels2",
301 "tst_rel1" =>
"TST_DOCREL_TITLE_CR"
303 "update" => array() ,
307 "id" =>
"TST_DOCREL_TITLE_CR",
315 "tst_rel1" =>
"TST_DOCREL_TITLE_LF"
317 "update" => array() ,
321 "id" =>
"TST_DOCREL_TITLE_LF",
329 "tst_rel1" =>
"TST_DOCREL_TITLE_TAB"
331 "update" => array() ,
335 "id" =>
"TST_DOCREL_TITLE_TAB",
343 "tst_rel1" =>
"TST_DOCREL_TITLE_BACKSLASH"
345 "update" => array() ,
349 "id" =>
"TST_DOCREL_TITLE_BACKSLASH",
350 "title" =>
"nnn\\nnn"
357 "tst_rel1" =>
"TST_DOCREL_TITLE_BACKSLASH_N"
359 "update" => array() ,
363 "id" =>
"TST_DOCREL_TITLE_BACKSLASH_N",
testDocRelUpdate($initValues, $updateValues, $expectValues)
static getCommonImportFile()
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err