13 require_once
'PU_testcase_dcp_commonfamily.php';
24 "PU_data_dcp_invisible.ods"
36 $s->setObjectReturn();
37 $dl =
$s->search()->getDocumentList();
39 $fc = new \FormatCollection();
40 $fc->useCollection($dl);
41 $fc->relationNoAccessText =
'no grant';
42 $fc->addProperty($fc::propName);
43 foreach ($expectedValues as $aid =>
$value) {
44 $fc->addAttribute($aid);
48 foreach ($expectedValues as $aid =>
$value) {
49 $this->assertTrue($this->getRenderValue(
$r, $docName, $aid) !== null,
"$aid not found");
50 $this->assertEquals(
$value, $this->getRenderValue(
$r, $docName, $aid)->displayValue, sprintf(
"%s [%s]<>\n%s", $aid,
$value, print_r($this->getRenderValue(
$r, $docName, $aid) ,
true)));
61 $s->setObjectReturn();
62 $dl =
$s->search()->getDocumentList();
64 $fc = new \FormatCollection();
65 $fc->setVerifyAttributeAccess(
false);
66 $fc->useCollection($dl);
67 $fc->relationNoAccessText =
'no grant';
68 $fc->addProperty($fc::propName);
69 foreach ($expectedValues as $aid =>
$value) {
70 $fc->addAttribute($aid);
74 foreach ($expectedValues as $aid =>
$value) {
75 $this->assertTrue($this->getRenderValue(
$r, $docName, $aid) !== null,
"$aid not found");
76 $this->assertEquals(
$value, $this->getRenderValue(
$r, $docName, $aid)->displayValue, sprintf(
"%s [%s]<>\n%s", $aid,
$value, print_r($this->getRenderValue(
$r, $docName, $aid) ,
true)));
87 $outFile = tempnam(
getTmpDir() ,
'tstexport');
89 $s->setObjectReturn();
90 $dl =
$s->search()->getDocumentList();
92 $ec = new \Dcp\ExportCollection();
93 $ec->setVerifyAttributeAccess(
false);
94 $ec->setDocumentlist($dl);
97 $ec->setCvsEnclosure($enclosure);
98 $ec->setCvsSeparator($separator);
99 $ec->setOutputFilePath($outFile);
113 $outFile = tempnam(
getTmpDir() ,
'tstexport');
115 $s->setObjectReturn();
116 $dl =
$s->search()->getDocumentList();
118 $ec = new \Dcp\ExportCollection();
119 $ec->setVerifyAttributeAccess(
true);
120 $ec->setDocumentlist($dl);
123 $ec->setCvsEnclosure($enclosure);
124 $ec->setCvsSeparator($separator);
125 $ec->setOutputFilePath($outFile);
133 protected function verifyCsvContains($outFile, $separator, $enclosure, $expectedData, $columnId)
135 $results = fopen($outFile,
"r");
136 $resultData = array();
137 while ((
$data = fgetcsv($results, 1000, $separator, $enclosure)) !== FALSE) {
139 $docName =
$data[$columnId];
140 $resultData[$docName] =
$data;
143 foreach ($expectedData as $docName => $docValues) {
144 $this->assertTrue(isset($resultData[$docName]) , sprintf(
"%s document not found : %s", $docName, print_r($resultData,
true)));
145 foreach ($docValues as $index =>
$value) {
146 if (strpos(
$value,
"*") ===
false) {
147 $this->assertEquals(
$value, $resultData[$docName][$index], sprintf(
"%s (index %s) : %s \n %s", $docName, $index, print_r($resultData,
true) , $outFile));
149 $this->assertEquals(preg_match(
'/' .
$value .
'/', $resultData[$docName][$index]) , 1, sprintf(
"expected \"%s\" %s (index %s) : %s \n %s",
$value, $docName, $index, print_r($resultData,
true) , $outFile));
160 $outFile = tempnam(
getTmpDir() ,
'tstexport');
162 $s->setObjectReturn();
165 $this->assertEmpty(
$s->searchError() , sprintf(
"Error in search %s", print_r(
$s->getSearchInfo() ,
true)));
167 $ec = new \Dcp\ExportCollection();
169 $ec->setOutputFilePath($outFile);
171 $ec->setDocumentlist(
$s->getDocumentList());
172 $ec->setVerifyAttributeAccess(
true);
175 $this->assertTrue(filesize($outFile) > 0, sprintf(
"\"%s\" file not produced", $outFile));
177 $dom = new \DOMDocument();
178 $dom->load($outFile);
183 protected function XPathTesting(\DOMDocument $dom, array $expectedValues)
186 $xp = new \DOMXpath($dom);
188 $entries = $xp->query(
$path);
190 $foundValues = array();
192 foreach ($entries as $entry) {
193 if ($entry->nodeValue ==
$value) $found++;
194 $foundValues[] = $entry->nodeValue;
196 $this->assertGreaterThan(0, $found, sprintf(
"Item \"%s\" not found in %s path, found \n\t%s\n",
$value,
$path, implode(
"\n\t", $foundValues)));
205 private function getRenderValue(array
$r, $docName, $attrName)
207 foreach ($r as $format) {
208 if ($format[
"properties"][
"name"] == $docName) {
209 if ($format[
"attributes"][$attrName] === null) {
210 return new \StandardAttributeValue(
"", null);
212 return $format[
"attributes"][$attrName];
225 $this->famName .
'[@name = "TST_INVISIBLE_DOC1"]/tst_frame1/tst_number' =>
"1",
226 $this->famName .
'[@name = "TST_INVISIBLE_DOC1"]/tst_frame1/tst_text[@granted = "false"]' =>
"",
227 $this->famName .
'[@name = "TST_INVISIBLE_DOC1"]/tst_tab_i/tst_frame2/tst_decimal[@granted = "false"]' =>
"",
229 $this->famName .
'[@name = "TST_INVISIBLE_DOC2"]/tst_frame1/tst_number[@granted = "false"]' =>
"",
230 $this->famName .
'[@name = "TST_INVISIBLE_DOC2"]/tst_frame1/tst_text[@granted = "false"]' =>
"",
231 $this->famName .
'[@name = "TST_INVISIBLE_DOC2"]/tst_tab_i/tst_frame2/tst_decimal' =>
"2.2",
233 $this->famName .
'[@name = "TST_INVISIBLE_DOC3"]/tst_frame1/tst_number' =>
"3",
234 $this->famName .
'[@name = "TST_INVISIBLE_DOC3"]/tst_frame1/tst_text[@granted = "false"]' =>
"",
235 $this->famName .
'[@name = "TST_INVISIBLE_DOC3"]/tst_tab_i/tst_frame2/tst_decimal[@granted = "false"]' =>
"",
242 $this->famName .
'[@name = "TST_INVISIBLE_DOC3"]/tst_frame1/tst_number[@granted = "false"]' =>
"",
243 $this->famName .
'[@name = "TST_INVISIBLE_DOC3"]/tst_frame1/tst_text[@granted = "false"]' =>
"",
244 $this->famName .
'[@name = "TST_INVISIBLE_DOC3"]/tst_tab_i/tst_frame2/tst_decimal' =>
"3.3",
256 "TST_INVISIBLE_DOC1" => array(
266 "TST_INVISIBLE_DOC2" => array(
272 9 =>
"TST_INVISIBLE_DOC1"
274 "TST_INVISIBLE_DOC3" => array(
293 "TST_INVISIBLE_DOC1" => array(
300 "TST_INVISIBLE_DOC2" => array(
306 9 =>
"TST_INVISIBLE_DOC1"
308 "TST_INVISIBLE_DOC3" => array(
310 9 =>
"TST_INVISIBLE_DOC1\nTST_INVISIBLE_DOC2"
322 "TST_INVISIBLE_DOC1",
324 "tst_title" =>
"Titre 1",
334 "TST_INVISIBLE_DOC2",
336 "tst_title" =>
"Titre 2",
339 "tst_longtext" =>
"Deux long",
340 "tst_decimal" =>
"2,2"
345 "TST_INVISIBLE_DOC3",
347 "tst_title" =>
"Titre 3",
356 "TST_INVISIBLE_DOC4",
358 "tst_title" =>
"Titre 4",
367 "TST_INVISIBLE_DOC5",
369 "tst_title" =>
"Titre 5",
378 "TST_INVISIBLE_DOC3",
380 "tst_title" =>
"Titre 3",
383 "tst_longtext" =>
"Trois long",
384 "tst_decimal" =>
"3,3"
389 "TST_INVISIBLE_DOC4",
391 "tst_title" =>
"Titre 4",
394 "tst_longtext" =>
"Quatre long",
395 "tst_decimal" =>
"4,4"
400 "TST_INVISIBLE_DOC3",
402 "tst_title" =>
"Titre 3",
411 "TST_INVISIBLE_DOC4",
413 "tst_title" =>
"Titre 4",
414 "tst_text" =>
"Quatre",
416 "tst_longtext" =>
"Quatre long",
417 "tst_decimal" =>
"4,4"
422 "TST_INVISIBLE_DOC3",
424 "tst_title" =>
"Titre 3",
433 "TST_INVISIBLE_DOC4",
435 "tst_title" =>
"Titre 4",
436 "tst_text" =>
"Quatre",
438 "tst_longtext" =>
"Quatre long",
439 "tst_decimal" =>
"4,4"
450 "TST_INVISIBLE_DOC1",
452 "tst_title" =>
"Titre 1",
455 "tst_longtext" =>
"Un long",
456 "tst_decimal" =>
"1,1"
461 "TST_INVISIBLE_DOC2",
463 "tst_title" =>
"Titre 2",
464 "tst_text" =>
"Deux",
466 "tst_longtext" =>
"Deux long",
467 "tst_decimal" =>
"2,2"
472 "TST_INVISIBLE_DOC3",
474 "tst_title" =>
"Titre 3",
475 "tst_text" =>
"Trois",
477 "tst_longtext" =>
"Trois long",
478 "tst_decimal" =>
"3,3"
483 "TST_INVISIBLE_DOC4",
485 "tst_title" =>
"Titre 4",
486 "tst_text" =>
"Quatre",
488 "tst_longtext" =>
"Quatre long",
489 "tst_decimal" =>
"4,4"
494 "TST_INVISIBLE_DOC5",
496 "tst_title" =>
"Titre 5",
497 "tst_text" =>
"Cinq",
499 "tst_longtext" =>
"Cinq long",
500 "tst_decimal" =>
"5,5"
505 "TST_INVISIBLE_DOC3",
507 "tst_title" =>
"Titre 3",
508 "tst_text" =>
"Trois",
510 "tst_longtext" =>
"Trois long",
511 "tst_decimal" =>
"3,3"
516 "TST_INVISIBLE_DOC4",
518 "tst_title" =>
"Titre 4",
519 "tst_text" =>
"Quatre",
521 "tst_longtext" =>
"Quatre long",
522 "tst_decimal" =>
"4,4"
527 "TST_INVISIBLE_DOC3",
529 "tst_title" =>
"Titre 3",
530 "tst_text" =>
"Trois",
532 "tst_longtext" =>
"Trois long",
533 "tst_decimal" =>
"3,3"
538 "TST_INVISIBLE_DOC4",
540 "tst_title" =>
"Titre 4",
541 "tst_text" =>
"Quatre",
543 "tst_longtext" =>
"Quatre long",
544 "tst_decimal" =>
"4,4"
549 "TST_INVISIBLE_DOC3",
551 "tst_title" =>
"Titre 3",
552 "tst_text" =>
"Trois",
554 "tst_longtext" =>
"Trois long",
555 "tst_decimal" =>
"3,3"
560 "TST_INVISIBLE_DOC4",
562 "tst_title" =>
"Titre 4",
563 "tst_text" =>
"Quatre",
565 "tst_longtext" =>
"Quatre long",
566 "tst_decimal" =>
"4,4"
const xmlFileOutputFormat