public function testSetLocale() { Session::start(); $currentLocale = I18n::getCurrentLocale(); $_REQUEST['_locale'] = 'en'; I18n::staticReset(); $this->assertEquals('en', I18n::getCurrentLocale(), 'Unable to set locale via request'); $_REQUEST['_locale'] = $currentLocale; I18n::staticReset(); unset($_REQUEST['_locale']); I18n::setLocale('en'); $this->assertEquals('en', I18n::getCurrentLocale(), 'Unable to set locale via setLocale()'); I18n::setLocale($currentLocale); $this->assertEquals($currentLocale, I18n::getCurrentLocale(), 'Unable to set locale via setLocale()'); I18n::setLocale('non-existing'); $this->assertEquals($currentLocale, I18n::getCurrentLocale(), 'Unable to restore default locale via setLocale()'); Session::end(); I18n::clearCache(true); Cookies::set('locale', 'en'); Session::start(); I18n::staticReset(); $this->assertEquals('en', I18n::getCurrentLocale(), 'Unable to set locale via cookie'); $_REQUEST['_locale'] = $currentLocale; I18n::staticReset(); unset($_REQUEST['_locale']); Session::set('current_locale', 'en'); I18n::staticReset(); $this->assertEquals('en', I18n::getCurrentLocale(), 'Unable to set locale via session'); Session::set('current_locale', null); I18n::staticReset(); $this->assertEquals($currentLocale, I18n::getCurrentLocale(), 'Unable to restore default locale'); Session::end(); }
public function fire() { $clearAll = true; if ($this->input->getOption('config-only')) { $clearAll = false; Config::clearCache(); $this->info('Config cache cleared.'); } if ($this->input->getOption('meta-only')) { $clearAll = false; Db::clearMetadata(); $this->info('Model metadata cleared.'); } if ($this->input->getOption('locale-only')) { $clearAll = false; I18n::clearCache(); $this->info('Locale cache cleared.'); } if ($this->input->getOption('assets-only')) { $clearAll = false; View::clearAssetsCache(); $this->info('Assets cache cleared.'); } if ($clearAll) { Cache::flush(); Config::clearCache(); $this->info('Cache cleared.'); } Events::fire('cache:after_clear', $this); }