public function testSetGetLocale() { $locale = uniqid('locale:'); $session = $this->getMockSession(); $session->expects($this->at(0))->method('set')->with('lunetics_locale', $locale); $session->expects($this->at(1))->method('get')->with('lunetics_locale', $locale)->will($this->returnValue($locale)); $localeSession = new LocaleSession($session); $localeSession->setLocale($locale); $this->assertEquals($locale, $localeSession->getLocale($locale)); }
public function testNotUpdateSessionSameLocale() { $this->session->setLocale('el'); $listener = $this->getLocaleUpdateListener(array('session')); $reflectionClass = new \ReflectionClass($listener); $property = $reflectionClass->getProperty('locale'); $property->setAccessible(true); $property->setValue($listener, 'el'); $this->assertFalse($listener->updateSession()); }
/** * Update Session section * * @return bool */ public function updateSession() { if ($this->session && $this->checkGuesser('session') && $this->session->hasLocaleChanged($this->locale)) { if (null !== $this->logger) { $this->logger->info(sprintf('Session var \'%s\' set to [ %s ]', $this->session->getSessionVar(), $this->locale)); } $this->session->setLocale($this->locale); return true; } return false; }