mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-03 12:47:17 -06:00
Increase test coverage.
This commit is contained in:
parent
a50949e554
commit
bb1da31830
@ -219,12 +219,15 @@ class BudgetController extends Controller
|
||||
}
|
||||
|
||||
$journals = $repository->getJournals($budget, $repetition);
|
||||
$limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget);
|
||||
$subTitle = !is_null($repetition->id)
|
||||
?
|
||||
trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)])
|
||||
:
|
||||
e($budget->name);
|
||||
|
||||
if (is_null($repetition->id)) {
|
||||
$limits = $repository->getBudgetLimits($budget);
|
||||
$subTitle = e($budget->name);
|
||||
} else {
|
||||
$limits = [$repetition->budgetLimit];
|
||||
$subTitle = trans('firefly.budget_in_month', ['name' => $budget->name, 'month' => $repetition->startdate->formatLocalized($this->monthFormat)]);
|
||||
}
|
||||
|
||||
$journals->setPath('/budgets/show/' . $budget->id);
|
||||
|
||||
return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle'));
|
||||
|
@ -258,6 +258,29 @@ class BudgetControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\BudgetController::show
|
||||
*/
|
||||
public function testShowRepetition()
|
||||
{
|
||||
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||
$budget = $repetition->budgetLimit->budget;
|
||||
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$this->be($budget->user);
|
||||
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 20, 1);
|
||||
|
||||
Amount::shouldReceive('getCurrencyCode')->andReturn('x');
|
||||
Amount::shouldReceive('format')->andReturn('x');
|
||||
$repository->shouldReceive('getJournals')->andReturn($paginator);
|
||||
$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
|
||||
|
||||
|
||||
$this->call('GET', '/budgets/show/' . $budget->id . '/' . $repetition->id);
|
||||
$this->assertResponseOk();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\BudgetController::store
|
||||
*/
|
||||
|
@ -4,8 +4,6 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
||||
use FireflyIII\Helpers\Report\ReportHelper;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
use FireflyIII\Models\PiggyBankRepetition;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use Illuminate\Support\Collection;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
@ -48,13 +46,21 @@ class ReportHelperTest extends TestCase
|
||||
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
$cash = FactoryMuffin::create('FireflyIII\Models\AccountType');
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$account->user_id = $user->id;
|
||||
$account->account_type_id = $asset->id;
|
||||
$account->save();
|
||||
|
||||
}
|
||||
|
||||
$cashAccount = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$cashAccount->user_id = $user->id;
|
||||
$cashAccount->account_type_id = $cash->id;
|
||||
$cashAccount->save();
|
||||
|
||||
$this->be($user);
|
||||
/** @var AccountCollection $object */
|
||||
$object = $this->object->getAccountReport(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth(), false);
|
||||
|
@ -80,16 +80,23 @@ class ReportQueryTest extends TestCase
|
||||
]
|
||||
);
|
||||
|
||||
$amount = 100;
|
||||
if($i == 8) {
|
||||
$amount = 0; // at least one "empty" journal.
|
||||
}
|
||||
|
||||
// update both transactions
|
||||
$journal->transactions[0]->account_id = $account1->id;
|
||||
$journal->transactions[0]->amount = -100;
|
||||
$journal->transactions[0]->amount = $amount * -1;
|
||||
$journal->transactions[0]->save();
|
||||
|
||||
$journal->transactions[1]->account_id = $account2->id;
|
||||
$journal->transactions[1]->amount = 100;
|
||||
$journal->transactions[1]->amount = $amount;
|
||||
$journal->transactions[1]->save();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
$this->be($user);
|
||||
|
||||
@ -97,7 +104,7 @@ class ReportQueryTest extends TestCase
|
||||
$set = $this->object->expenseInPeriodCorrected($start, $end, false);
|
||||
|
||||
|
||||
$this->assertCount(10, $set);
|
||||
$this->assertCount(9, $set);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,13 +150,18 @@ class ReportQueryTest extends TestCase
|
||||
]
|
||||
);
|
||||
|
||||
$amount = 100;
|
||||
if($i == 8) {
|
||||
$amount = 0; // at least one "empty" journal.
|
||||
}
|
||||
|
||||
// update both transactions
|
||||
$journal->transactions[0]->account_id = $account1->id;
|
||||
$journal->transactions[0]->amount = -100;
|
||||
$journal->transactions[0]->amount = $amount * -1;
|
||||
$journal->transactions[0]->save();
|
||||
|
||||
$journal->transactions[1]->account_id = $account2->id;
|
||||
$journal->transactions[1]->amount = 100;
|
||||
$journal->transactions[1]->amount = $amount;
|
||||
$journal->transactions[1]->save();
|
||||
|
||||
}
|
||||
@ -157,7 +169,7 @@ class ReportQueryTest extends TestCase
|
||||
|
||||
$set = $this->object->expenseInPeriodCorrected($start, $end, true);
|
||||
|
||||
$this->assertCount(10, $set);
|
||||
$this->assertCount(9, $set);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,13 +270,18 @@ class ReportQueryTest extends TestCase
|
||||
]
|
||||
);
|
||||
|
||||
$amount = 100;
|
||||
if($i == 8) {
|
||||
$amount = 0; // at least one "empty" journal.
|
||||
}
|
||||
|
||||
// update both transactions
|
||||
$journal->transactions[0]->account_id = $account1->id;
|
||||
$journal->transactions[0]->amount = 100;
|
||||
$journal->transactions[0]->amount = $amount;
|
||||
$journal->transactions[0]->save();
|
||||
|
||||
$journal->transactions[1]->account_id = $account2->id;
|
||||
$journal->transactions[1]->amount = -100;
|
||||
$journal->transactions[1]->amount = $amount * -1;
|
||||
$journal->transactions[1]->save();
|
||||
|
||||
}
|
||||
@ -272,7 +289,7 @@ class ReportQueryTest extends TestCase
|
||||
|
||||
$set = $this->object->incomeInPeriodCorrected($start, $end, false);
|
||||
|
||||
$this->assertCount(10, $set);
|
||||
$this->assertCount(9, $set);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,13 +336,18 @@ class ReportQueryTest extends TestCase
|
||||
]
|
||||
);
|
||||
|
||||
$amount = 100;
|
||||
if($i == 8) {
|
||||
$amount = 0; // at least one "empty" journal.
|
||||
}
|
||||
|
||||
// update both transactions
|
||||
$journal->transactions[0]->account_id = $account1->id;
|
||||
$journal->transactions[0]->amount = -100;
|
||||
$journal->transactions[0]->amount = $amount * -1;
|
||||
$journal->transactions[0]->save();
|
||||
|
||||
$journal->transactions[1]->account_id = $account2->id;
|
||||
$journal->transactions[1]->amount = 100;
|
||||
$journal->transactions[1]->amount = $amount;
|
||||
$journal->transactions[1]->save();
|
||||
|
||||
}
|
||||
@ -333,7 +355,7 @@ class ReportQueryTest extends TestCase
|
||||
|
||||
$set = $this->object->incomeInPeriodCorrected($start, $end, true);
|
||||
|
||||
$this->assertCount(10, $set);
|
||||
$this->assertCount(9, $set);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user