public function testFirst()
{
// Symfony forms need a CSRF token so we have to mock this too
$this->removeCSRF($this->getApp());
// Because we have users in the database this should exit at first attempt
$this->setRequest(Request::create('/bolt/userfirst'));
$response = $this->controller()->first($this->getRequest());
$this->assertEquals('/bolt', $response->getTargetUrl());
// Now we delete the users
$this->getService('db')->executeQuery('DELETE FROM bolt_users;');
$this->getService('users')->users = [];
$this->setRequest(Request::create('/bolt/userfirst'));
$response = $this->controller()->first($this->getRequest());
$context = $response->getContext();
$this->assertEquals('create', $context['context']['kind']);
// This block attempts to create the user
$request = Request::create('/bolt/userfirst', 'POST', ['form' => ['username' => 'admin', 'email' => '[email protected]', 'displayname' => 'Admin', 'password' => 'password', 'password_confirmation' => 'password', '_token' => 'xyz']]);
$this->setRequest($request);
$this->getApp()['request_stack']->push($request);
$response = $this->controller()->first($this->getRequest());
$this->assertEquals('/bolt', $response->getTargetUrl());
}