13 require_once
'PU_testcase_dcp_commonfamily.php';
20 return "PU_data_dcp_enumfamily1.ods";
25 public function testExecuteGetEnum(
$famid, $attrid, array $expectedKeys, array $expectedLabel)
28 $this->assertTrue($fam->isAlive() , sprintf(
"family %s not found",
$famid));
32 $oa = $fam->getAttribute($attrid);
33 $this->assertNotEmpty($oa, sprintf(
"attribute %s not found", $attrid));
35 $enum = $oa->getEnum();
36 $keys = array_keys($enum);
37 $labels = array_values($enum);
39 $this->assertEquals($expectedKeys, $keys,
"enum keys mismatch");
40 $this->assertEquals($expectedLabel, $labels,
"enum label mismatch");
45 public function testGetLabelOfEnum(
$famid, $attrid, array $expectedKeysLabel)
48 $this->assertTrue($fam->isAlive() , sprintf(
"family %s not found",
$famid));
52 $oa = $fam->getAttribute($attrid);
53 $this->assertNotEmpty($oa, sprintf(
"attribute %s not found", $attrid));
55 $enum = $oa->getEnum();
56 foreach ($expectedKeysLabel as $key => $label) {
58 $this->assertEquals($label, $oa->getEnumLabel($key) , sprintf(
"enum single label mismatch: key %s\n%s", $key, print_r($enum,
true)));
64 public function testGetEnumLabel(
$famid, $attrid, array $expectedKeys, array $expectedLabel)
66 $a = _(
"TST_ENUMFAM1#tst_enuma#a");
67 $a = _(
"TST_ENUMFAM1#tst_enum2#0");
69 $this->assertTrue($fam->isAlive() , sprintf(
"family %s not found",
$famid));
73 $oa = $fam->getAttribute($attrid);
74 $this->assertNotEmpty($oa, sprintf(
"attribute %s not found", $attrid));
76 $enum = $oa->getEnumLabel();
77 $keys = array_keys($enum);
78 $labels = array_values($enum);
80 $this->assertEquals($expectedKeys, $keys,
"enum keys mismatch");
81 $this->assertEquals($expectedLabel, $labels,
"enum label mismatch");
90 public function testInheritedGetEnum($familyIdList, $attrId, $expectedEnum)
96 foreach ($familyIdList as $familyId) {
98 $attr = $fam->getAttribute($attrId);
99 $enum = $attr->getEnum();
100 $this->assertTrue(is_array($enum) , sprintf(
"getEnum() on '%s' from '%s' is not an array (found type '%s').", $attrId, $fam->name, gettype($enum)));
101 $this->assertTrue(count($expectedEnum) === count($enum) , sprintf(
"Count mismatch for getEnum() on '%s' from '%s': found '%d' while expecting '%d'.", $attrId, $fam->name, count($enum) , count($expectedEnum)));
102 $diff = array_diff_key($expectedEnum, $enum);
103 $this->assertTrue(count($diff) === 0, sprintf(
"getEnum() on '%s' from '%s' returned unexpected keys.", $attrId, $fam->name));
112 public function testInheritedAddEnum($addEnums, $expectedEnums)
118 foreach ($addEnums as $familyId => $attrs) {
120 foreach ($attrs as $attrId => $enums) {
121 $attr = $fam->getAttribute($attrId);
122 foreach ($enums as $enumKey => $enumValue) {
124 $this->assertEmpty(
$err, sprintf(
"addEnum() returned unexpected error: %s",
$err));
128 foreach ($expectedEnums as $familyId => $attrs) {
130 foreach ($attrs as $attrId => $expectedEnum) {
131 $attr = $fam->getAttribute($attrId);
132 $enum = $attr->getEnum();
133 $this->assertTrue(is_array($enum) , sprintf(
"getEnum() on '%s' from '%s' is not an array (found type '%s').", $attrId, $fam->name, gettype($enum)));
134 $this->assertTrue(count($expectedEnum) === count($enum) , sprintf(
"Count mismatch for getEnum() on '%s' from '%s': found '%d' while expecting '%d'.", $attrId, $fam->name, count($enum) , count($expectedEnum)));
135 $diff = array_diff_key($expectedEnum, $enum);
136 $this->assertTrue(count($diff) === 0, sprintf(
"getEnum() on '%s' from '%s' returned unexpected keys.", $attrId, $fam->name));
145 'family' =>
'TST_ENUMFAM1',
146 'attrid' =>
'TST_ENUM1',
159 'family' =>
'TST_ENUMFAM1',
160 'attrid' =>
'TST_ENUMA',
173 'family' =>
'TST_ENUMFAM1',
174 'attrid' =>
'TST_ENUM2',
193 'family' =>
'TST_ENUMFAM1',
194 'attrid' =>
'TST_ENUMAUTO2',
214 'family' =>
'TST_ENUMFAM1',
215 'attrid' =>
'TST_ENUMNA',
235 'family' =>
'TST_ENUMFAM1',
236 'attrid' =>
'TST_ENUMNUMERIC',
255 'family' =>
'TST_ENUMFAM1',
256 'attrid' =>
'TST_ENUM1',
269 'family' =>
'TST_ENUMFAM1',
270 'attrid' =>
'TST_ENUMA',
283 'family' =>
'TST_ENUMFAM1',
284 'attrid' =>
'TST_ENUM2',
303 'family' =>
'TST_ENUMFAM1',
304 'attrid' =>
'TST_ENUMAUTO2',
323 'family' =>
'TST_ENUMFAM1',
324 'attrid' =>
'TST_ENUMNUMERIC',
343 'family' =>
'TST_ENUMFAM1',
344 'attrid' =>
'TST_ENUM1',
345 'keysLabel' => array(
353 'family' =>
'TST_ENUMFAM1',
354 'attrid' =>
'TST_ENUM2',
355 'keysLabel' => array(
357 "01" =>
"Zéfiro/ZéroUn",
358 "02" =>
"Zéfiro/ZéroDeux",
366 'family' =>
'TST_ENUMFAM1',
367 'attrid' =>
'TST_ENUMNUMERIC',
368 'keysLabel' => array(
369 "0.1" =>
"Zéro virgule un",
370 "1.2" =>
"Un point 2",
381 'TST_INHERIT_GETENUM_A1',
382 'TST_INHERIT_GETENUM_B1',
383 'TST_INHERIT_GETENUM_C1'
385 'attrid' =>
'TST_ENUM1',
386 'expectedEnum' => array(
394 'TST_INHERIT_GETENUM_A2',
395 'TST_INHERIT_GETENUM_B2',
396 'TST_INHERIT_GETENUM_C2',
397 'TST_INHERIT_GETENUM_D2'
399 'attrid' =>
'TST_ENUM1',
400 'expectedEnum' => array(
408 'TST_INHERIT_GETENUM_A3',
409 'TST_INHERIT_GETENUM_B3',
410 'TST_INHERIT_GETENUM_C3',
411 'TST_INHERIT_GETENUM_D3'
413 'attrid' =>
'TST_ENUM1',
414 'expectedEnum' => array(
427 'TST_INHERIT_ADDENUM_B1' => array(
428 'TST_ENUM1' => array(
432 'TST_INHERIT_ADDENUM_C1' => array(
433 'TST_ENUM1' => array(
437 'TST_INHERIT_ADDENUM_D1' => array(
438 'TST_ENUM1' => array(
443 'expectedEnums' => array(
444 'TST_INHERIT_ADDENUM_B1' => array(
445 'TST_ENUM1' => array(
454 'TST_INHERIT_ADDENUM_C1' => array(
455 'TST_ENUM1' => array(
464 'TST_INHERIT_ADDENUM_D1' => array(
465 'TST_ENUM1' => array(
478 'TST_INHERIT_ADDENUM_B2' => array(
479 'TST_ENUM1' => array(
483 'TST_INHERIT_ADDENUM_C2' => array(
484 'TST_ENUM1' => array(
488 'TST_INHERIT_ADDENUM_D2' => array(
489 'TST_ENUM1' => array(
494 'expectedEnums' => array(
495 'TST_INHERIT_ADDENUM_B2' => array(
496 'TST_ENUM1' => array(
505 'TST_INHERIT_ADDENUM_C2' => array(
506 'TST_ENUM1' => array(
515 'TST_INHERIT_ADDENUM_D2' => array(
516 'TST_ENUM1' => array(
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
if($file) if($subject==""&&$file) if($subject=="") $err
static getCommonImportFile()