示例#1
0
    {
        return array(dirname(__FILE__) . '/fixtures');
    }
}
$configuration = new TestConfiguration('test', true, sfConfig::get('sf_test_cache_dir', sfToolkit::getTmpDir()));
$dispatcher = $configuration->getEventDispatcher();
$cache = new sfNoCache();
// ->initialize()
$t->diag('->initialize()');
$i18n = new sfI18N($configuration, $cache);
$dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' => 'fr')));
$t->is($i18n->getCulture(), 'fr', '->initialize() connects to the user.change_culture event');
// ->getCulture() ->setCulture()
$t->diag('->getCulture() ->setCulture()');
$i18n = new sfI18N($configuration, $cache);
$t->is($i18n->getCulture(), 'en', '->getCulture() returns the current culture');
$i18n->setCulture('fr');
$t->is($i18n->getCulture(), 'fr', '->setCulture() sets the current culture');
// ->__()
$t->diag('->__()');
sfConfig::set('sf_charset', 'UTF-8');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->__('an english sentence'), 'une phrase en français', '->__() translates a string');
class EnglishSentence
{
    public function __toString()
    {
        return 'an english sentence';
    }
}
$t->is($i18n->__(new EnglishSentence()), 'une phrase en français', '->__() translates an object with __toString()');