$t->diag('::setTranslationCallable() ::getTranslationCallable()'); function my__($string) { return sprintf('[%s]', $string); } class myI18n { public static function __($string) { return my__($string); } } MyFormatter::setTranslationCallable('my__'); $t->is(MyFormatter::getTranslationCallable(), 'my__', 'get18nCallable() retrieves i18n callable correctly'); MyFormatter::setTranslationCallable(new sfCallable('my__')); $t->isa_ok(MyFormatter::getTranslationCallable(), 'sfCallable', 'get18nCallable() retrieves i18n sfCallable correctly'); try { $f->setTranslationCallable('foo'); $t->fail('setTranslationCallable() does not throw InvalidException when i18n callable is invalid'); } catch (InvalidArgumentException $e) { $t->pass('setTranslationCallable() throws InvalidException if i18n callable is not a valid callable'); } catch (Exception $e) { $t->fail('setTranslationCallable() throws unexpected exception'); } $t->diag('->translate()'); $f = new MyFormatter(new sfWidgetFormSchema()); $t->is($f->translate('label'), '[label]', 'translate() call i18n sfCallable as expected'); MyFormatter::setTranslationCallable(array('myI18n', '__')); $t->is($f->translate('label'), '[label]', 'translate() call i18n callable as expected'); $t->diag('->generateLabel() ->generateLabelName() ->setLabel() ->setLabels()'); MyFormatter::dropTranslationCallable();