$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();
$w = new sfWidgetFormSchema(array('author_id' => new sfWidgetFormInputText(), 'first_name' => new sfWidgetFormInputText(), 'last_name' => new sfWidgetFormInputText()));
$f = new MyFormatter($w);
$t->is($f->generateLabelName('first_name'), 'First Name', '->generateLabelName() generates a label value from a label name');
$t->is($f->generateLabelName('author_id'), 'Author', '->generateLabelName() removes _id from auto-generated labels');
$w->setLabels(array('first_name' => 'The first name'));
$t->is($f->generateLabelName('first_name'), 'The first name', '->setLabels() changes all current labels');
$w->setLabel('first_name', 'A first name');
$t->is($f->generateLabelName('first_name'), 'A first name', '->setLabel() sets a label value');
$w->setLabel('first_name', false);
$t->is($f->generateLabel('first_name'), '', '->generateLabel() returns an empty string if the label is false');
$w->setLabel('first_name', 'Your First Name');
$t->is($f->generateLabel('first_name'), '<label for="first_name">Your First Name</label>', '->generateLabelName() returns a label tag');
$t->is($f->generateLabel('first_name', array('class' => 'foo')), '<label class="foo" for="first_name">Your First Name</label>', '->generateLabelName() returns a label tag with optional HTML attributes');
$t->is($f->generateLabel('first_name', array('for' => 'myid')), '<label for="myid">Your First Name</label>', '->generateLabelName() returns a label tag with specified for-id');
$w->setLabel('last_name', 'Your Last Name');
$t->is($f->generateLabel('last_name'), '<label for="last_name">Your Last Name</label>', '->generateLabelName() returns a label tag');
MyFormatter::setTranslationCallable('my__');
$t->is($f->generateLabel('last_name'), '<label for="last_name">[Your Last Name]</label>', '->generateLabelName() returns a i18ned label tag');
// ->setTranslationCatalogue() ->getTranslationCatalogue()
class MyFormatter2 extends sfWidgetFormSchemaFormatter
{
}
$f = new MyFormatter2(new sfWidgetFormSchema(array()));
$f->setTranslationCatalogue('foo');
$t->is($f->getTranslationCatalogue(), 'foo', 'setTranslationCatalogue() has set the i18n catalogue correctly');