mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expanded test coverage.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
@@ -72,6 +72,7 @@ class ProfileControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postChangePassword
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::validatePassword
|
||||
*/
|
||||
public function testPostChangePassword()
|
||||
{
|
||||
@@ -92,6 +93,52 @@ class ProfileControllerTest extends TestCase
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postChangePassword
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::validatePassword
|
||||
*/
|
||||
public function testPostChangePasswordNotCorrect()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('changePassword');
|
||||
|
||||
$data = [
|
||||
'current_password' => 'james3',
|
||||
'new_password' => 'james2',
|
||||
'new_password_confirmation' => 'james2',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('profile.change-password.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postChangePassword
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::validatePassword
|
||||
*/
|
||||
public function testPostChangePasswordSameNew()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('changePassword');
|
||||
|
||||
$data = [
|
||||
'current_password' => 'james',
|
||||
'new_password' => 'james',
|
||||
'new_password_confirmation' => 'james',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('profile.change-password.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
|
||||
*/
|
||||
@@ -101,7 +148,7 @@ class ProfileControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy');
|
||||
$repository->shouldReceive('destroy')->once();
|
||||
$data = [
|
||||
'password' => 'james',
|
||||
];
|
||||
@@ -111,4 +158,23 @@ class ProfileControllerTest extends TestCase
|
||||
$response->assertRedirect(route('index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
|
||||
*/
|
||||
public function testPostDeleteAccountWrong()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$data = [
|
||||
'password' => 'james2',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('profile.delete-account.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('profile.delete-account'));
|
||||
$response->assertSessionHas('error');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user