mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 09:51:40 +00:00
Expand tests.
This commit is contained in:
@@ -57,10 +57,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAccountReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(AcYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
$generator->shouldReceive('setStartDate')->once();
|
||||
$generator->shouldReceive('setEndDate')->once();
|
||||
$generator->shouldReceive('setAccounts')->once();
|
||||
@@ -77,6 +81,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testAuditReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(AYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@@ -96,6 +103,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudgetReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(BYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@@ -115,6 +125,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testCategoryReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(CYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@@ -134,6 +147,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testDefaultReport()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$generator = $this->mock(SYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@@ -152,6 +168,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testDefaultReportBadDate()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -167,6 +186,9 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
|
||||
$helper = $this->mock(ReportHelperInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
@@ -186,6 +208,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptions()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -200,6 +224,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsAccount()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$account = new Account();
|
||||
$account->name = 'Something';
|
||||
$account->id = 3;
|
||||
@@ -222,6 +248,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsBudget()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
@@ -240,6 +268,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsCategory()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
@@ -257,6 +287,8 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testOptionsTag()
|
||||
{
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$tag = factory(Tag::class)->make();
|
||||
@@ -273,7 +305,12 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexAccountOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->times(3);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$data = [
|
||||
@@ -286,7 +323,7 @@ class ReportControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('reports.index.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('reports.report.account', ['1', '4', '20160101', '20160131']));
|
||||
$response->assertRedirect(route('reports.report.account', ['1', '1', '20160101', '20160131']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,8 +331,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexAuditOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -314,8 +356,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexBudgetError()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -336,8 +384,15 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexBudgetOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
$budgetRepository->shouldReceive('findNull')->andReturn($this->user()->budgets()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -357,8 +412,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexCategoryError()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -379,8 +440,14 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexCategoryOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$categoryRepos->shouldReceive('findNull')->andReturn($this->user()->categories()->find(1))->twice();
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -400,8 +467,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexDefaultOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -420,8 +492,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexDefaultStartEnd()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -440,8 +517,13 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexTagError()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -462,8 +544,15 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexTagOK()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$tag = $this->user()->tags()->find(1);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
$tagRepos->shouldReceive('findByTag')->andReturn($tag)->twice();
|
||||
|
||||
$data = [
|
||||
'accounts' => ['1'],
|
||||
@@ -475,7 +564,7 @@ class ReportControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('reports.index.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('reports.report.tag', ['1', 'housing', '20160101', '20160131']));
|
||||
$response->assertRedirect(route('reports.report.tag', ['1', $tag->tag, '20160101', '20160131']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,7 +572,11 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndexZeroAccounts()
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$data = [
|
||||
@@ -504,8 +597,18 @@ class ReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testTagReport()
|
||||
{
|
||||
$generator = $this->mock(TYRG::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
$generator = $this->mock(TYRG::class);
|
||||
$tag = $this->user()->tags()->find(1);
|
||||
|
||||
$tagRepos->shouldReceive('setUser');
|
||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||
|
||||
$budgetRepository->shouldReceive('cleanupBudgets');
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$generator->shouldReceive('setStartDate')->once();
|
||||
$generator->shouldReceive('setEndDate')->once();
|
||||
@@ -514,7 +617,7 @@ class ReportControllerTest extends TestCase
|
||||
$generator->shouldReceive('generate')->once()->andReturn('here-be-report');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.report.tag', [1, 'TagJanuary', '20160101', '20161231']));
|
||||
$response = $this->get(route('reports.report.tag', [1, $tag->tag, '20160101', '20161231']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user