Skip to content

Firefly III: a personal finances manager

Auth and password controller.

James Cole355862025a33
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 @@
+<?php
+use League\FactoryMuffin\Facade as FactoryMuffin;
+
+/**
+ * Class AuthControllerTest
+ */
+class AuthControllerTest extends TestCase
+{
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ FactoryMuffin::create('FireflyIII\User');
+ }
+
+ /**
+ * This method is called before the first test of this test class is run.
+ *
+ * @since Method available since Release 3.4.0
+ */
+ public static function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ public function tearDown()
+ {
+ parent::tearDown();
+ }
+
+ public function testPostRegister()
+ {
+
+ $data = [
+ 'email' => '[email protected]',
+ 'password' => 'onetwothree',
+ 'password_confirmation' => 'onetwothree',
+ '_token' => 'replaceMe'
+ ];
+ $this->call('POST', '/auth/register', $data);
+ $this->assertResponseStatus(302);
+ $this->assertSessionHas('success');
+ }
+
+ public function testPostRegisterFails()
+ {
+
+ $data = [
+ 'email' => '[email protected]',
+ 'password' => 'onetwothree',
+ 'password_confirmation' => 'onetwofour',
+ '_token' => 'replaceMe'
+ ];
+ $this->call('POST', '/auth/register', $data);
+ $this->assertResponseStatus(302);
+
+
+ }
+
+}