public function testHasLocaleChanged()
 {
     $localeEn = uniqid('en:');
     $localeFr = uniqid('fr:');
     $session = $this->getMockSession();
     $session->expects($this->at(0))->method('get')->with('lunetics_locale')->will($this->returnValue($localeEn));
     $session->expects($this->at(1))->method('get')->with('lunetics_locale')->will($this->returnValue($localeFr));
     $localeSession = new LocaleSession($session);
     $this->assertFalse($localeSession->hasLocaleChanged($localeEn));
     $this->assertTrue($localeSession->hasLocaleChanged($localeEn));
 }
예제 #2
0
 /**
  * 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;
 }