13 require_once
'PU_testcase_dcp.php';
24 "PU_data_dcp_exportfamily.ods",
25 "PU_data_dcp_exportrelation.ods",
26 "PU_data_dcp_exporttitlelimits.ods",
27 "PU_data_dcp_exportdocimagexml.ods"
33 private function getExportedSelectionDom()
43 foreach ($selNames as $name) {
45 if ($id) $config[
"selectionItems"][] = $id;
48 $s = new \Fdl_DocumentSelection($config);
50 $export = new \exportXmlFolder();
53 $export->useIdentificator(
false);
55 $this->dom = new \DOMDocument();
56 $this->dom->load(
$export->getOutputFile());
57 @unlink(
$export->getOutputFile());
60 catch(\Exception $e) {
61 print $e->getMessage();
71 private function getExportedSearchDom()
76 $export = new \exportXmlFolder();
79 $export->useIdentificator(
false);
82 $this->dom = new \DOMDocument();
83 $this->dom->load(
$export->getOutputFile());
84 @unlink(
$export->getOutputFile());
96 $dom = $this->getExportedSearchDom();
97 $this->domTestExportValue($dom, $docName, $attrName,
'name', $expectedValue);
105 $dom = $this->getExportedSelectionDom();
106 $this->domTestExportValue($dom, $docName, $attrName,
'name', $expectedValue);
114 $dom = $this->getExportedSearchDom();
115 $this->domTestExportValue($dom, $docName, $attrName,
'content', $expectedValue);
117 private function domTestExportValue(\DOMDocument $dom, $docName, $attrName, $domAttr, $expectedValue)
120 $docs = $dom->getElementsByTagName(
"tst_exportfam1");
125 foreach ($docs as
$doc) {
130 if ($doc->getAttribute(
'name') == $docName) {
136 $this->assertNotEmpty($xmldoc, sprintf(
"document %s not found in xml", $docName));
140 $attrs = $xmldoc->getElementsByTagName($attrName);
141 if (!is_array($expectedValue)) $expectedValue = array(
144 $this->assertEquals(count($expectedValue) , $attrs->length, sprintf(
"attribute %s not found in %s document", $attrName, $docName));
147 foreach ($attrs as $attr) {
151 if ($domAttr ==
'content') {
152 $value = $attr->nodeValue;
154 $value = $attr->getAttribute($domAttr);
156 $this->assertTrue($expectedValue[$ka] ===
$value, sprintf(
"incorrect value for attribute %s in %s document", $attrName, $docName));
165 if (file_exists(
"/.dockerenv")) {
166 $this->markTestSkipped(
"Detected incompatible Docker environment");
168 $export = new \exportXmlFolder();
169 $catchedMessage =
'';
172 $export->useIdentificator(
false);
173 $export->exportFromFolder($folderId);
174 $this->dom = new \DOMDocument();
175 $this->dom->load(
$export->getOutputFile());
176 @unlink(
$export->getOutputFile());
179 $catchedMessage = $e->getMessage();
181 $this->assertNotNull($this->dom->documentElement, sprintf(
"Invalid XML export for folder '%s': %s", $folderId, ($catchedMessage !=
'') ? $catchedMessage :
'<no-error-message>'));
193 include_once (
'FDL/exportfld.php');
194 include_once (
'Lib.FileDir.php');
197 $oImport->importDocuments(self::getAction() , $archiveFile,
false,
true);
199 if (
$err)
throw new \Dcp\Exception(
$err);
201 $folderId =
"TEXT_FOLDER_EXPORT_IMAGE_XML";
202 $famid =
"TST_EXPORT_IMAGE_XML";
203 $testFolder = uniqid(
getTmpDir() .
"/testexportimage");
204 $testExtractFolder = uniqid(
getTmpDir() .
"/testexportextractimage");
206 $testarchivefile = $testFolder .
"/xml";
207 if (
$type ==
"X") $testarchivefile.=
".zip";
208 else $testarchivefile.=
".xml";
215 $this->assertEmpty(
$err, sprintf(
"Unexpected error while extracting archive '%s': %s", $testarchivefile,
$err));
216 }
else $testExtractFolder = $testFolder;
219 exec(sprintf(
"cat %s/*.xml", escapeshellarg($testExtractFolder)) , $output);
220 foreach ($needles as $needle) {
222 foreach ($output as $line) {
223 if (stripos($line, $needle) !==
false) {
228 $this->assertTrue($found, sprintf(
"file %s not found in export archive", $needle));
237 "./DCPTEST/PU_dcp_data_exportxmlimage.zip",
239 "PU_data_dcp_exportdocimageexample.png",
240 "PU_data_dcp_exportdocimage.ods"
245 "./DCPTEST/PU_dcp_data_exportxmlimage.zip",
247 "PU_data_dcp_exportdocimageexample.png",
248 "PU_data_dcp_exportdocimage.ods"
271 "TST_OUTREL1,TST_OUTREL2,TST_OUTREL3"
287 "TST_OUTREL1,TST_OUTREL3",
288 "TST_OUTREL1,TST_OUTREL2,TST_OUTREL3"
324 "TST_EXPORTTITLELIMITS_DIR"
exportxmlfld(Action &$action, $aflid="0", $famid="", SearchDoc $specSearch=null, $outputFile= '', $eformat="", $wident= 'Y', Fdl_DocumentSelection $aSelection=null, $toDownload=true)
static getCommonImportFile()
testExportSimpleValue($docName, $attrName, $expectedValue)
testExportTitleLimits($folderId)
testExportImageXmlZip($archiveFile, $needles, $type)
extractTar($tar, $untardir, $mime="")
testExportSelectionRelation($docName, $attrName, $expectedValue)
getIdFromName($dbaccess, $name)
testExportRelation($docName, $attrName, $expectedValue)
if($file) if($subject==""&&$file) if($subject=="") $err