From 355862025a3351a8397ddf4eb60671011d690ff8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 10 May 2015 13:06:02 +0200 Subject: [PATCH] Auth and password controller. --- .env.example | 3 +- .env.testing | 3 +- app/Http/Controllers/Auth/AuthController.php | 5 ++ .../Controllers/Auth/PasswordController.php | 2 +- config/mail.php | 2 +- tests/controllers/AuthControllerTest.php | 68 +++++++++++++++++++ 6 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 tests/controllers/AuthControllerTest.php diff --git a/.env.example b/.env.example index ce0218faf1..9259db3b04 100644 --- a/.env.example +++ b/.env.example @@ -15,4 +15,5 @@ EMAIL_SMTP= EMAIL_DRIVER=smtp EMAIL_USERNAME= EMAIL_PASSWORD= -ANALYTICS_ID= \ No newline at end of file +ANALYTICS_ID= +EMAIL_PRETEND=false \ No newline at end of file diff --git a/.env.testing b/.env.testing index 789c5a2b02..5443422bda 100644 --- a/.env.testing +++ b/.env.testing @@ -14,4 +14,5 @@ SESSION_DRIVER=array EMAIL_SMTP= EMAIL_USERNAME= EMAIL_PASSWORD= -ANALYTICS_ID=ABC \ No newline at end of file +ANALYTICS_ID=ABC +EMAIL_PRETEND=true \ No newline at end of file diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 079ec4dcf3..27c50adb65 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -38,6 +38,7 @@ class AuthController extends Controller * * @param \Illuminate\Contracts\Auth\Guard $auth * @param \Illuminate\Contracts\Auth\Registrar $registrar + * @codeCoverageIgnore * */ public function __construct(Guard $auth, Registrar $registrar) @@ -51,7 +52,9 @@ class AuthController extends Controller /** * Show the application login form. * + * @codeCoverageIgnore * @return \Illuminate\Http\Response + * */ public function getLogin() { @@ -73,7 +76,9 @@ class AuthController extends Controller $this->throwValidationException( $request, $validator ); + // @codeCoverageIgnoreStart } + // @codeCoverageIgnoreEnd $data = $request->all(); $data['password'] = bcrypt($data['password']); diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 2d9ebced35..907b514894 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -7,7 +7,7 @@ use Illuminate\Foundation\Auth\ResetsPasswords; /** * Class PasswordController - * + * @codeCoverageIgnore * @package FireflyIII\Http\Controllers\Auth */ class PasswordController extends Controller diff --git a/config/mail.php b/config/mail.php index 3841db29c9..31c5eaa8a2 100644 --- a/config/mail.php +++ b/config/mail.php @@ -119,6 +119,6 @@ return [ | */ - 'pretend' => false, + 'pretend' => env('EMAIL_PRETEND', false), ]; diff --git a/tests/controllers/AuthControllerTest.php b/tests/controllers/AuthControllerTest.php new file mode 100644 index 0000000000..abe9fa9e44 --- /dev/null +++ b/tests/controllers/AuthControllerTest.php @@ -0,0 +1,68 @@ + 'test@example.com', + 'password' => 'onetwothree', + 'password_confirmation' => 'onetwothree', + '_token' => 'replaceMe' + ]; + $this->call('POST', '/auth/register', $data); + $this->assertResponseStatus(302); + $this->assertSessionHas('success'); + } + + public function testPostRegisterFails() + { + + $data = [ + 'email' => 'test@example.com', + 'password' => 'onetwothree', + 'password_confirmation' => 'onetwofour', + '_token' => 'replaceMe' + ]; + $this->call('POST', '/auth/register', $data); + $this->assertResponseStatus(302); + + + } + +}