14 require_once
'PU_testcase_dcp_commonfamily.php';
26 return "PU_data_dcp_gethtmlvaluefamily.ods";
35 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
36 foreach ($setValues as $attrid => $newValue) {
37 $d->setAttributeValue($attrid, $newValue);
40 foreach ($expectedValues as $attrid => $expectedValue) {
41 $oriValue =
$d->getrawValue($attrid);
42 $value =
$d->getHtmlAttrValue($attrid);
44 $this->assertTrue($expectedValue ===
$value, sprintf(
"wrong value \"%s\" : \n\texpected \"%s\", \n\thas \"%s\" \n\tRaw is :\"%s\"", $attrid, print_r($expectedValue,
true) , print_r(
$value,
true) , print_r($oriValue,
true)));
54 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document",
$data[
'docName']));
55 foreach (
$data[
'setValues'] as $attrid => $newValue) {
56 $d->setAttributeValue($attrid, $newValue);
59 foreach (
$data[
'expectedExceptionsMatch'] as $attrid => $expectedExceptionMatchRE) {
60 $exceptionMessage =
'';
62 $value =
$d->getHtmlAttrValue($attrid);
65 $exceptionMessage = $e->getMessage();
68 $this->assertTrue((preg_match($expectedExceptionMatchRE, $exceptionMessage) === 1) , sprintf(
"Exception '%s' does not match expected exception message '%s'.", $exceptionMessage, $expectedExceptionMatchRE));
74 public function testHtmlFormat($docName, array $setValues, array $expectedValues, $target =
"_self", $htmllink =
true, $index = - 1, $useEntitities =
true, $abstractMode =
false)
78 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
79 foreach ($setValues as $attrid => $newValue) {
80 $d->setAttributeValue($attrid, $newValue);
83 $ht = new \DocHtmlFormat(
$d);
84 foreach ($expectedValues as $attrid => $expectedValue) {
85 $oriValue =
$d->getrawValue($attrid);
86 $oa =
$d->getAttribute(($attrid));
89 $mValue =
$d->getMultipleRawValues($attrid);
90 $oriValue = $mValue[$index];
92 $value = $ht->getHtmlValue($oa, $oriValue, $target, $htmllink, $index, $useEntitities, $abstractMode);
94 $this->assertTrue($expectedValue ===
$value, sprintf(
"wrong value \"%s\" : \n\texpected \"%s\", \n\thas \"%s\" \n\tRaw is :\"%s\"", $attrid, print_r($expectedValue,
true) , print_r(
$value,
true) , print_r($oriValue,
true)));
106 "tst_text" =>
'no text',
107 "tst_date" =>
'no date',
108 "tst_time" =>
'no time',
109 "tst_int" =>
'no int',
110 "tst_longtext" =>
"no longtext",
111 "tst_double" =>
'no double',
112 "tst_money" =>
'no money',
113 "tst_timestamp" =>
'no timestamp',
114 "tst_rel" =>
"no rel",
115 "tst_enum" =>
"no enum",
116 "tst_color" =>
'no color',
117 "tst_enums" =>
"no enums",
118 "tst_texts" =>
"no text",
119 "tst_ints" =>
"no int",
120 "tst_moneys" =>
"no money",
121 "tst_doubles" =>
"no double",
122 "tst_times" =>
"no time",
123 "tst_enumms" =>
"no enum",
124 "tst_colors" =>
'no color',
125 "tst_longtexts" =>
"no longtext",
127 "tst_doubles1" =>
"",
129 "tst_ftext" =>
'no text',
130 "tst_fdate" =>
'no date',
131 "tst_ftime" =>
'no time',
132 "tst_fint" =>
'no int',
133 "tst_fdouble" =>
'no double',
134 "tst_fmoney" =>
'no money',
135 "tst_ftimestamp" =>
'no timestamp',
141 "useEntities" =>
true,
142 "abstractMode" =>
false
148 "tst_text" =>
'Document Un',
149 "tst_date" =>
'20/04/2013',
150 "tst_time" =>
'01:00',
152 "tst_longtext" =>
"Et<br />\nLa suite en été<b>...",
153 "tst_double" =>
'3.1415926',
154 "tst_money" =>
'2,54',
155 "tst_timestamp" =>
'30/09/2013 10:00',
158 "tst_color" =>
'<span style="background-color:#f3f">#f3f</span>',
159 "tst_enums" =>
"A<BR>B<BR>C",
160 "tst_texts" =>
"Un<BR>Deux",
162 "tst_moneys" =>
"3,00",
163 "tst_doubles" =>
"-54",
164 "tst_times" =>
"10:00",
166 "tst_colors" =>
'<span style="background-color:#ff33ff">#ff33ff</span><BR><span style="background-color:#45e098">#45e098</span>',
167 "tst_longtexts" =>
"Un<br />\nDeux<BR>Trois<br />\nQuatre",
168 "tst_ints1" =>
"1<BR>2<BR>3",
169 "tst_doubles1" =>
"<BR><BR>",
170 "tst_dates" =>
"20/04/2013",
172 "tst_ftext" =>
'[Document Un]',
173 "tst_fdate" =>
'samedi 20 avril 2013',
174 "tst_ftime" =>
' 1h 00min 00s',
175 "tst_fdoubles" =>
"-54.000",
177 "tst_fdouble" =>
'3.142',
178 "tst_fmoney" =>
'2,54 €',
179 "tst_fdates" =>
"samedi 20 avril 2013",
180 "tst_ftimestamp" =>
'lundi 30 septembre 2013 10h 00min 00s',
181 "tst_fltext" =>
'<a target="_self" title="" onmousedown="document.noselect=true;" href="http://www.here.com/Document%20Un.html" >Document Format Un</a>',
183 "tst_ftexts" =>
"[Un]<BR>[Deux]",
188 "useEntities" =>
true,
189 "abstractMode" =>
false
195 "tst_text" =>
'Document Deux',
196 "tst_date" =>
'23/05/2020',
197 "tst_time" =>
'14:17',
199 "tst_longtext" =>
"Texte long. Html tag <br />\n.",
200 "tst_double" =>
'-54',
201 "tst_money" =>
'3,00',
202 "tst_timestamp" =>
'30/09/2013 20:10',
205 "tst_color" =>
'<span style="background-color:#50ED42">#50ED42</span>',
206 "tst_enums" =>
"C<BR>no enums<BR>B",
207 "tst_texts" =>
"Un cheval noir<BR>Et un autre rouge",
208 "tst_ints" =>
"45<BR>3654<BR>-34",
209 "tst_moneys" =>
"2,54<BR>3,00<BR>2,72",
210 "tst_doubles" =>
"3.1415926<BR>2.7182818<BR>1.61803398875",
211 "tst_times" =>
"04:07",
212 "tst_dates" =>
'23/05/2020<BR>13/04/2017',
214 "tst_colors" =>
'<span style="background-color:#50ED42">#50ED42</span>',
215 "tst_longtexts" =>
"Alpha<br />\nBéta<BR>A<br />\nB<br />\nC",
216 "tst_ints1" =>
"3<BR><BR>",
217 "tst_doubles1" =>
"<BR>5.6<BR>7.8",
219 "tst_ftext" =>
'[Document Deux]',
220 "tst_fdate" =>
'samedi 23 mai 2020',
221 "tst_fdates" =>
"samedi 23 mai 2020<BR>jeudi 13 avril 2017",
223 "tst_ftexts" =>
'[Un cheval noir]<BR>[Et un autre rouge]',
224 "tst_fmoneys" =>
'2,54 $<BR>3,00 $<BR>2,72 $',
225 "tst_fdoubles" =>
"3.142<BR>2.718<BR>1.618",
226 "tst_ftime" =>
"14h 17min 43s",
227 "tst_fdouble" =>
'-54.000',
228 "tst_fmoney" =>
'3,00 €',
229 "tst_ftimestamp" =>
'lundi 30 septembre 2013 20h 10min 41s',
230 "tst_fltext" =>
'<a target="_self" title="" onmousedown="document.noselect=true;" href="http://www.here.com/Document%20Deux.html" >Document Format Deux</a>',
235 "useEntities" =>
true,
236 "abstractMode" =>
false
243 "tst_fltext" =>
'One',
246 "tst_fltext" =>
'<a target="_self" title="" onmousedown="document.noselect=true;" href="http://www.here.com/Two.html" >One</a>',
251 "useEntities" =>
true,
252 "abstractMode" =>
false
258 "tst_fltext" =>
'One',
261 "tst_fltext" =>
'One',
266 "useEntities" =>
true,
267 "abstractMode" =>
false
272 "tst_text" =>
"Hétérogénéité",
275 "tst_text" =>
'Hétérogénéité',
280 "useEntities" =>
true,
281 "abstractMode" =>
false
286 "tst_text" =>
"Hétérogénéité",
289 "tst_text" =>
'Hétérogénéité',
294 "useEntities" =>
false,
295 "abstractMode" =>
false
300 "tst_texts" => array(
307 "tst_texts" =>
'Deux',
312 "useEntities" =>
false,
313 "abstractMode" =>
false
318 "tst_texts" => array(
330 "useEntities" =>
false,
331 "abstractMode" =>
false
343 "tst_text" =>
'no text',
344 "tst_date" =>
'no date',
345 "tst_time" =>
'no time',
346 "tst_int" =>
'no int',
347 "tst_longtext" =>
"no longtext",
348 "tst_double" =>
'no double',
349 "tst_money" =>
'no money',
350 "tst_timestamp" =>
'no timestamp',
351 "tst_file" =>
'no file',
352 "tst_rel" =>
"no rel",
353 "tst_enum" =>
"no enum",
354 "tst_color" =>
'no color',
355 "tst_enums" =>
"no enums",
356 "tst_texts" =>
"no text",
357 "tst_ints" =>
"no int",
358 "tst_moneys" =>
"no money",
359 "tst_doubles" =>
"no double",
360 "tst_times" =>
"no time",
361 "tst_enumms" =>
"no enum",
362 "tst_colors" =>
'no color',
363 "tst_longtexts" =>
"no longtext",
365 "tst_doubles1" =>
"",
367 "tst_ftext" =>
'no text',
368 "tst_fdate" =>
'no date',
369 "tst_ftime" =>
'no time',
370 "tst_fint" =>
'no int',
371 "tst_fdouble" =>
'no double',
372 "tst_fmoney" =>
'no money',
373 "tst_ftimestamp" =>
'no timestamp',
381 "tst_text" =>
'Document Un',
382 "tst_date" =>
'20/04/2013',
383 "tst_time" =>
'01:00',
385 "tst_longtext" =>
"Et<br />\nLa suite en été<b>...",
386 "tst_double" =>
'3.1415926',
387 "tst_money" =>
'2,54',
388 "tst_timestamp" =>
'30/09/2013 10:00',
391 "tst_color" =>
'<span style="background-color:#f3f">#f3f</span>',
392 "tst_enums" =>
"A<BR>B<BR>C",
393 "tst_texts" =>
"Un<BR>Deux",
395 "tst_moneys" =>
"3,00",
396 "tst_doubles" =>
"-54",
397 "tst_times" =>
"10:00",
399 "tst_colors" =>
'<span style="background-color:#ff33ff">#ff33ff</span><BR><span style="background-color:#45e098">#45e098</span>',
400 "tst_longtexts" =>
"Un<br />\nDeux<BR>Trois<br />\nQuatre",
401 "tst_ints1" =>
"1<BR>2<BR>3",
402 "tst_doubles1" =>
"<BR><BR>",
403 "tst_dates" =>
"20/04/2013",
405 "tst_ftext" =>
'[Document Un]',
406 "tst_fdate" =>
'samedi 20 avril 2013',
407 "tst_ftime" =>
' 1h 00min 00s',
408 "tst_fdoubles" =>
"-54.000",
410 "tst_fdouble" =>
'3.142',
411 "tst_fmoney" =>
'2,54 €',
412 "tst_fdates" =>
"samedi 20 avril 2013",
413 "tst_ftimestamp" =>
'lundi 30 septembre 2013 10h 00min 00s',
414 "tst_fltext" =>
'<a target="_self" title="" onmousedown="document.noselect=true;" href="http://www.here.com/Document%20Un.html" oncontextmenu="popdoc(event,\'http://www.here.com/Document%20Un.html\');return false;" >Document Format Un</a>',
416 "tst_ftexts" =>
"[Un]<BR>[Deux]",
423 "tst_text" =>
'Document Deux',
424 "tst_date" =>
'23/05/2020',
425 "tst_time" =>
'14:17',
427 "tst_longtext" =>
"Texte long. Html tag <br />\n.",
428 "tst_double" =>
'-54',
429 "tst_money" =>
'3,00',
430 "tst_timestamp" =>
'30/09/2013 20:10',
433 "tst_color" =>
'<span style="background-color:#50ED42">#50ED42</span>',
434 "tst_enums" =>
"C<BR>no enums<BR>B",
435 "tst_texts" =>
"Un cheval noir<BR>Et un autre rouge",
436 "tst_ints" =>
"45<BR>3654<BR>-34",
437 "tst_moneys" =>
"2,54<BR>3,00<BR>2,72",
438 "tst_doubles" =>
"3.1415926<BR>2.7182818<BR>1.61803398875",
439 "tst_times" =>
"04:07",
440 "tst_dates" =>
'23/05/2020<BR>13/04/2017',
442 "tst_colors" =>
'<span style="background-color:#50ED42">#50ED42</span>',
443 "tst_longtexts" =>
"Alpha<br />\nBéta<BR>A<br />\nB<br />\nC",
444 "tst_ints1" =>
"3<BR><BR>",
445 "tst_doubles1" =>
"<BR>5.6<BR>7.8",
447 "tst_ftext" =>
'[Document Deux]',
448 "tst_fdate" =>
'samedi 23 mai 2020',
449 "tst_fdates" =>
"samedi 23 mai 2020<BR>jeudi 13 avril 2017",
451 "tst_ftexts" =>
'[Un cheval noir]<BR>[Et un autre rouge]',
452 "tst_fmoneys" =>
'2,54 $<BR>3,00 $<BR>2,72 $',
453 "tst_fdoubles" =>
"3.142<BR>2.718<BR>1.618",
454 "tst_ftime" =>
"14h 17min 43s",
455 "tst_fdouble" =>
'-54.000',
456 "tst_fmoney" =>
'3,00 €',
457 "tst_ftimestamp" =>
'lundi 30 septembre 2013 20h 10min 41s',
458 "tst_fltext" =>
'<a target="_self" title="" onmousedown="document.noselect=true;" href="http://www.here.com/Document%20Deux.html" oncontextmenu="popdoc(event,\'http://www.here.com/Document%20Deux.html\');return false;" >Document Format Deux</a>',
465 "tst_text" =>
'\'"a|à|á|â|ã|ä|å|o|ò|ó|ô|õ|ö|ø|e|è|é|ê|ë|c|ç|i|ì|í|î|ï|u|ù|ú|û|ü|y|ÿ|n|ñ|<|>|&',
466 "tst_htmltext
" => '<p>été comme hivers</p><br/><p>2>1</p>',
469 "tst_text
" => "'"a|à|á|â|ã|ä|å|o|ò|ó|ô|õ|ö|ø|e|è|é|ê|ë|c|ç|i|ì|í|î|ï|u|ù|ú|û|ü|y|ÿ|n|ñ|<|>|&",
470 "tst_htmltext" => '<div
class=
"htmltext"><p>été comme hivers</p><br><p>2>1</p></div>
',
475 public function dataGetHtmlValuesException()
480 'docName
' => 'TST_DOCHTML0
',
481 'setValues
' => array(
484 'expectedExceptionsMatch
' => array(
485 'tst_text
' => '/^$/
',
486 'tst_non_existing_attribute
' => '/{DOC0130}/
'
testHtmlFormat($docName, array $setValues, array $expectedValues, $target="_self", $htmllink=true, $index=-1, $useEntitities=true, $abstractMode=false)
testGetHtmlValues($docName, array $setValues, array $expectedValues)
testGetHtmlValuesException($data)
static getCommonImportFile()
requiresCoreParamEquals($paramName, $requiredValue, $markTestIncomplete=true)