firefly-iii/tests/acceptance/Controllers/Auth/AuthControllerTest.php
2016-01-20 14:23:50 +01:00

113 lines
3.0 KiB
PHP

<?php
/**
* AuthControllerTest.php
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:40:28.
*/
class AuthControllerTest extends TestCase
{
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::getLogin
*/
public function testGetLogin()
{
$response = $this->call('GET', '/login');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::getLogout
*/
public function testGetLogout()
{
$this->be($this->user());
$response = $this->call('GET', '/logout');
$this->assertEquals(302, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::getRegister
*/
public function testGetRegister()
{
$response = $this->call('GET', '/register');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::login
*/
public function testLogin()
{
$response = $this->call('GET', '/login');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::logout
*/
public function testLogout()
{
$this->be($this->user());
$response = $this->call('GET', '/logout');
$this->assertEquals(302, $response->status());
// index should now redirect:
$response = $this->call('GET', '/');
$this->assertEquals(302, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::postLogin
*/
public function testPostLogin()
{
$args = [
'email' => 'thegrumpydictator@gmail.com',
'password' => 'james',
'remember' => 1,
'_token' => Session::token(),
];
$response = $this->call('POST', '/login', $args);
$this->assertEquals(302, $response->status());
$response = $this->call('GET', '/');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::postRegister
*/
public function testPostRegister()
{
$args = [
'email' => 'thegrumpydictator+test@gmail.com',
'password' => 'james123',
'password_confirmation' => 'james123',
'_token' => Session::token(),
];
$response = $this->call('POST', '/register', $args);
$this->assertEquals(302, $response->status());
$this->assertSessionHas('start');
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::register
*/
public function testRegister()
{
$response = $this->call('GET', '/register');
$this->assertEquals(200, $response->status());
}
}