14 require_once
'PU_testcase_dcp_commonfamily.php';
26 return "PU_data_dcp_gettypedvaluefamily.ods";
34 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
35 foreach ($expectedValues as $attrid => $expectedValue) {
36 $value =
$d->getAttributeValue($attrid);
37 $this->assertTrue($expectedValue ===
$value, sprintf(
'wrong value "%s" : expected %s, has %s', $attrid, $this->getDump($expectedValue) , $this->getDump(
$value,
true)));
46 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
48 $d->getAttributeValue($attrid);
51 $this->assertEquals($expectedErrorCode, $e->getDcpCode() , sprintf(
'"not correct code: %s"', $e->getMessage()));
60 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
62 $d->setAttributeValue($attrid,
$value);
63 $this->assertTrue(
false,
"no error detected need $expectedErrorCode");
66 $this->assertEquals($expectedErrorCode, $e->getDcpCode() , sprintf(
'"not correct code : %s"', $e->getMessage()));
67 $this->
log($e->getMessage());
76 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
77 foreach ($expectedValues as $attrid => $expectedValue) {
78 $value =
$d->getAttributeValue($attrid);
80 $expectedDocId = $this->docNames2docIds($expectedValue);
81 $this->assertTrue($expectedDocId ===
$value, sprintf(
'wrong value "%s" : expected %s, has %s \nRaw is :"%s"', $attrid, $this->getDump($expectedDocId) , $this->getDump(
$value,
true) ,
$d->getRawValue($attrid)));
90 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
91 foreach ($expectedValues as $attrid => $expectedValue) {
92 $value =
$d->getAttributeValue($attrid);
93 $stringDates = array();
94 $oa =
$d->getAttribute($attrid);
97 $stringDates = $this->date2string(
$value,
'Y-m-d');
101 $stringDates = $this->date2string(
$value,
'Y-m-d\TH:i:s');
105 $this->assertTrue($stringDates === $expectedValue, sprintf(
'wrong value "%s" : expected %s, has %s \nRaw is :"%s"', $attrid, $this->getDump($expectedValue,
true) , $this->getDump($stringDates) ,
$d->getRawValue($attrid)));
114 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
115 foreach ($expectedValues as $attrid => $newValue) {
116 $d->setAttributeValue($attrid, $newValue);
118 foreach ($expectedValues as $attrid => $expectedValue) {
119 $value =
$d->getAttributeValue($attrid);
121 $expectedDocId = $this->docNames2docIds($expectedValue);
123 $this->assertTrue($expectedDocId ===
$value, sprintf(
'wrong value "%s" : expected %s, has %s \nRaw is :"%s"', $attrid, $this->getDump($expectedDocId) , $this->getDump(
$value,
true) ,
$d->getRawValue($attrid)));
132 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
133 foreach ($setValues as $attrid => $newValue) {
134 $d->setAttributeValue($attrid, $newValue);
137 foreach ($expectedValues as $attrid => $expectedValue) {
138 $oriValue =
$value =
$d->getAttributeValue($attrid);
140 $oa =
$d->getAttribute($attrid);
151 $this->assertTrue($expectedValue ===
$value, sprintf(
'wrong value "%s" : expected %s, has %s \nRaw is :"%s"', $attrid, $this->getDump($expectedValue) , $this->getDump(
$value,
true) , $this->getDump($oriValue)));
155 private function date2string($dates, $format)
157 if (is_array($dates)) {
158 $stringDate = array();
162 foreach ($dates as $aDate) {
163 if (is_array($aDate)) {
168 foreach ($aDate as $dates2) {
169 $Datess[] = $dates2 ? $dates2->format($format) : null;
171 $stringDate[] = $Datess;
173 $stringDate[] = $aDate ? $aDate->format($format) : null;
180 $stringDate = $dates ? $dates->format($format) : null;
185 private function docNames2docIds($docNames)
187 if (is_array($docNames)) {
188 $expectedDocId = array();
189 foreach ($docNames as $docName) {
190 if (is_array($docName)) {
191 $expectDocId2 = array();
192 foreach ($docName as $docName2) {
195 $expectedDocId[] = $expectDocId2;
203 return $expectedDocId;
206 private function getDump(
$o)
210 return ob_get_clean();
218 $this->assertTrue(is_object(
$d) , sprintf(
"cannot create %s document", $this->famName));
219 foreach ($expectedValues as $attrid =>
$value) {
220 $d->setAttributeValue($attrid,
$value);
223 foreach ($expectedValues as $attrid => $expectedValue) {
224 $value =
$d->getAttributeValue($attrid);
225 $this->assertTrue($expectedValue ===
$value, sprintf(
'wrong value "%s" : expected %s, has %s', $attrid, $this->getDump($expectedValue) , $this->getDump(
$value,
true)));
235 $this->assertTrue(
$d->isAlive() , sprintf(
"cannot access %s document", $docName));
236 foreach ($expectedValues as $attrid =>
$value) {
237 $d->setAttributeValue($attrid,
$value);
240 foreach ($expectedValues as $attrid => $expectedValue) {
241 $value =
$d->getAttributeValue($attrid);
242 $this->assertTrue($expectedValue ===
$value, sprintf(
'wrong value "%s" : expected %s, has %s', $attrid, $this->getDump($expectedValue) , $this->getDump(
$value,
true)));
252 "tst_date" =>
'2013-04-21',
253 "tst_time" =>
'10:00',
255 "tst_double" =>
"24",
256 "tst_timestamp" =>
'2013-09-30T10:00:00',
257 "tst_dates" => array(
260 "tst_timestamps" => array(
261 "2013-09-30T10:00:00"
265 "tst_date" =>
'2013-04-21',
266 "tst_time" =>
'10:00:00',
268 "tst_double" => 24.0,
269 "tst_timestamp" =>
'2013-09-30T10:00:00',
270 "tst_dates" => array(
273 "tst_timestamps" => array(
274 "2013-09-30T10:00:00"
281 "tst_date" =>
new \DateTime(
'2013-04-21') ,
282 "tst_time" =>
'1:2:5',
283 "tst_timestamp" =>
new \DateTime(
'2013-09-30 10:00:00') ,
284 "tst_dates" => array(
285 new \DateTime(
"2013-04-20") ,
286 new \DateTime(
"2013-4-2") ,
288 "tst_timestamps" => array(
289 new \DateTime(
"2013-09-30T10:00:00")
293 "tst_date" =>
'2013-04-21',
294 "tst_time" =>
'01:02:05',
295 "tst_timestamp" =>
'2013-09-30T10:00:00',
296 "tst_dates" => array(
300 "tst_timestamps" => array(
301 "2013-09-30T10:00:00"
308 "tst_array5" => array(
310 "tst_dates" =>
new \DateTime(
"2013-04-20")
313 "tst_dates" =>
new \DateTime(
"2013-4-2")
318 "tst_dates" => array(
327 "tst_array8" => array(
329 "tst_timestamps" =>
new \DateTime(
"2013-09-30T10:00:00")
332 "tst_timestamps" =>
new \DateTime(
"2013-09-30T22:00:00")
337 "tst_timestamps" => array(
338 '2013-09-30T10:00:00',
339 '2013-09-30T22:00:00'
346 "tst_t_numbers" => array(
349 "tst_doubles1" => 23.6
355 "tst_t_numbers" => array(
358 "tst_doubles1" => 23.6
366 "tst_t_numbers" => array(
369 "tst_doubles1" => 20.0
375 "tst_doubles1" =>
"22.2"
380 "tst_doubles1" => 23.6
390 "tst_t_numbers" => array(
393 "tst_doubles1" => 20.0
397 "tst_doubles1" => null
401 "tst_doubles1" => 22.2
405 "tst_doubles1" => null
409 "tst_doubles1" => 23.6
413 "tst_doubles1" => 0.0
421 "tst_texts" => array(
426 "tst_texts" => array()
433 "tst_texts" => array(
439 "tst_texts" => array()
446 "tst_texts" => array(
453 "tst_texts" => array(
463 "tst_t_text" => array(
470 "tst_texts" => array(
479 "tst_t_text" => array(
489 "tst_texts" => array(
499 "tst_t_numbers" => null
502 "tst_t_numbers" => array()
508 "tst_t_numbers" => array()
511 "tst_t_numbers" => array()
517 "tst_t_numbers" => array(
520 "tst_doubles1" => 20.0
526 "tst_doubles1" =>
"22.2"
534 "tst_t_numbers" => array(
537 "tst_doubles1" => 20.0
541 "tst_doubles1" => null
545 "tst_doubles1" => 22.2
549 "tst_doubles1" => null
553 "tst_doubles1" => null
567 "tst_date" =>
'2013-04-20',
568 "tst_timestamp" =>
'2013-09-30T10:00:00',
569 "tst_dates" => array(
572 "tst_timestamps" => array(
573 "2013-09-30T10:00:00"
580 "tst_date" =>
'2020-05-23',
581 "tst_timestamp" =>
'2013-09-30T20:10:41',
582 "tst_dates" => array(
586 "tst_timestamps" => array(
587 "2013-09-30T20:10:41",
588 "2014-05-23T00:00:00"
600 "tst_rel" =>
'TST_DOCTYPE1',
605 "tst_rels2" => array(
622 "tst_rels2" => array(
648 "tst_rel" =>
'TST_DOCTYPE1',
653 "tst_rels2" => array(
670 "tst_rels2" => array(
847 "tst_double" => null,
851 "tst_timestamp" => null,
855 "tst_enums" => array() ,
856 "tst_texts" => array() ,
857 "tst_ints" => array() ,
858 "tst_moneys" => array() ,
859 "tst_doubles" => array() ,
860 "tst_dates" => array() ,
861 "tst_times" => array() ,
862 "tst_timestamps" => array() ,
863 "tst_enumms" => array() ,
864 "tst_colors" => array() ,
866 "tst_t_text" => array()
871 "tst_title" =>
"test trois",
874 "tst_double" => 3.14159,
875 "tst_time" =>
"12:54:00",
878 "tst_color" =>
"#ff23e6",
880 "tst_enums" => array(
885 "tst_texts" => array(
893 "tst_moneys" => array(
898 "tst_doubles" => array(
905 "tst_times" => array(
909 "tst_enumms" => array(
914 "tst_colors" => array(
934 "tst_double" => null,
938 "tst_timestamp" => null,
942 "tst_enums" => array() ,
943 "tst_texts" => array() ,
944 "tst_ints" => array() ,
945 "tst_moneys" => array() ,
946 "tst_doubles" => array() ,
947 "tst_dates" => array() ,
948 "tst_times" => array() ,
949 "tst_timestamps" => array() ,
950 "tst_enumms" => array() ,
951 "tst_colors" => array() ,
953 "tst_t_text" => array()
963 "tst_double" => null,
967 "tst_timestamp" => null,
971 "tst_enums" => array() ,
972 "tst_texts" => array() ,
973 "tst_ints" => array() ,
974 "tst_moneys" => array() ,
975 "tst_doubles" => array() ,
976 "tst_dates" => array() ,
977 "tst_times" => array() ,
978 "tst_timestamps" => array() ,
979 "tst_enumms" => array() ,
980 "tst_colors" => array() ,
982 "tst_t_text" => array()
988 "tst_title" =>
"test trois",
991 "tst_htmltext" =>
'<p>Mon premier paragraphe</p>',
992 "tst_double" => 3.14159,
993 "tst_time" =>
"12:54:00",
996 "tst_color" =>
"#ff23e6",
998 "tst_enums" => array(
1003 "tst_texts" => array(
1007 "tst_ints" => array(
1011 "tst_moneys" => array(
1016 "tst_doubles" => array(
1022 "tst_times" => array(
1026 "tst_enumms" => array(
1031 "tst_colors" => array(
1048 "tst_title" => null,
1050 "tst_money" => null,
1051 "tst_double" => null,
1055 "tst_timestamp" => null,
1057 "tst_color" => null,
1059 "tst_enums" => array() ,
1060 "tst_texts" => array() ,
1061 "tst_ints" => array() ,
1062 "tst_moneys" => array() ,
1063 "tst_doubles" => array() ,
1064 "tst_dates" => array() ,
1065 "tst_times" => array() ,
1066 "tst_timestamps" => array() ,
1067 "tst_enumms" => array() ,
1068 "tst_colors" => array() ,
1070 "tst_t_text" => array()
1076 "tst_title" =>
"Titre Un",
1077 "TST_TITLE" =>
"Titre Un",
1078 "tst_longtext" =>
"Et\nLa suite...",
1080 "tst_money" => 2.54,
1081 "tst_double" => 3.1415926,
1082 "tst_time" =>
"01:00:00",
1084 "tst_color" =>
"#f3f",
1085 "tst_enums" => array(
1090 "tst_texts" => array(
1094 "tst_ints" => array(
1097 "tst_moneys" => array(
1100 "tst_doubles" => array(-54.0
1102 "tst_times" => array(
1105 "tst_enumms" => array(
1108 "tst_colors" => array(
1111 "tst_longtexts" => array(
1115 "tst_ints1" => array(
1120 "tst_doubles1" => array(
1125 "tst_t_text" => array(
1130 "tst_texts" =>
"Deux"
1133 "tst_t_ints" => array(
1138 "tst_t_numbers" => array(
1141 "tst_doubles1" => null
1145 "tst_doubles1" => null
1149 "tst_doubles1" => null
1157 "tst_title" =>
"Titre Deux",
1158 "tst_longtext" =>
"Texte long. Html tag <BR>.",
1161 "tst_double" => - 54.0,
1162 "tst_time" =>
"14:17:43",
1164 "tst_color" =>
"#50ED42",
1165 "tst_enums" => array(
1170 "tst_texts" => array(
1174 "tst_ints" => array(
1178 "tst_moneys" => array(
1183 "tst_doubles" => array(
1188 "tst_times" => array(
1191 "tst_enumms" => array(
1194 "tst_colors" => array(
1197 "tst_ints1" => array(
1202 "tst_doubles1" => array(
1207 "tst_t_ints" => array(
testGetRelationValues($docName, array $expectedValues)
dataErrorGetAttributeValue()
testErrorSetAttributeValue($docName, $attrid, $value, $expectedErrorCode)
static getCommonImportFile()
testSetRelationValues($docName, array $expectedValues)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
testCreateSetAttributeValue(array $expectedValues)
dataErrorSetAttributeValue()
testSetGetValues($docName, array $setValues, array $expectedValues)
testGetDateValues($docName, array $expectedValues)
testErrorGetAttributeValue($docName, $attrid, $expectedErrorCode)
testModifySetAttributeValue($docName, array $expectedValues)
dataModifyAttributeValue()
getIdFromName($dbaccess, $name)
testGetAttributeValue($docName, array $expectedValues)