be($user); $this->call('GET', '/profile/change-password'); $this->assertResponseOk(); } /** * @covers FireflyIII\Http\Controllers\ProfileController::deleteAccount */ public function testDeleteAccount() { $user = FactoryMuffin::create('FireflyIII\User'); $this->be($user); $this->call('GET', '/profile/delete-account'); $this->assertResponseOk(); } /** * @covers FireflyIII\Http\Controllers\ProfileController::index */ public function testIndex() { $user = FactoryMuffin::create('FireflyIII\User'); $this->be($user); $this->call('GET', '/profile'); $this->assertResponseOk(); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword * @covers FireflyIII\Http\Controllers\ProfileController::validatePassword */ public function testPostChangePassword() { $user = FactoryMuffin::create('FireflyIII\User'); $user->password = bcrypt('current'); $user->save(); $this->be($user); $post = [ 'current_password' => 'current', 'new_password' => 'something', 'new_password_confirmation' => 'something', '_token' => 'replaceMe' ]; $this->call('POST', '/profile/change-password', $post); $this->assertRedirectedToRoute('profile'); $this->assertSessionHas('success', 'Password changed!'); $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword * @covers FireflyIII\Http\Controllers\ProfileController::validatePassword */ public function testPostChangePasswordInvalidCurrent() { $user = FactoryMuffin::create('FireflyIII\User'); $user->password = bcrypt('current'); $user->save(); $this->be($user); $post = [ 'current_password' => 'currentWrong', 'new_password' => 'something', 'new_password_confirmation' => 'something', '_token' => 'replaceMe' ]; $this->call('POST', '/profile/change-password', $post); $this->assertRedirectedToRoute('change-password'); $this->assertSessionHas('error', 'Invalid current password!'); $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postChangePassword * @covers FireflyIII\Http\Controllers\ProfileController::validatePassword */ public function testPostChangePasswordNoNewPassword() { $user = FactoryMuffin::create('FireflyIII\User'); $user->password = bcrypt('current'); $user->save(); $this->be($user); $post = [ 'current_password' => 'current', 'new_password' => 'current', 'new_password_confirmation' => 'current', '_token' => 'replaceMe' ]; $this->call('POST', '/profile/change-password', $post); $this->assertSessionHas('error', 'The idea is to change your password.'); $this->assertResponseStatus(302); $this->assertRedirectedToRoute('change-password'); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount */ public function testPostDeleteAccount() { $user = FactoryMuffin::create('FireflyIII\User'); $user->password = bcrypt('current'); $user->save(); $this->be($user); $post = [ 'password' => 'current', '_token' => 'replaceMe' ]; $this->call('POST', '/profile/delete-account', $post); $this->assertRedirectedToRoute('index'); $this->assertResponseStatus(302); } /** * @covers FireflyIII\Http\Controllers\ProfileController::postDeleteAccount */ public function testPostDeleteAccountInvalidPassword() { $user = FactoryMuffin::create('FireflyIII\User'); $user->password = bcrypt('current'); $user->save(); $this->be($user); $post = [ 'password' => 'currentXX', '_token' => 'replaceMe' ]; $this->call('POST', '/profile/delete-account', $post); $this->assertRedirectedToRoute('delete-account'); $this->assertSessionHas('error', 'Invalid password!'); $this->assertResponseStatus(302); } }