Skip to content

Firefly III: a personal finances manager

Fix some tests.

James Colecf34713518c9
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
index fd38a15187..afaa6b3b48 100755
--- a/app/Http/Controllers/Auth/LoginController.php
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -49,7 +49,7 @@ class LoginController extends Controller
*
* @var string
*/
- protected $redirectTo = '/home';
+ protected $redirectTo = '/';
/**
* Create a new controller instance.
@@ -71,10 +71,6 @@ class LoginController extends Controller
public function login(Request $request)
{
$this->validateLogin($request);
-
- // If the class is using the ThrottlesLogins trait, we can automatically throttle
- // the login attempts for this application. We'll key this by the username and
- // the IP address of the client making these requests into this application.
$lockedOut = $this->hasTooManyLoginAttempts($request);
if ($lockedOut) {
$this->fireLockoutEvent($request);
@@ -83,7 +79,7 @@ class LoginController extends Controller
}
$credentials = $this->credentials($request);
- $credentials['blocked'] = 0; // most not be blocked.
+ $credentials['blocked'] = 0; // must not be blocked.
if ($this->guard()->attempt($credentials, $request->has('remember'))) {
return $this->sendLoginResponse($request);
diff --git a/test.sh b/test.sh
index 53e5424121..b1e52c6932 100755
--- a/test.sh
+++ b/test.sh
@@ -11,8 +11,9 @@ resetestflag=''
testflag=''
coverageflag=''
acceptancetestclass=''
+verbalflag=''
-while getopts 'crta:' flag; do
+while getopts 'vcrta:' flag; do
case "${flag}" in
r)
resetestflag='true'
@@ -23,6 +24,9 @@ while getopts 'crta:' flag; do
c)
coverageflag='true'
;;
+ v)
+ verbalflag=' -v'
+ ;;
a)
acceptancetestclass=./tests/acceptance/$OPTARG
echo "Will only run acceptance test $OPTARG"
@@ -82,10 +86,10 @@ else
if [[ $coverageflag == "" ]]
then
echo "Must run PHPUnit without coverage"
- phpunit $acceptancetestclass
+ phpunit --stop-on-error $verbalflag $acceptancetestclass
else
echo "Must run PHPUnit with coverage"
- phpunit --configuration phpunit.coverage.xml $acceptancetestclass
+ phpunit --stop-on-error $verbalflag --configuration phpunit.coverage.xml $acceptancetestclass
fi
fi
diff --git a/tests/acceptance/Controllers/Auth/ConfirmationControllerTest.php b/tests/acceptance/Controllers/Auth/ConfirmationControllerTest.php
index 2e62488c0c..d8af8c900d 100644
--- a/tests/acceptance/Controllers/Auth/ConfirmationControllerTest.php
+++ b/tests/acceptance/Controllers/Auth/ConfirmationControllerTest.php
@@ -49,7 +49,7 @@ class ConfirmationControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn(null);
- FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->once()->andReturn($trueConfig);
+ FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->andReturn($trueConfig);
$this->be($this->user());
$this->call('GET', route('confirmation_error'));
$this->assertResponseStatus(200);
@@ -100,11 +100,11 @@ class ConfirmationControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['user_confirmed_last_mail', 0])->andReturn($timePreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference);
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn(null);
- FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->once()->andReturn($trueConfig);
+ FireflyConfig::shouldReceive('get')->withArgs(['must_confirm_account', false])->andReturn($trueConfig);
Preferences::shouldReceive('get')->withArgs(['user_confirmed', false])->andReturn($falsePreference);
// from event handler:
- Preferences::shouldReceive('setForUser')->withAnyArgs()->once();
+ Preferences::shouldReceive('setForUser')->withAnyArgs();
$this->be($this->user());
$this->call('GET', route('resend_confirmation'));
diff --git a/tests/acceptance/Controllers/Auth/ForgotPasswordControllerTest.php b/tests/acceptance/Controllers/Auth/ForgotPasswordControllerTest.php
deleted file mode 100644
index 65ebc3186f..0000000000
--- a/tests/acceptance/Controllers/Auth/ForgotPasswordControllerTest.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/**
- * ForgotPasswordControllerTest.php
- * Copyright (C) 2016 [email protected]
- *
- * This software may be modified and distributed under the terms of the
- * Creative Commons Attribution-ShareAlike 4.0 International License.
- *
- * See the LICENSE file for details.
- */
-
-namespace Auth;
-
-use TestCase;
-
-/**
- * Generated by PHPUnit_SkeletonGenerator on 2016-12-07 at 18:50:31.
- */
-class ForgotPasswordControllerTest 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();
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\Auth\ForgotPasswordController::broker
- * Implement testBroker().
- */
- public function testBroker()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\Auth\ForgotPasswordController::sendResetLinkEmail
- * Implement testSendResetLinkEmail().
- */
- public function testSendResetLinkEmail()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\Auth\ForgotPasswordController::showLinkRequestForm
- * Implement testShowLinkRequestForm().
- */
- public function testShowLinkRequestForm()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- */
- protected function tearDown()
- {
- }
-}
diff --git a/tests/acceptance/Controllers/Auth/LoginControllerTest.php b/tests/acceptance/Controllers/Auth/LoginControllerTest.php
index 605c0eefda..750e8ba28f 100644
--- a/tests/acceptance/Controllers/Auth/LoginControllerTest.php
+++ b/tests/acceptance/Controllers/Auth/LoginControllerTest.php
@@ -35,10 +35,12 @@ class LoginControllerTest extends TestCase
*/
public function testLogin()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->visit('/login')
+ ->type('[email protected]', 'email')
+ ->type('james', 'password')
+ ->press('Sign In')
+ ->seePageIs('/')
+ ->see('[email protected]');
}
/**
@@ -47,22 +49,9 @@ class LoginControllerTest extends TestCase
*/
public function testLogout()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\Auth\LoginController::redirectPath
- * Implement testRedirectPath().
- */
- public function testRedirectPath()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->visit('/logout')
+ ->seePageIs('/login')
+ ->see('Sign in to start your session');
}
/**
@@ -71,22 +60,9 @@ class LoginControllerTest extends TestCase
*/
public function testShowLoginForm()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\Auth\LoginController::username
- * Implement testUsername().
- */
- public function testUsername()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $this->visit('/')
+ ->seePageIs('/login')
+ ->see('Sign in to start your session');
}
/**
diff --git a/tests/acceptance/Controllers/HomeControllerTest.php b/tests/acceptance/Controllers/HomeControllerTest.php
index adeace0b8c..016a4762d6 100755
--- a/tests/acceptance/Controllers/HomeControllerTest.php
+++ b/tests/acceptance/Controllers/HomeControllerTest.php
@@ -11,10 +11,6 @@
*/
class HomeControllerTest extends TestCase
{
- public function displayError()
- {
- $this->assertTrue(true);
- }
/**
* @covers FireflyIII\Http\Controllers\HomeController::dateRange
@@ -80,7 +76,7 @@ class HomeControllerTest extends TestCase
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
- $this->call('GET', route('allRoutes'));
+ $this->call('GET', route('all-routes'));
$this->assertResponseStatus(200);
}
@@ -90,7 +86,7 @@ class HomeControllerTest extends TestCase
public function testTestFlash()
{
$this->be($this->user());
- $this->call('GET', route('testFlash'));
+ $this->call('GET', route('test-flash'));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertSessionHas('info');