Пример #1
0
 /**
  * Testing the doGET method.
  */
 public function testDoGET()
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $front = new FrontController();
     $controller = new LogoutController();
     $securityParams = $controller->generateSecurityFields();
     $person = $this->createPersonObject('logintest');
     $person->save();
     $params = array('loginBut' => true, 'var1' => $securityParams[0], 'var2' => $securityParams[1], 'email' => '*****@*****.**', 'password' => 'passwordTest');
     $request = new Request(array('method' => 'POST', 'URI' => '/login', 'params' => $params));
     $response = $front->process($request);
     $this->assertEquals(301, $response->getStatus(), 'Testing the doPOST with correct password');
     $this->assertTrue($session->get('currentUser') instanceof Person, 'Testing that the user is logged in');
     $request = new Request(array('method' => 'GET', 'URI' => '/logout'));
     $response = $front->process($request);
     $this->assertEquals(200, $response->getStatus(), 'Testing the doGET method');
     $this->assertEquals('text/html', $response->getHeader('Content-Type'), 'Testing the doGET method');
     $this->assertFalse($session->get('currentUser'), 'Testing that the user is no longer logged in');
 }