示例#1
0
 public function testOnKernelResponseWithoutSession()
 {
     $this->securityContext->setToken(new UsernamePasswordToken('test1', 'pass1', 'phpunit'));
     $request = new Request();
     $event = new FilterResponseEvent($this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST, new Response());
     $listener = new ContextListener($this->securityContext, array(), 'session');
     $listener->onKernelResponse($event);
     $this->assertFalse($request->hasSession());
 }
 protected function runSessionOnKernelResponse($newToken, $original = null)
 {
     $session = new Session(new MockArraySessionStorage());
     if ($original !== null) {
         $session->set('_security_session', $original);
     }
     $tokenStorage = new TokenStorage();
     $tokenStorage->setToken($newToken);
     $request = new Request();
     $request->setSession($session);
     $request->cookies->set('MOCKSESSID', true);
     $event = new FilterResponseEvent($this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST, new Response());
     $listener = new ContextListener($tokenStorage, array(), 'session', null, new EventDispatcher());
     $listener->onKernelResponse($event);
     return $session;
 }