mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix some tests
This commit is contained in:
@@ -121,7 +121,7 @@ class LinkTypeControllerTest extends TestCase
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->post(route('api.v1.link_types.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('You need the \"owner\"-role to do this.');
|
||||
$response->assertSee('200005');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,7 +211,7 @@ class LinkTypeControllerTest extends TestCase
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->put(route('api.v1.link_types.update', [$linkType->id]), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('You cannot edit this link type ');
|
||||
$response->assertSee('200020');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +253,7 @@ class LinkTypeControllerTest extends TestCase
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->put(route('api.v1.link_types.update', [$linkType->id]), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('You need the \"owner\"-role to do this.');
|
||||
$response->assertSee('200005');
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Api\V1\Controllers;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
@@ -95,14 +96,14 @@ class PiggyBankControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Api\V1\Controllers\PiggyBankController
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testStoreNull(): void
|
||||
public function testStoreThrowError(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$repository->shouldReceive('store')->once()->andReturn(null)->once();
|
||||
$repository->shouldReceive('store')->once()->andThrow(new FireflyException('400005'));
|
||||
|
||||
|
||||
$data = [
|
||||
@@ -116,7 +117,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
$response = $this->post(route('api.v1.piggy_banks.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
$response->assertSee('Could not store new piggy bank.');
|
||||
$response->assertSee('400005');
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1055,7 +1055,6 @@ class RecurrenceControllerTest extends TestCase
|
||||
'errors' => [
|
||||
'transactions.0.source_id' => [
|
||||
null,
|
||||
'This value is invalid for this field.',
|
||||
],
|
||||
'transactions.0.source_name' => [
|
||||
null,
|
||||
@@ -1196,7 +1195,6 @@ class RecurrenceControllerTest extends TestCase
|
||||
'errors' => [
|
||||
'transactions.0.source_id' => [
|
||||
null,
|
||||
'This value is invalid for this field.',
|
||||
],
|
||||
'transactions.0.source_name' => [
|
||||
null,
|
||||
|
@@ -175,7 +175,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->get(route('api.v1.rule_groups.test', [$group->id]), ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('{"message":"No rules in this rule group.","exception":"FireflyIII\\\\Exceptions\\\\FireflyException"');
|
||||
$response->assertSee('200023');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -136,29 +136,33 @@ class SummaryControllerTest extends TestCase
|
||||
// budget repos
|
||||
$abRepos->shouldReceive('getAvailableBudgetWithCurrency')->atLeast()->once()->andReturn([1 => '123', 2 => '456']);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->atLeast()->once()->andReturn(new Collection([$budget]));
|
||||
$opsRepos->shouldReceive('spentInPeriodMc')->atLeast()->once()->andReturn(
|
||||
[
|
||||
[
|
||||
'currency_id' => 3,
|
||||
'currency_code' => 'EUR',
|
||||
'currency_symbol' => 'x',
|
||||
'currency_decimal_places' => 2,
|
||||
'amount' => 321.21,
|
||||
],
|
||||
[
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'currency_symbol' => 'x',
|
||||
'currency_decimal_places' => 2,
|
||||
'amount' => 321.21,
|
||||
],
|
||||
|
||||
]
|
||||
);
|
||||
// new stuff
|
||||
$opsRepos->shouldReceive('sumExpenses')->atLeast()->once()->andReturn([]);
|
||||
|
||||
|
||||
//$opsRepos->shouldReceive('spentInPeriodMc')->atLeast()->once()->andReturn(
|
||||
// [
|
||||
// [
|
||||
// 'currency_id' => 3,
|
||||
// 'currency_code' => 'EUR',
|
||||
// 'currency_symbol' => 'x',
|
||||
// 'currency_decimal_places' => 2,
|
||||
// 'amount' => 321.21,
|
||||
// ],
|
||||
// [
|
||||
// 'currency_id' => 1,
|
||||
// 'currency_code' => 'EUR',
|
||||
// 'currency_symbol' => 'x',
|
||||
// 'currency_decimal_places' => 2,
|
||||
// 'amount' => 321.21,
|
||||
// ],
|
||||
//
|
||||
// ]
|
||||
// );
|
||||
|
||||
// account repos:
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->atLeast()->once()
|
||||
->withArgs([[AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]])->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->atLeast()->once()->withArgs([[AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]])->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getMetaValue')->atLeast()->once()->withArgs([Mockery::any(), 'include_net_worth'])->andReturn(true);
|
||||
|
||||
// net worth calculator
|
||||
@@ -169,9 +173,10 @@ class SummaryControllerTest extends TestCase
|
||||
'end' => $date->addWeek()->format('Y-m-d'),
|
||||
];
|
||||
|
||||
// TODO AFTER 4.8,0: check if JSON is correct
|
||||
$response = $this->get(route('api.v1.summary.basic') . '?' . http_build_query($parameters));
|
||||
$response->assertStatus(200);
|
||||
// TODO AFTER 4.8,0: check if JSON is correct
|
||||
//$response->assertSee('hi there');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,21 +242,24 @@ class SummaryControllerTest extends TestCase
|
||||
// budget repos
|
||||
$abRepos->shouldReceive('getAvailableBudgetWithCurrency')->atLeast()->once()->andReturn([1 => '123']);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->atLeast()->once()->andReturn(new Collection([$budget]));
|
||||
$opsRepos->shouldReceive('spentInPeriodMc')->atLeast()->once()->andReturn(
|
||||
[
|
||||
[
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'currency_symbol' => 'x',
|
||||
'currency_decimal_places' => 2,
|
||||
'amount' => 321.21,
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
// new stuff
|
||||
$opsRepos->shouldReceive('sumExpenses')->atLeast()->once()->andReturn([]);
|
||||
|
||||
// $opsRepos->shouldReceive('spentInPeriodMc')->atLeast()->once()->andReturn(
|
||||
// [
|
||||
// [
|
||||
// 'currency_id' => 1,
|
||||
// 'currency_code' => 'EUR',
|
||||
// 'currency_symbol' => 'x',
|
||||
// 'currency_decimal_places' => 2,
|
||||
// 'amount' => 321.21,
|
||||
// ],
|
||||
// ]
|
||||
// );
|
||||
|
||||
// account repos:
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->atLeast()->once()
|
||||
->withArgs([[AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]])->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->atLeast()->once()->withArgs([[AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE]])->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getMetaValue')->atLeast()->once()->withArgs([Mockery::any(), 'include_net_worth'])->andReturn(true);
|
||||
|
||||
// net worth calculator
|
||||
|
@@ -720,8 +720,8 @@ class TransactionControllerTest extends TestCase
|
||||
$apiRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['invalid'])->atLeast()->once();
|
||||
$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
//$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
//$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
|
||||
$data = [
|
||||
'group_title' => 'Empty',
|
||||
@@ -779,8 +779,8 @@ class TransactionControllerTest extends TestCase
|
||||
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['withdrawal'])->atLeast()->once();
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['deposit'])->atLeast()->once();
|
||||
$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
//$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
//$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -845,8 +845,8 @@ class TransactionControllerTest extends TestCase
|
||||
$apiRepos = $this->mock(JournalAPIRepositoryInterface::class);
|
||||
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['invalid'])->atLeast()->once();
|
||||
$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
//$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
//$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
@@ -260,7 +260,7 @@ class TransactionLinkControllerTest extends TestCase
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->post(route('api.v1.transaction_links.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Source or destination is NULL.'); // the creation moment.
|
||||
$response->assertSee('200024'); // the creation moment.
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ class TransactionLinkControllerTest extends TestCase
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->put(route('api.v1.transaction_links.update', $journalLink->id), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Source or destination is NULL.'); // the creation moment.
|
||||
$response->assertSee('200024'); // the creation moment.
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user