Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
User controller tests.
James Cole0967ff9c7f5f
diff --git a/app/tests/controllers/UserControllerTes.php b/app/tests/controllers/UserControllerTes.phpdeleted file mode 100644index 26a93f57f2..0000000000--- a/app/tests/controllers/UserControllerTes.php+++ /dev/null@@ -1,9 +0,0 @@-<?php--class UserControllerTest extends TestCase-{- public function testJemoeder()- {- $this->assertTrue(true);- }-}\ No newline at end of filediff --git a/app/tests/controllers/UserControllerTest.php b/app/tests/controllers/UserControllerTest.phpnew file mode 100644index 0000000000..9501d03b97--- /dev/null+++ b/app/tests/controllers/UserControllerTest.php@@ -0,0 +1,168 @@+<?php++use Mockery as m;+use Zizaco\FactoryMuff\Facade\FactoryMuff as f;+++/**+ * Class UserControllerTest+ */+class UserControllerTest extends TestCase+{+ protected $_user;+ protected $_users;+ protected $_email;++ public function setUp()+ {++ parent::setUp();+ Artisan::call('migrate');+ Artisan::call('db:seed');+ $this->_user = m::mock('User', 'Eloquent');+ $this->_users = $this->mock('Firefly\Storage\User\UserRepositoryInterface');+ $this->_email = $this->mock('Firefly\Helper\Email\EmailHelperInterface');++ }++ public function tearDown()+ {+ m::close();+ }++ public function testLogin()+ {+ $this->action('GET', 'UserController@login');+ $this->assertResponseOk();+ }++ public function testLogout()+ {+ $this->action('GET', 'UserController@logout');+ $this->assertResponseStatus(302);+ }++ public function testPostLogin()+ {+ $input = [+ 'email' => 'bla@bla',+ 'password' => 'something',+ ];++ Auth::shouldReceive('attempt')->with($input, false)->andReturn(true);++ $this->action('POST', 'UserController@postLogin', $input);+ $this->assertResponseStatus(302);+ }++ public function testPostLoginFails()+ {+ $input = [+ 'username' => 'bla@bla',+ 'password' => 'something',+ 'remindme' => 0+ ];+ $this->action('POST', 'UserController@postLogin');+ $this->assertResponseOk();+ }++ public function testPostRegister()+ {+ Config::set('auth.allow_register', true);+ $user = f::create('User');+ $this->_users->shouldReceive('register')->andReturn($user);+ $this->_email->shouldReceive('sendPasswordMail')->with($user);+ $this->action('POST', 'UserController@postRegister');+ $this->assertResponseOk();+ }++ public function testPostRegisterFails()+ {+ Config::set('auth.allow_register', true);+ $this->_users->shouldReceive('register')->andReturn(false);+ $this->action('POST', 'UserController@postRegister');+ $this->assertResponseOk();+ }++ public function testPostRegisterNotAllowed()+ {+ Config::set('auth.allow_register', false);+ $this->action('POST', 'UserController@postRegister');+ $this->assertResponseOk();+ }++ public function testPostRegisterVerify()+ {+ Config::set('auth.allow_register', true);+ Config::set('auth.verify_mail', true);+ $user = f::create('User');+ $this->_users->shouldReceive('register')->andReturn($user);+ $this->_email->shouldReceive('sendVerificationMail')->with($user);+ $this->action('POST', 'UserController@postRegister');+ $this->assertResponseOk();+ }++ public function testPostRemindme()+ {+ $user = f::create('User');+ Config::set('auth.verify_reset', true);+ $this->_users->shouldReceive('findByEmail')->andReturn($user);+ $this->_email->shouldReceive('sendResetVerification');+ $this->action('POST', 'UserController@postRemindme');+ $this->assertResponseOk();+ }++ public function testPostRemindmeNoVerify()+ {+ $user = f::create('User');+ Config::set('auth.verify_reset', false);+ $this->_users->shouldReceive('findByEmail')->andReturn($user);+ $this->_email->shouldReceive('sendPasswordMail');+ $this->action('POST', 'UserController@postRemindme');+ $this->assertResponseOk();+ }++ public function testPostRemindmeFails()+ {+ Config::set('auth.verify_reset', true);+ $this->_users->shouldReceive('findByEmail')->andReturn(false);+ $this->action('POST', 'UserController@postRemindme');+ $this->assertResponseOk();+ }++ public function testRegister()+ {+ $this->action('GET', 'UserController@register');+ $this->assertResponseOk();+ }++ public function testRegisterNotAllowed()+ {+ Config::set('auth.allow_register', false);+ $this->action('GET', 'UserController@register');+ $this->assertResponseOk();+ }++ public function testRemindme()+ {+ $this->action('GET', 'UserController@remindme');+ $this->assertResponseOk();+ }++ public function testReset()+ {+ $user = f::create('User');++ $this->_users->shouldReceive('findByReset')->andReturn($user);+ $this->_email->shouldReceive('sendPasswordMail');+ $this->action('GET', 'UserController@reset');+ $this->assertResponseOk();+ }++ public function testResetNoUser()+ {+ $this->_users->shouldReceive('findByReset')->andReturn(false);+ $this->action('GET', 'UserController@reset');+ $this->assertResponseOk();+ }+}\ No newline at end of file