Code cleanup.

This commit is contained in:
James Cole 2015-05-25 19:58:13 +02:00
parent fbe4435599
commit 0ef6d2f91a
18 changed files with 109 additions and 70 deletions

View File

@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
* Class AppServiceProvider
*
* @package FireflyIII\Providers
*
* @codeCoverageIgnore
*/
class AppServiceProvider extends ServiceProvider
{

View File

@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
/**
* Class BusServiceProvider
*
* @codeCoverageIgnore
*
* @package FireflyIII\Providers
*/
class BusServiceProvider extends ServiceProvider

View File

@ -6,6 +6,8 @@ use Illuminate\Support\ServiceProvider;
* Class ConfigServiceProvider
*
* @package FireflyIII\Providers
* @codeCoverageIgnore
*
*/
class ConfigServiceProvider extends ServiceProvider
{

View File

@ -23,6 +23,7 @@ use Validator;
* Class FireflyServiceProvider
*
* @package FireflyIII\Providers
* @codeCoverageIgnore
*/
class FireflyServiceProvider extends ServiceProvider
{

View File

@ -7,6 +7,7 @@ use Illuminate\Routing\Router;
* Class RouteServiceProvider
*
* @package FireflyIII\Providers
* @codeCoverageIgnore
*/
class RouteServiceProvider extends ServiceProvider
{

View File

@ -8,6 +8,7 @@ use Illuminate\Support\ServiceProvider;
/**
* Class TestingServiceProvider
*
* @codeCoverageIgnore
* @package FireflyIII\Providers
*/
class TestingServiceProvider extends ServiceProvider

View File

@ -13,18 +13,6 @@ use Illuminate\Support\Collection;
interface PiggyBankRepositoryInterface
{
/**
* @return Collection
*/
public function getPiggyBanks();
/**
* @param PiggyBank $piggyBank
*
* @return Collection
*/
public function getEvents(PiggyBank $piggyBank);
/**
* @param PiggyBank $piggyBank
* @param $amount
@ -33,6 +21,13 @@ interface PiggyBankRepositoryInterface
*/
public function createEvent(PiggyBank $piggyBank, $amount);
/**
* @param PiggyBank $piggyBank
*
* @return bool
*/
public function destroy(PiggyBank $piggyBank);
/**
* @param PiggyBank $piggyBank
*
@ -43,9 +38,14 @@ interface PiggyBankRepositoryInterface
/**
* @param PiggyBank $piggyBank
*
* @return bool
* @return Collection
*/
public function destroy(PiggyBank $piggyBank);
public function getEvents(PiggyBank $piggyBank);
/**
* @return Collection
*/
public function getPiggyBanks();
/**
* Set all piggy banks to order 0.

View File

@ -57,6 +57,24 @@ class BudgetControllerTest extends TestCase
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::amount
*/
public function testAmountZero()
{
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$limitRepetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
$budget = $limitRepetition->budgetlimit->budget;
$this->be($budget->user);
$today = new Carbon;
$this->session(['start' => $today]);
$repository->shouldReceive('updateLimitAmount')->once()->andReturn($limitRepetition);
$this->call('POST', '/budgets/amount/' . $budget->id, ['amount' => 0, '_token' => 'replaceme']);
$this->assertResponseOk();
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::create
*/
@ -128,12 +146,13 @@ class BudgetControllerTest extends TestCase
$collection = new Collection;
$collection->push($budget);
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
$repository->shouldReceive('getActiveBudgets')->once()->andReturn($collection);
$repository->shouldReceive('getInactiveBudgets')->once()->andReturn($collection);
$repository->shouldReceive('cleanupBudgets')->once();
$repository->shouldReceive('spentInPeriodCorrected')->once();
$repository->shouldReceive('getCurrentRepetition')->once();
$repository->shouldReceive('getCurrentRepetition')->once()->andReturn($repetition);
Amount::shouldReceive('getCurrencySymbol')->andReturn('x');
Amount::shouldReceive('format')->andReturn('x');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');

View File

@ -38,6 +38,7 @@ class HelpControllerTest extends TestCase
/**
* Everything present and accounted for, and in cache:
*
* @covers FireflyIII\Http\Controllers\HelpController::show
*/
public function testGetHelpText()
@ -59,6 +60,7 @@ class HelpControllerTest extends TestCase
/**
* Everything present and accounted for, but not cached
*
* @covers FireflyIII\Http\Controllers\HelpController::show
*/
public function testGetHelpTextNoCache()
@ -82,6 +84,7 @@ class HelpControllerTest extends TestCase
/**
* No such route.
*
* @covers FireflyIII\Http\Controllers\HelpController::show
*/
public function testGetHelpTextNoRoute()

View File

@ -360,16 +360,16 @@ class TransactionControllerTest extends TestCase
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$this->be($account->user);
$account2->user_id = $account->user_id;
$account->account_type_id = $asset->id;
$account2->account_type_id = $asset->id;
$piggy->account_id = $account->id;
$piggy->account_id = $account->id;
$account->save();
$account2->save();
$piggy->save();

View File

@ -233,16 +233,20 @@ class ReportHelperTest extends TestCase
$left->save();
// save meta for account:
AccountMeta::create([
'account_id' => $left->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]);
AccountMeta::create([
'account_id' => $right->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]);
AccountMeta::create(
[
'account_id' => $left->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
AccountMeta::create(
[
'account_id' => $right->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
for ($i = 0; $i < 5; $i++) {
@ -292,16 +296,20 @@ class ReportHelperTest extends TestCase
$right->account_type_id = $asset->id;
// save meta for account:
AccountMeta::create([
'account_id' => $left->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]);
AccountMeta::create([
'account_id' => $right->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]);
AccountMeta::create(
[
'account_id' => $left->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
AccountMeta::create(
[
'account_id' => $right->id,
'name' => 'accountRole',
'data' => 'defaultAsset'
]
);
$right->save();
$left->save();

View File

@ -76,7 +76,7 @@ class AccountModelTest extends TestCase
'name' => 'Some new account',
'account_type_id' => $account->account_type_id,
'user_id' => $account->user_id,
'active' => 1,
'active' => 1,
];
$result = Account::firstOrCreateEncrypted($search);
@ -125,7 +125,7 @@ class AccountModelTest extends TestCase
'name' => 'Some new account',
'account_type_id' => $account->account_type_id,
'user_id' => $account->user_id,
'active' => 1,
'active' => 1,
];
$result = Account::firstOrNullEncrypted($search);

View File

@ -38,24 +38,6 @@ class TagModelTest extends TestCase
parent::tearDown();
}
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncryptedNew()
{
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$search = [
'tagMode' => 'something',
'tag' => 'Something else',
'user_id' => $tag->user_id,
];
$result = Tag::firstOrCreateEncrypted($search);
$this->assertNotEquals($tag->id, $result->id);
}
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
@ -74,4 +56,22 @@ class TagModelTest extends TestCase
$this->assertEquals($tag->id, $result->id);
}
/**
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testFirstOrCreateEncryptedNew()
{
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$search = [
'tagMode' => 'something',
'tag' => 'Something else',
'user_id' => $tag->user_id,
];
$result = Tag::firstOrCreateEncrypted($search);
$this->assertNotEquals($tag->id, $result->id);
}
}

View File

@ -324,7 +324,7 @@ class TransactionJournalModelTest extends TestCase
// make accounts
$expense = FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
$asset = FactoryMuffin::create('FireflyIII\Models\Account');
Transaction::create(['account_id' => $expense->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => 300]);
Transaction::create(['account_id' => $asset->id, 'transaction_journal_id' => $withdrawal->id, 'amount' => -300]);

View File

@ -58,8 +58,8 @@ class AccountRepositoryTest extends TestCase
public function testDestroy()
{
// create account:
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$accountId = $account->id;
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$accountId = $account->id;
$this->be($account->user);

View File

@ -43,8 +43,8 @@ class BillRepositoryTest extends TestCase
$end = Carbon::now()->endOfMonth();
// payment:
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $start;
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->date = $start;
$journal->bill_id = $bill->id;
$journal->save();

View File

@ -103,7 +103,7 @@ class CategoryRepositoryTest extends TestCase
$journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
/** @var Category $category */
$category = FactoryMuffin::create('FireflyIII\Models\Category');
$category = FactoryMuffin::create('FireflyIII\Models\Category');
$journal1->user_id = $user->id;
$journal1->date = new Carbon('2015-02-11');
@ -113,7 +113,7 @@ class CategoryRepositoryTest extends TestCase
$journal2->date = new Carbon('2015-02-11');
$journal2->transaction_type_id = $type->id;
$category->user_id = $user->id;
$category->user_id = $user->id;
$category->transactionjournals()->save($journal1);
$category->transactionjournals()->save($journal2);

View File

@ -58,7 +58,7 @@ class TagRepositoryTest extends TestCase
public function testConnectBalancingOneDeposit()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@ -85,7 +85,7 @@ class TagRepositoryTest extends TestCase
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@ -156,7 +156,7 @@ class TagRepositoryTest extends TestCase
FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
@ -203,7 +203,7 @@ class TagRepositoryTest extends TestCase
FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
@ -248,7 +248,7 @@ class TagRepositoryTest extends TestCase
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');