$t->is($menu['admin']->getCulture(), 'mars', '->getCulture() returns the set culture, not the parent\'s culture.'); $t->info(' 9.2 - Test the useI18n() and get/setLabel() methods'); $menu = new ioMenuItem('admin'); $context->getUser()->setCulture('en'); $t->is($menu->useI18n(), false, '->useI18n() returns false, there are no i18n labels set.'); $menu->setLabel('administración', 'es'); $t->is($menu->useI18n(), true, '->useI18n() returns true after an i18n label is set.'); $t->is($menu->getLabel('es'), 'administración', '->getLabel(es) correctly returns the spanish label I just set.'); $t->is($menu->getLabel(), 'admin', '->getLabel() still returns "admin", which is the name since no en label is set.'); $menu->setLabel('admin default'); $t->is($menu->getLabel(), 'admin default', '->getLabel() returns "admin default", the default label'); $menu->setLabel('administration', 'en'); $t->is($menu->getLabel(), 'administration', '->getLabel() returns "administration", the "en" culture label'); sfConfig::set('sf_default_culture', 'es'); $t->is($menu->getLabel('fake'), 'administración', '->getLabel() retrieves the sf_default_culture label if the given culture does not have a label.'); $menu->setCulture('es'); $t->is($menu->getLabel(), 'administración', '->getLabel() returns the label of the culture on the label'); $t->info(' 9.3 - Test toArray() and fromArray()'); $arr = $menu->toArray(); $t->is($arr['i18n_labels'], array('es' => 'administración', 'en' => 'administration'), '->toArray() exports an i18n_labels array'); $newMenu = ioMenuItem::createFromArray($arr); $arr = $newMenu->toArray(); $t->is($arr['i18n_labels'], array('es' => 'administración', 'en' => 'administration'), '->fromArray() correctly imports the i18n_labels'); $menu = new ioMenuItem('root'); $arr = $menu->toArray(); $t->is(isset($arr['i18n_labels']), false, 'If no i18n labels are set, the key is hidden entirely from ->toarray().'); $t->info('10 - Test item reordering.'); $menu = new ioMenuItem('root'); $menu->addChild('c1'); $menu->addChild('c2'); $menu->addChild('c3');