13 require_once
'PU_testcase_dcp_commonfamily.php';
25 return "PU_data_dcp_setvaluefamily.ods";
34 $this->assertTrue(is_object(
$d) ,
"cannot create TST_FAMSETVALUE document");
37 $this->assertEmpty(
$err, sprintf(
"setvalue error : %s",
$err));
38 if ($converted ===
false) $converted =
$value;
40 $this->assertEquals($converted,
$d->getRawValue($attrid) ,
"setvalue / getvalue $attrid : not the same");
42 $this->assertEmpty($err, sprintf(
"store error : %s", $err));
51 $this->assertTrue(is_object(
$d) ,
"cannot create TST_FAMSETVALUE document");
54 $this->assertNotEmpty(
$err, sprintf(
"setvalue error : %s",
$err));
55 $this->assertEmpty(
$d->getRawValue($attrid));
62 public function testArraySetValue(array $values, $expectedCount, array $secondValues = array() , $secondCount = 0)
65 $this->assertTrue(is_object(
$d) ,
"cannot create TST_FAMSETVALUE document");
67 foreach ($values as $aid =>
$value) {
70 $this->assertEmpty(
$err, sprintf(
"setvalue error : %s",
$err));
72 foreach ($values as $aid =>
$value) {
73 $this->assertEquals($expectedCount, count(
$d->getMultipleRawValues($aid)) , sprintf(
"count for %s incorrect %d <> %d", $aid, $expectedCount, count(
$d->getMultipleRawValues($aid))));
77 foreach ($secondValues as $aid =>
$value) {
80 $this->assertEmpty(
$err, sprintf(
"setvalue error : %s",
$err));
82 foreach ($secondValues as $aid =>
$value) {
83 $oa =
$d->getAttribute($aid);
84 $this->assertEquals($secondCount, count(
$d->getMultipleRawValues($aid)) , sprintf(
"second count for %s incorrect %d <> %d : %s", $aid, $secondCount, count(
$d->getMultipleRawValues($aid)) , print_r(
$d->getArrayRawValues($oa->fieldSet->id) ,
true)));
92 public function testOldValue(array $before, array $after, array $notchanged)
96 $this->assertTrue(is_object(
$d) ,
"cannot create TST_FAMSETVALUE document");
98 foreach ($before as $aid =>
$value) {
102 self::resetDocumentCache();
105 $this->assertEmpty(
$err, sprintf(
"before setvalue error : %s",
$err));
106 foreach ($after as $aid =>
$value) {
109 $this->assertEmpty(
$err, sprintf(
"after setvalue error : %s",
$err));
111 foreach ($notchanged as $aid =>
$value) {
112 $this->assertEquals(
$value,
$d->getOldRawValue($aid) ,
"wrong old value $aid" . print_r(
$d->getValues() ,
true));
122 $this->assertTrue(is_object(
$d) ,
"cannot create TST_FAMSETVALUE document");
124 foreach ($before as $aid =>
$value) {
125 $d->setAttributeValue($aid,
$value);
128 self::resetDocumentCache();
131 foreach ($after as $aid =>
$value) {
132 $d->setAttributeValue($aid,
$value);
135 foreach ($notchanged as $aid =>
$value) {
136 $this->assertEquals(
$value,
$d->getOldRawValue($aid) ,
"wrong old attribute value $aid" . print_r(array(
137 "values" =>
$d->getValues() ,
138 "old" =>
$d->getOldRawValues()
144 return array_merge(self::dataOldValue() , array(
149 "tst_array" => array(
151 "tst_coltext" =>
"Un",
153 "tst_coldate" =>
"2014-05-07"
160 "tst_array" => array(
162 "tst_coltext" =>
"Deux",
164 "tst_coldate" =>
"2014-05-08"
171 "tst_coltext" =>
"Un",
173 "tst_coldate" =>
"2014-05-07",
180 "tst_array" => array(
182 "tst_coltext" =>
"Un",
184 "tst_coldate" =>
"2014-05-07"
191 "tst_array" => array(
193 "tst_coltext" =>
"Deux",
195 "tst_coldate" =>
"2014-05-07"
202 "tst_coltext" =>
"Un",
203 "tst_colint" => null,
204 "tst_coldate" => null,
211 "tst_array" => array(
213 "tst_coltext" =>
"Un",
215 "tst_coldate" =>
"2014-05-07"
218 "tst_coltext" =>
"Deux",
220 "tst_coldate" =>
"2014-05-08"
227 "tst_array" => array(
229 "tst_coltext" =>
"Trois",
231 "tst_coldate" =>
"2014-05-08"
238 "tst_coltext" =>
"Un\nDeux",
239 "tst_colint" =>
"1\n2",
240 "tst_coldate" =>
"2014-05-07\n2014-05-08",
247 "tst_file" =>
"text/css|123|toto.css"
252 "tst_file" =>
"text/css|234|titi.css"
257 "tst_file" =>
"text/css|123|toto.css"
264 "tst_array" => array(
266 "tst_coltext" =>
"Un",
268 "tst_coldate" =>
"2014-05-07",
269 "tst_files" =>
"text/css|123|un.css"
272 "tst_coltext" =>
"Deux",
274 "tst_coldate" =>
"2014-05-08",
275 "tst_files" =>
"text/css|234|deux.css"
282 "tst_array" => array(
284 "tst_coltext" =>
"Un",
286 "tst_coldate" =>
"2014-05-07",
287 "tst_files" =>
"text/css|123|un.css"
290 "tst_coltext" =>
"Deux",
292 "tst_coldate" =>
"2014-05-08",
293 "tst_files" =>
"text/css|234|deux.css"
296 "tst_coltext" =>
"Trois",
298 "tst_coldate" =>
"2014-05-08",
299 "tst_files" =>
"text/css|345|trois.css"
306 "tst_coltext" =>
"Un\nDeux",
307 "tst_colint" =>
"1\n2",
308 "tst_coldate" =>
"2014-05-07\n2014-05-08",
309 "tst_files" =>
"text/css|123|un.css\ntext/css|234|deux.css"
322 "tst_date" =>
'2012-01-30',
323 "tst_docids" => array() ,
324 "tst_coltext" => array() ,
325 "tst_coldate" => array() ,
326 "tst_colint" => array()
331 "tst_date" =>
'2012-01-30',
332 "tst_docids" => array() ,
333 "tst_coltext" => array() ,
334 "tst_coldate" => array()
340 "tst_docids" => null,
341 "tst_coltext" => null,
342 "tst_coldate" => null,
343 "tst_colint" => null,
350 "tst_date" =>
'2012-01-30',
351 "tst_docids" => array(
355 "tst_coltext" => array(
359 "tst_coldate" => array(
363 "tst_colint" => array(
371 "tst_date" =>
'30/01/2012',
372 "tst_docids" => array(
376 "tst_coltext" => array(
385 "tst_docids" => null,
386 "tst_coltext" => null,
387 "tst_coldate" => null,
388 "tst_colint" => null,
395 "tst_date" =>
'2012-01-30',
396 "tst_docids" => array(
400 "tst_coltext" => array(
404 "tst_coldate" => array(
408 "tst_colint" => array(
416 "tst_date" =>
'31/01/2012',
417 "tst_docids" => array(
421 "tst_coltext" => array(
430 "tst_date" =>
'2012-01-30',
431 "tst_docids" => null,
432 "tst_coltext" =>
"Un\nDeux",
433 "tst_coldate" => null,
434 "tst_colint" => null,
444 "tst_coltext" => array(
449 "tst_colint" => array(
454 "tst_coldate" => array(
464 "tst_coltext" => array(
468 "tst_colint" => array(
471 "tst_coldate" => array(
480 "tst_coltext" => array(
484 "tst_colint" => array() ,
485 "tst_coldate" => array(
495 "tst_coltext" => array() ,
496 "tst_colint" => array() ,
497 "tst_coldate" => array(
506 "tst_coltext" => array(
510 "tst_colint" => array() ,
511 "tst_coldate" => array(
518 "tst_coltext" => array(
521 "tst_colint" => array() ,
522 "tst_coldate" => array(
530 "tst_coltext" => array(
535 "tst_colint" => array(
540 "tst_coldate" => array(
548 "tst_coltext" => array(
552 "tst_colint" => array(
556 "tst_coldate" => array(
565 "tst_coltext" => array(
570 "tst_colint" => array(
575 "tst_coldate" => array(
583 "tst_coltext" => array(
586 "tst_colint" => array(
589 "tst_coldate" => array(
597 "tst_coltext" => array(
602 "tst_colint" => array(
607 "tst_coldate" => array(
615 "tst_coltext" => array() ,
616 "tst_colint" => array() ,
617 "tst_coldate" => array()
703 '<p>être & Co <i>12 €</i></p>',
704 '<p>être & Co <i>12 €</i></p>'
708 '<p>L\'avenir est "ici"</p>'
712 '<p>L'avenir est "ici"</p>',
713 '<p>L'avenir est "ici"</p>'
717 '<p>L'avenir est "ici"</p>',
718 '<p>L\'avenir est "ici"</p>'
722 '<p>L'avenir est "ici"</p>',
723 '<p>L\'avenir est "ici"</p>'
727 '<p>L'avenir est "ici"</p>',
728 '<p>L\'avenir est "ici"</p>'
732 '<style>p.zou:{color:red;}</style><p class="zou">C\'est rouge</p>',
733 '<style>p.zou:{color:red;}</style><p class="zou">C\'est rouge</p>'
737 '<p onload="alert(1)">Hou la là</p>',
742 '<p onload="alert(1)">Hou la là</p>',
747 '<p onload=\'alert(1)\'>Hou la là quote</p>',
748 '<p >Hou la là quote</p>'
752 '<p onload=\'alert(1)\'>Hou la là quote</p>',
753 '<p>Hou la là quote</p>'
757 '<p onload = "alert(1)">Hou la là espaces</p>',
758 '<p >Hou la là espaces</p>'
762 '<p onload = "alert(1)">Hou la là espaces</p>',
763 '<p>Hou la là espaces</p>'
767 "<p onload\n=\n\t 'alert(1)' style='color:blue'>Hou la là espaces compliqués</p>",
768 "<p style='color:blue'>Hou la là espaces compliqués</p>"
772 "<p onload\n=\n\t 'alert(1)' style='color:blue'>Hou la là espaces compliqués</p>",
773 "<p>Hou la là espaces compliqués</p>"
777 '<p onload=\'alert(1)\'>Hou la là</p>',
782 '<p onload=\'alert(1)\'>Hou la là</p>',
787 '<script>alert("oh");</script><p data-oh="2" onclick="alert(1)" data-yo="1">Hou la là</p>',
788 'alert("oh");<p data-oh="2" data-yo="1">Hou la là</p>'
792 '<script>alert("oh");</script><p data-oh="2" onclick="alert(1)" data-yo="1">Hou la là</p>',
793 'alert("oh");<p data-oh="2" data-yo="1">Hou la là</p>'
797 '<a href="javascript:alert(1)">Hou la là</a>',
798 '<a href="nojavascript...alert(1)">Hou la là</a>'
802 '<a href="vbscript:alert(1)">Hou la là</a>',
803 '<a href="novbscript...alert(1)">Hou la là</a>'
807 '<xml:a href="#Yo">Pas de domaine</xml:a>',
812 '<a href="#Yo">Yo</a>'
816 '<p data-onload="alert(1)">Çà et là</p>',
817 '<p data-onload="alert(1)">Çà et là</p>'
821 '<div class="special"><span width="30px">Hello</span></div>'
825 '<div class="special"><span width="30px">Hello</span></div>',
830 '<div><font color="#007755">Hello</font></div>',
835 '<div>A<iframe style="color:red" onload="alert(1)" src="about:blank"/>Z</div>',
836 '<div>A<iframe style="color:red" src="about:blank"/>Z</div>'
840 '<div>A<iframe style="color:red" onload="alert(1)" src="about:blank"/>Z</div>',
841 '<div>A<iframe src="about:blank"></iframe>Z</div>'
845 '<div>A<iframe style="color:red" onload="alert(1)" src="about:blank"/>Z</div>',
846 '<div>A<iframe style="color:red" src="about:blank"/>Z</div>'
850 '<div>A<iframe style="color:red" onload="alert(1)" src="about:blank"/>Z</div>',
851 '<div>A<iframe src="about:blank"></iframe>Z</div>'
855 '<style>p.zou:{color:red;}</style><p class="zou">C\'est rouge</p>',
856 '<p>C\'est rouge</p>'
860 '<style>p.zou:{color:red;}</style><p class=\'zou\'>C\'est rouge</p>',
861 '<p>C\'est rouge</p>'
865 '<p>Hello <em>world',
870 '<p>Hello <em>world',
871 '<p>Hello <em>world</em></p>'
875 '<video src="foo.ogg"><track kind="subtitles" src="foo.en.vtt" srclang="en" label="English"></track><track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska"></track></video>',
876 '<video src="foo.ogg"><track kind="subtitles" src="foo.en.vtt" srclang="en" label="English"></track><track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska"></track></video>'
918 '<p style=">Hello</p>'
926 '<p style=">Hello</p>'
testGoodSetValue($attrid, $value, $converted=false)
static getCommonImportFile()
testOldAttributeValue(array $before, array $after, array $notchanged)
static dataAttributeOldValue()
testWrongSetValue($attrid, $value)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
testOldValue(array $before, array $after, array $notchanged)
if($file) if($subject==""&&$file) if($subject=="") $err
testArraySetValue(array $values, $expectedCount, array $secondValues=array(), $secondCount=0)
requiresCoreParamEquals($paramName, $requiredValue, $markTestIncomplete=true)