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
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\User;
use Illuminate\Database\Seeder;
@@ -22,6 +27,15 @@ class TestDataSeeder extends Seeder
// create asset accounts for user #1.
$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()
{
$response = $this->call('GET', '/login');
$this->assertSessionHas('isLoggedIn', 'yes');
$this->assertEquals(200, $response->status());
}
@@ -79,7 +78,11 @@ class AuthControllerTest extends TestCase
];
$response = $this->call('POST', '/login', $args);
$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');
}
/**
* @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
* @todo Implement testRegister().
*/
public function testRegister()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'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.'
);
$response = $this->call('GET', '/register');
$this->assertEquals(200, $response->status());
}
}

View File

@@ -12,124 +12,17 @@
*/
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
* @todo Implement testSendResetLinkEmail().
*/
public function testSendResetLinkEmail()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$args = [
'email' => 'thegrumpydictator@gmail.com',
'_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
* @todo Implement testExpenseAccounts().
*/
public function testExpenseAccounts()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$response = $this->call('GET', '/chart/account/expense');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::frontpage
* @todo Implement testFrontpage().
*/
public function testFrontpage()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$response = $this->call('GET', '/chart/account/frontpage');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::report
* @todo Implement testReport().
*/
public function testReport()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$response = $this->call('GET', '/chart/account/report/default/20160101/20160131/1');
$this->assertEquals(200, $response->status());
}
/**
* @covers FireflyIII\Http\Controllers\Chart\AccountController::single
* @todo Implement testSingle().
*/
public function testSingle()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$response = $this->call('GET', '/chart/account/1');
$this->assertEquals(200, $response->status());
}
}

View File

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

View File

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