13 require_once
'PU_testcase_dcp_commonfamily.php';
26 "PU_data_dcp_docenum_family.ods"
36 foreach ($langs as
$lang) {
41 parent::tearDownAfterClass();
46 public function testDocEnumAdd($attrid, $key, $label, $absOrder, $expectedOrder)
48 $s = new \EnumStructure();
51 $s->absoluteOrder = $absOrder;
55 $this->verifyEnumProperties($attrid, $key, $label, $expectedOrder);
60 public function testDocEnumMod($attrid, $key, $label, $absOrder, $expectedOrder)
62 $s = new \EnumStructure();
65 $s->absoluteOrder = $absOrder;
69 $this->verifyEnumProperties($attrid, $key, $label, $expectedOrder);
76 $s = new \EnumStructure();
79 $s->orderBeforeThan = $relativeOrder;
83 $this->verifyEnumProperties($attrid, $key, $label, $expectedOrder);
88 public function testDocEnumDisabled($attrid, array $disabledKeys, $expectedEnums)
92 foreach ($disabledKeys as $key) {
93 $oe = new \DocEnum(
"", array(
99 $this->assertTrue(
$oe->isAffected() ,
"enum $attrid : $key not found");
100 $s = new \EnumStructure();
102 $s->label =
$oe->label;
103 $s->absoluteOrder =
$oe->eorder;
111 $oa = $fam->getAttribute($attrid);
113 $enums = $oa->getEnumLabel(null,
false);
114 $enumKey = array_keys($enums);
115 $diff = array_diff($enumKey, $expectedEnums);
117 $this->assertEmpty($diff, sprintf(
"getEnumLabel:: not expected visible \nExpect:\n %s,\nHas\n %s", print_r($expectedEnums,
true) , print_r($enumKey,
true)));
119 $this->assertEquals(count($expectedEnums) , count($enumKey) , sprintf(
"getEnumLabel:: not expected enum count %s, %s", print_r($expectedEnums,
true) , print_r($enums,
true)));
122 $enums = $oa->getEnum(
false);
123 $enums2 = $oa->getEnum(
false);
124 $this->assertEquals($enums, $enums2, sprintf(
"getEnum::not same with cache %s, %s", print_r($enums,
true) , print_r($enums2,
true)));
126 $enumKey = array_keys($enums);
127 $diff = array_diff($enumKey, $expectedEnums);
129 $this->assertEmpty($diff, sprintf(
"getEnum:: not expected visible \nExpect:\n %s,\nHas\n %s", print_r($expectedEnums,
true) , print_r($enumKey,
true)));
131 $this->assertEquals(count($expectedEnums) , count($enumKey) , sprintf(
"getEnum::not expected enum count %s, %s", print_r($expectedEnums,
true) , print_r($enums,
true)));
138 $s = new \EnumStructure();
141 $s->orderBeforeThan = $relativeOrder;
145 $this->verifyEnumProperties($attrid, $key, $label, $expectedOrder);
147 private function verifyEnumProperties($attrid, $key, $expectedLabel, $expectedOrder)
149 $f =
new_Doc(
"", self::familyName);
153 $oa = $f->getAttribute($attrid);
155 $elabel = $oa->getEnumLabel($key);
156 $this->assertTrue($elabel !== null,
"Enum not inserted");
157 $this->assertEquals($expectedLabel, $elabel,
"Enum not inserted");
159 $de = new \DocEnum(
"", array(
164 $this->assertTrue($de->isAffected() ,
"Enum record not found");
165 $this->assertEquals($expectedOrder, $de->eorder,
"Enum order not the good one");
170 public function testDocEnumAddLocale($attrid, $key, $label, array
$locale)
172 $s = new \EnumStructure();
176 foreach ($locale as
$lang => $localeLabel) {
177 $s->localeLabel[] = new \EnumLocale(
$lang, $localeLabel);
183 $f =
new_Doc(
"", self::familyName);
187 $oa = $f->getAttribute($attrid);
189 $label = $oa->getEnumLabel($key);
190 $this->assertTrue($label !== null,
"Enum not inserted");
192 foreach ($locale as
$lang => $localeLabel) {
195 $eLabel = $oa->getEnumLabel($key);
196 $this->assertEquals($localeLabel, $eLabel, sprintf(
"not good %s mabel",
$lang));
204 "attrid" =>
"tst_enum1",
211 "attrid" =>
"tst_enum1",
218 "attrid" =>
"tst_enum1",
225 "attrid" =>
"tst_enum1",
227 "label" =>
"mucho mucho",
232 "attrid" =>
"tst_enum1",
234 "label" =>
"mucho mucho",
244 "attrid" =>
"tst_enum1",
246 "label" =>
"one more",
251 "attrid" =>
"tst_enum1",
253 "label" =>
"one more",
263 "attrid" =>
"tst_enuma",
265 "label" =>
"one more",
270 "attrid" =>
"tst_enuma",
272 "label" =>
"one more",
277 "attrid" =>
"tst_enuma",
279 "label" =>
"one more",
284 "attrid" =>
"tst_enuma",
286 "label" =>
"one more",
296 "attrid" =>
"tst_enuma",
298 "label" =>
"one more",
303 "attrid" =>
"tst_enuma",
305 "label" =>
"one more",
310 "attrid" =>
"tst_enuma",
312 "label" =>
"one more",
323 "attrid" =>
"tst_enum1",
334 "attrid" =>
"tst_enum1",
335 "disable" => array() ,
344 "attrid" =>
"tst_enum1",
354 "attrid" =>
"tst_enum1",
365 "attrid" =>
"tst_enuma",
381 "attrid" =>
"tst_enum1",
dataDocAddRelativeOrder()
static reloadLocaleCache()
testDocEnumAddRelativeOrder($attrid, $key, $label, $relativeOrder, $expectedOrder)
static modifyEnum($famId, $attrid, EnumStructure $enumStruct)
static getCommonImportFile()
static addEnum($famId, $attrid, EnumStructure $enumStruct)
testDocEnumAdd($attrid, $key, $label, $absOrder, $expectedOrder)
testDocEnumMod($attrid, $key, $label, $absOrder, $expectedOrder)
static tearDownAfterClass()
new_Doc($dbaccess, $id= '', $latest=false)
dataDocModRelativeOrder()
testDocEnumModRelativeOrder($attrid, $key, $label, $relativeOrder, $expectedOrder)
static getMoFilename($famId, $lang)