Implemented some tests.

This commit is contained in:
James Cole
2016-01-20 09:15:33 +01:00
parent ebdb1a8836
commit 2faf84780f
7 changed files with 176 additions and 246 deletions

View File

@@ -1,7 +1,12 @@
<?php <?php
use Carbon\Carbon;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@@ -22,6 +27,15 @@ class TestDataSeeder extends Seeder
// create asset accounts for user #1. // create asset accounts for user #1.
$this->createAssetAccounts($user); $this->createAssetAccounts($user);
// create a bills for user #1
$this->createBills($user);
// create some budgets for user #1
$this->createBudgets($user);
// create some categories for user #1
$this->createCategories($user);
} }
/** /**
@@ -58,4 +72,79 @@ class TestDataSeeder extends Seeder
} }
} }
/**
* @param User $user
*/
private function createBills(User $user)
{
Bill::create(
[
'name' => 'Rent',
'match' => 'rent,land,lord',
'amount_min' => 795,
'amount_max' => 805,
'user_id' => $user->id,
'date' => '2015-01-01',
'active' => 1,
'automatch' => 1,
'repeat_freq' => 'monthly',
'skip' => 0,
]
);
Bill::create(
[
'name' => 'Health insurance',
'match' => 'zilveren,kruis,health',
'amount_min' => 120,
'amount_max' => 140,
'user_id' => $user->id,
'date' => '2015-01-01',
'active' => 1,
'automatch' => 1,
'repeat_freq' => 'monthly',
'skip' => 0,
]
);
}
/**
* @param $user
*/
private function createBudgets($user)
{
$set = [
Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]),
Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]),
];
$current = new Carbon;
/** @var Budget $budget */
foreach ($set as $budget) {
// some budget limits:
$start = clone $current;
$end = clone $current;
$start->startOfMonth();
$end->endOfMonth();
BudgetLimit::create(
[
'budget_id' => $budget->id,
'startdate' => $start->format('Y-m-d'),
'amount' => 500,
'repeats' => 0,
'repeat_freq' => 'monthly',
]
);
}
}
/**
* @param User $user
*/
private function createCategories(User $user)
{
Category::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]);
Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
}
} }

View File

@@ -47,7 +47,6 @@ class AuthControllerTest extends TestCase
public function testLogin() public function testLogin()
{ {
$response = $this->call('GET', '/login'); $response = $this->call('GET', '/login');
$this->assertSessionHas('isLoggedIn', 'yes');
$this->assertEquals(200, $response->status()); $this->assertEquals(200, $response->status());
} }
@@ -79,7 +78,11 @@ class AuthControllerTest extends TestCase
]; ];
$response = $this->call('POST', '/login', $args); $response = $this->call('POST', '/login', $args);
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
$this->assertSessionHas('isLoggedIn', 'yes');
$response = $this->call('GET', '/');
$this->assertEquals(200, $response->status());
} }
@@ -98,51 +101,12 @@ class AuthControllerTest extends TestCase
$this->assertSessionHas('start'); $this->assertSessionHas('start');
} }
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::redirectPath
* @todo Implement testRedirectPath().
*/
public function testRedirectPath()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/** /**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::register * @covers FireflyIII\Http\Controllers\Auth\AuthController::register
* @todo Implement testRegister().
*/ */
public function testRegister() public function testRegister()
{ {
// Remove the following lines when you implement this test. $response = $this->call('GET', '/register');
$this->markTestIncomplete( $this->assertEquals(200, $response->status());
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\AuthController::showLoginForm
* @todo Implement testShowLoginForm().
*/
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\AuthController::showRegistrationForm
* @todo Implement testShowRegistrationForm().
*/
public function testShowRegistrationForm()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
} }
} }

View File

@@ -12,124 +12,17 @@
*/ */
class PasswordControllerTest extends TestCase class PasswordControllerTest extends TestCase
{ {
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::getBroker
* @todo Implement testGetBroker().
*/
public function testGetBroker()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::getEmail
* @todo Implement testGetEmail().
*/
public function testGetEmail()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::getReset
* @todo Implement testGetReset().
*/
public function testGetReset()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::postEmail
* @todo Implement testPostEmail().
*/
public function testPostEmail()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::postReset
* @todo Implement testPostReset().
*/
public function testPostReset()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::redirectPath
* @todo Implement testRedirectPath().
*/
public function testRedirectPath()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::reset
* @todo Implement testReset().
*/
public function testReset()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/** /**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::sendResetLinkEmail * @covers FireflyIII\Http\Controllers\Auth\PasswordController::sendResetLinkEmail
* @todo Implement testSendResetLinkEmail().
*/ */
public function testSendResetLinkEmail() public function testSendResetLinkEmail()
{ {
// Remove the following lines when you implement this test. $args = [
$this->markTestIncomplete( 'email' => 'thegrumpydictator@gmail.com',
'This test has not been implemented yet.' '_token' => Session::token(),
); ];
$response = $this->call('POST', '/password/email', $args);
$this->assertEquals(302, $response->status());
} }
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::showLinkRequestForm
* @todo Implement testShowLinkRequestForm().
*/
public function testShowLinkRequestForm()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers FireflyIII\Http\Controllers\Auth\PasswordController::showResetForm
* @todo Implement testShowResetForm().
*/
public function testShowResetForm()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
} }

View File

@@ -14,49 +14,45 @@ class ChartAccountControllerTest extends TestCase
{ {
/** /**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts * @covers FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts
* @todo Implement testExpenseAccounts().
*/ */
public function testExpenseAccounts() public function testExpenseAccounts()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/account/expense');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::frontpage * @covers FireflyIII\Http\Controllers\Chart\AccountController::frontpage
* @todo Implement testFrontpage().
*/ */
public function testFrontpage() public function testFrontpage()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/account/frontpage');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::report * @covers FireflyIII\Http\Controllers\Chart\AccountController::report
* @todo Implement testReport().
*/ */
public function testReport() public function testReport()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/account/report/default/20160101/20160131/1');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::single * @covers FireflyIII\Http\Controllers\Chart\AccountController::single
* @todo Implement testSingle().
*/ */
public function testSingle() public function testSingle()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/account/1');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
} }

View File

@@ -15,25 +15,23 @@ class ChartBillControllerTest extends TestCase
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BillController::frontpage * @covers FireflyIII\Http\Controllers\Chart\BillController::frontpage
* @todo Implement testFrontpage().
*/ */
public function testFrontpage() public function testFrontpage()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/bill/frontpage');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BillController::single * @covers FireflyIII\Http\Controllers\Chart\BillController::single
* @todo Implement testSingle().
*/ */
public function testSingle() public function testSingle()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/bill/1');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
} }

View File

@@ -15,61 +15,58 @@ class ChartBudgetControllerTest extends TestCase
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budget * @covers FireflyIII\Http\Controllers\Chart\BudgetController::budget
* @todo Implement testBudget().
*/ */
public function testBudget() public function testBudget()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/budget/1');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit * @covers FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit
* @todo Implement testBudgetLimit().
*/ */
public function testBudgetLimit() public function testBudgetLimit()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/budget/1/1');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::frontpage * @covers FireflyIII\Http\Controllers\Chart\BudgetController::frontpage
* @todo Implement testFrontpage().
*/ */
public function testFrontpage() public function testFrontpage()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/budget/frontpage');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::multiYear * @covers FireflyIII\Http\Controllers\Chart\BudgetController::multiYear
* @todo Implement testMultiYear().
*/ */
public function testMultiYear() public function testMultiYear()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/budget/multi-year/default/20150101/20160101/1/1');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\BudgetController::year * @covers FireflyIII\Http\Controllers\Chart\BudgetController::year
* @todo Implement testYear().
*/ */
public function testYear() public function testYear()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/budget/year/default/20150101/201512031/1');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
} }

View File

@@ -15,85 +15,78 @@ class ChartCategoryControllerTest extends TestCase
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::all * @covers FireflyIII\Http\Controllers\Chart\CategoryController::all
* @todo Implement testAll().
*/ */
public function testAll() public function testAll()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/category/1/all');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::currentPeriod * @covers FireflyIII\Http\Controllers\Chart\CategoryController::currentPeriod
* @todo Implement testCurrentPeriod().
*/ */
public function testCurrentPeriod() public function testCurrentPeriod()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/category/1/period');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::earnedInPeriod * @covers FireflyIII\Http\Controllers\Chart\CategoryController::earnedInPeriod
* @todo Implement testEarnedInPeriod().
*/ */
public function testEarnedInPeriod() public function testEarnedInPeriod()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/category/earned-in-period/default/20150101/20151231/1');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::frontpage * @covers FireflyIII\Http\Controllers\Chart\CategoryController::frontpage
* @todo Implement testFrontpage().
*/ */
public function testFrontpage() public function testFrontpage()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/category/frontpage');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::multiYear * @covers FireflyIII\Http\Controllers\Chart\CategoryController::multiYear
* @todo Implement testMultiYear().
*/ */
public function testMultiYear() public function testMultiYear()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/category/multi-year/default/20150101/20151231/1/1');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod * @covers FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod
* @todo Implement testSpecificPeriod().
*/ */
public function testSpecificPeriod() public function testSpecificPeriod()
{ {
// Remove the following lines when you implement this test. $this->be($this->user());
$this->markTestIncomplete( $response = $this->call('GET', '/chart/category/1/period/20150101');
'This test has not been implemented yet.'
); $this->assertEquals(200, $response->status());
} }
/** /**
* @covers FireflyIII\Http\Controllers\Chart\CategoryController::spentInPeriod * @covers FireflyIII\Http\Controllers\Chart\CategoryController::spentInPeriod
* @todo Implement testSpentInPeriod().
*/ */
public function testSpentInPeriod() public function testSpentInPeriod()
{ {
// Remove the following lines when you implement this test. // $this->be($this->user());
$this->markTestIncomplete( // $response = $this->call('GET', '/chart/category/spent-in-period/default/20150101/20151231/1');
'This test has not been implemented yet.' // $this->assertEquals(200, $response->status());
); $this->markTestSkipped('Skipped because sqlite does not support DATE_FORMAT.');
} }
} }