/** * Testing the doPOST method. */ public function testDoPOST() { $config = ConfigProvider::getInstance(); $sessionProvider = $config->get('session.provider.name'); $session = SessionProviderFactory::getInstance($sessionProvider); $person = new Person(); $person->dropTable(); $front = new FrontController(); $controller = new LoginController(); $securityParams = $controller->generateSecurityFields(); $params = array('loginBut' => true, 'var1' => $securityParams[0], 'var2' => $securityParams[1], 'email' => $config->get('app.install.username'), 'password' => $config->get('app.install.password')); $request = new Request(array('method' => 'POST', 'URI' => '/login', 'params' => $params)); $response = $front->process($request); $this->assertEquals(301, $response->getStatus(), 'Testing the doPOST method during install'); $person->makeTable(); $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'); $params['password'] = '******'; $request = new Request(array('method' => 'POST', 'URI' => '/login', 'params' => $params)); $response = $front->process($request); $this->assertEquals(200, $response->getStatus(), 'Testing the doPOST with incorrect password'); $params = array('resetBut' => true, 'var1' => $securityParams[0], 'var2' => $securityParams[1], 'email' => '*****@*****.**'); $request = new Request(array('method' => 'POST', 'URI' => '/login', 'params' => $params)); $response = $front->process($request); $this->assertEquals(200, $response->getStatus(), 'Testing the doPOST during password reset'); $person->reload(); $this->assertNotEquals($person->get('password'), password_hash('passwordTest', PASSWORD_DEFAULT, ['cost' => 12]), 'Checking that the password has changed in the database'); }