13 require_once
'PU_testcase_dcp_document.php';
29 parent::setUpBeforeClass();
31 self::$outputDir = (
getTmpDir() .
"/oootest");
32 if (!is_dir(self::$outputDir)) mkdir(self::$outputDir);
34 self::beginTransaction();
36 self::importDocument(
"PU_data_dcp_oooSimpleLayout.ods");
37 self::importDocument(
"PU_data_dcp_oooSimpleLayout.xml");
40 self::assertTrue($img->isAlive() ,
"no found reference image");
43 self::assertTrue($htmlImage->isAlive() ,
"no found reference html");
44 $imgInfo = $img->getFileInfo($img->getRawValue(
"img_file"));
45 $htmlImage->setValue(
"tst_html", str_replace(
"1234567", $imgInfo[
"id_file"], $htmlImage->getRawValue(
"tst_html")));
51 self::rollbackTransaction();
57 copy(
$file, self::$outputDir .
'/' . $name);
60 protected function extractFile($docName, $template, $extractName)
63 $this->assertTrue(
$doc->isAlive() , sprintf(
"document %s is not alive", $docName));
65 $file =
$doc->viewDoc(
"DCPTEST:" . $template .
":B");
66 $this->assertTrue(file_exists($file) ,
"fail layout $template");
68 $copyFileName = sprintf(
"%s_%s.odt", str_replace(
'.odt',
'', $template) , $docName);
71 $cmd = sprintf(
'cd %s;rm -f %s;unzip -q %s %s', self::$outputDir, $extractName, $copyFileName, $extractName);
74 $this->assertEquals(0,
$status);
75 $extractFile = sprintf(
'%s/%s', self::$outputDir, $extractName);
79 protected function XPathTesting(\DOMDocument $dom, array $expectedValues)
82 $xp = new \DOMXpath($dom);
83 foreach ($expectedValues as $pathValue) {
85 $entries = $xp->query(
$path);
87 $foundValues = array();
88 foreach ($entries as $entry) {
89 if ($entry->nodeValue ==
$value) $found++;
90 $foundValues[] = $entry->nodeValue;
93 $this->assertGreaterThan(0, $found, sprintf(
"Item \"%s\" not found in %s path, found \n\t%s\n", print_r(
$value,
true) ,
$path, implode(
"\n\t", $foundValues)));
102 public function testContent($docName, $template, array $expectedValues)
105 $contentFile = $this->
extractFile($docName, $template,
'content.xml');
106 $dom = new \DOMDocument();
107 $dom->load($contentFile);
116 public function testMeta($docName, $template, array $expectedValues)
119 $metaFile = $this->
extractFile($docName, $template,
'meta.xml');
120 $dom = new \DOMDocument();
121 $dom->load($metaFile);
130 "PU_dcp_data_simple1.odt",
133 "office:meta//dc:title",
137 "office:meta//meta:keyword",
144 "PU_dcp_data_simple1.odt",
147 "office:meta//dc:title",
151 "office:meta//meta:keyword",
164 "PU_dcp_data_simple1.odt",
167 "office:body/office:text/text:p/text:span",
171 "office:body/office:text/text:p/text:span",
175 "office:body/office:text/text:p/text:span",
179 "office:body/office:text/text:section//text:span",
183 "office:body/office:text/text:section//text:span[@text:style-name='Tbold']",
190 "PU_dcp_data_simple1.odt",
193 "office:body/office:text/text:p/text:span",
197 "office:body/office:text/text:p/text:span",
201 "office:body/office:text/text:p/text:span",
205 "office:body/office:text/text:section//text:span",
209 "office:body/office:text/text:section//text:span[@text:style-name='Titalics']",
213 "office:body//table:table/table:table-row[1]/table:table-cell[1]//text:p/text:span",
217 "office:body//table:table/table:table-row[1]/table:table-cell[2]//text:p/text:span",
221 "office:body//table:table/table:table-row[2]/table:table-cell[1]//text:section/text:p/text:span[@text:style-name='Tbold']",
225 "office:body//table:table/table:table-row[3]/table:table-cell[1]//text:section/text:p/text:span[@text:style-name='Titalics']",
229 "office:body//table:table/table:table-row[4]/table:table-cell[1]//text:section/text:p/text:span[@text:style-name='Punderline']",
233 "office:body//table:table/table:table-row[5]/table:table-cell[1]//text:section/text:p/text:span[@text:style-name='Tbold']",
237 "office:body//table:table/table:table-row[5]/table:table-cell[1]//text:section/text:p/text:span[@text:style-name='Titalics']",
241 "office:body//table:table/table:table-row[5]/table:table-cell[1]//text:section/text:p/text:span[@text:style-name='Punderline']",
245 "office:body//table:table/table:table-row[2]/table:table-cell[2]//text:p/text:span",
249 "office:body//table:table/table:table-row[3]/table:table-cell[2]//text:p/text:span",
253 "office:body//table:table/table:table-row[4]/table:table-cell[2]//text:p/text:span",
257 "office:body//table:table/table:table-row[5]/table:table-cell[2]//text:p/text:span",
264 "PU_dcp_data_simple1.odt",
267 "office:body/office:text/text:p/text:span",
271 "office:body/office:text/text:p/text:span",
275 "office:body/office:text/text:p/text:span",
279 "office:body/office:text/text:section//text:span",
283 "office:body/office:text/text:section//text:span[@text:style-name='Tbold']",
290 "PU_dcp_data_simple1.odt",
293 "office:body//table:table/table:table-row[1]/table:table-cell[1]//text:p/text:span",
297 "office:body//table:table/table:table-row[2]/table:table-cell[1]//text:section/text:p",
298 "C'est un test <<\"hivers\" & \"été\">>"
304 "PU_dcp_data_simple1.odt",
307 "office:body/office:text/text:section/text:p",
311 "office:body/office:text/text:section/text:p/draw:frame[@draw:name='htmlgraphic']",
315 "office:body/office:text/text:section/text:p/draw:frame[@svg:width='20mm']",
319 "office:body/office:text/text:section/text:p/draw:frame[@svg:height='30mm']",
323 "office:body/office:text/text:section/text:p/draw:frame[@draw:name='htmlgraphic']/draw:image[contains(@xlink:href,'Pictures/dcp')]",
330 "PU_dcp_data_simple1.odt",
333 "office:body/office:text/text:section/text:p",
337 "office:body/office:text/text:section/text:p/draw:frame[@draw:name='htmlgraphic']",
341 "office:body/office:text/text:section/text:p/draw:frame[@svg:width='48mm']",
345 "office:body/office:text/text:section/text:p/draw:frame[@svg:height='35mm']",
349 "office:body/office:text/text:section/text:p/draw:frame[@draw:name='htmlgraphic']/draw:image[contains(@xlink:href,'Pictures/dcp')]",
356 "PU_dcp_data_simple1.odt",
360 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell/text:p/draw:frame[@draw:name='htmlgraphic']",
364 "office:body/office:text/text:section//table:table[1]/table:table-row[2]//table:table-cell/text:p/draw:frame[@draw:name='htmlgraphic']",
368 "office:body/office:text/text:section/table:table[1]/table:table-row[1]//table:table-cell/text:p/text:span[@text:style-name='Tbold']",
375 "PU_dcp_data_simple1.odt",
379 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell[1]/text:p/text:span[@text:style-name='Tbold']",
383 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell[2]/text:p/text:span[@text:style-name='Tbold']",
387 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell[1]/text:p/text:span[@text:style-name='Titalics']",
391 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell[2]/text:p/text:span[@text:style-name='Titalics']",
395 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell[3]/text:p",
396 "Single text 'voilà'"
399 "office:body/office:text/text:section//table:table[1]/table:table-row[2]//table:table-cell[1]/text:p",
403 "office:body/office:text/text:section//table:table[1]/table:table-row[2]//table:table-cell[2]/text:p/text:span[@text:style-name='Punderline']",
407 "office:body/office:text/text:section//table:table[1]/table:table-row[2]//table:table-cell[3]/text:p",
411 "office:body/office:text/text:section//table:table[1]/table:table-row[2]//table:table-cell[4]/text:p",
415 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[1]/text:p/text:span[@text:style-name='Tsub']",
419 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[1]/text:p/text:span[@text:style-name='Tbold']",
423 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[1]/text:p/text:span[@text:style-name='Titalics']",
427 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[2]/text:p/text:span[@text:style-name='Tsuper']",
431 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[3]/text:p/text:span[@text:style-name='Tsub']",
435 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[4]/text:p/text:span[@text:style-name='Tsub']",
439 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[4]/text:p/text:span[@text:style-name='Tsuper']",
443 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[2]/text:p",
447 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[3]/text:p",
451 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[4]/text:p",
455 "office:body/office:text/text:section//table:table[1]/table:table-row[3]//table:table-cell[1]/text:p",
456 "XDelta Très Gros et mince"
459 "office:body/office:text/text:section//table:table[1]/table:table-row[1]//table:table-cell[4]/text:p/text:a",
463 "office:body/office:text/text:section//table:table[1]//table:table-column[@table:number-columns-repeated='4']",
467 "office:body/office:text/text:section//table:table[1]/table:table-header-rows//table:table-cell[1]/text:p/text:span[@text:style-name='Tbold']",
471 "office:body/office:text/text:section//table:table[1]/table:table-header-rows//table:table-cell[2]/text:p/text:span[@text:style-name='Tbold']",
475 "office:body/office:text/text:section//table:table[1]/table:table-header-rows//table:table-cell[1]/text:p/text:span[@text:style-name='Titalics']",
479 "office:body/office:text/text:section//table:table[1]/table:table-header-rows//table:table-cell[2]/text:p/text:span[@text:style-name='Titalics']",
483 "office:body/office:text/text:section//table:table[1]/table:table-header-rows//table:table-cell[3]/text:p",
484 "Hingle text 'voilà'"
487 "office:body/office:text/text:section//table:table[1]/table:table-header-rows//table:table-cell[4]/text:p/text:a",
testContent($docName, $template, array $expectedValues)
extractFile($docName, $template, $extractName)
saveFileResult($file, $name)
foreach($argv as $arg) $cmd
testMeta($docName, $template, array $expectedValues)
static tearDownAfterClass()
static setUpBeforeClass()
XPathTesting(\DOMDocument $dom, array $expectedValues)