mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage.
This commit is contained in:
@@ -120,6 +120,7 @@ class BudgetLimitControllerTest extends TestCase
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
|
||||
// call API
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->post(route('api.v1.budget_limits.store'), $data);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Unknown budget.');
|
||||
|
@@ -24,8 +24,11 @@ namespace Tests\Api\V1\Controllers\Chart;
|
||||
|
||||
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\Support\TestDataTrait;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -36,6 +39,8 @@ use Tests\TestCase;
|
||||
*/
|
||||
class CategoryControllerTest extends TestCase
|
||||
{
|
||||
use TestDataTrait;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -52,65 +57,21 @@ class CategoryControllerTest extends TestCase
|
||||
public function testOverview(): void
|
||||
{
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$noCatRepos =$this->mock(NoCategoryRepositoryInterface::class);
|
||||
$opsRepos = $this->mock(OperationsRepositoryInterface::class);
|
||||
|
||||
$spent = [
|
||||
2 => [
|
||||
'name' => 'Some other category',
|
||||
'spent' => [
|
||||
// earned in this currency.
|
||||
1 => [
|
||||
'currency_decimal_places' => 2,
|
||||
'currency_symbol' => 'x',
|
||||
'currency_code' => 'EUR',
|
||||
'currency_id' => 1,
|
||||
'spent' => '-522',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$earned = [
|
||||
1 => [
|
||||
'name' => 'Some category',
|
||||
'earned' => [
|
||||
// earned in this currency.
|
||||
2 => [
|
||||
'currency_decimal_places' => 2,
|
||||
'currency_id' => 1,
|
||||
'currency_symbol' => 'x',
|
||||
'currency_code' => 'EUR',
|
||||
'earned' => '123',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$earnedNoCategory = [
|
||||
1 => [
|
||||
'currency_decimal_places' => 2,
|
||||
'currency_id' => 3,
|
||||
'currency_symbol' => 'x',
|
||||
'currency_code' => 'EUR',
|
||||
'earned' => '123',
|
||||
],
|
||||
];
|
||||
$spentNoCategory = [
|
||||
5 => [
|
||||
'currency_decimal_places' => 2,
|
||||
'currency_symbol' => 'x',
|
||||
'currency_code' => 'EUR',
|
||||
'currency_id' => 4,
|
||||
'spent' => '-345',
|
||||
],
|
||||
];
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('spentInPeriodPerCurrency')->atLeast()->once()->andReturn($spent);
|
||||
$repository->shouldReceive('earnedInPeriodPerCurrency')->atLeast()->once()->andReturn($earned);
|
||||
$noCatRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$opsRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$opsRepos->shouldReceive('listExpenses')->atLeast()->once()->andReturn($this->categoryListExpenses());
|
||||
$opsRepos->shouldReceive('listIncome')->atLeast()->once()->andReturn($this->categoryListIncome());
|
||||
|
||||
$noCatRepos->shouldReceive('listExpenses')->atLeast()->once()->andReturn($this->noCategoryListExpenses());
|
||||
$noCatRepos->shouldReceive('listIncome')->atLeast()->once()->andReturn($this->noCategoryListIncome());
|
||||
|
||||
$repository->shouldReceive('earnedInPeriodPcWoCategory')->atLeast()->once()->andReturn($earnedNoCategory);
|
||||
$repository->shouldReceive('spentInPeriodPcWoCategory')->atLeast()->once()->andReturn($spentNoCategory);
|
||||
|
||||
$parameters = [
|
||||
'start' => '2019-01-01',
|
||||
|
@@ -118,6 +118,7 @@ class LinkTypeControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
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.');
|
||||
@@ -207,6 +208,7 @@ class LinkTypeControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
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 ');
|
||||
@@ -248,6 +250,7 @@ class LinkTypeControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
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.');
|
||||
|
@@ -112,6 +112,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
Log::warning('The following error is part of a test.');
|
||||
$response = $this->post(route('api.v1.piggy_banks.store'), $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
|
@@ -1256,7 +1256,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
[
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'description' => [
|
||||
'repetitions' => [
|
||||
'Need at least one repetition.',
|
||||
],
|
||||
],
|
||||
@@ -1309,7 +1309,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
[
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'description' => [
|
||||
'transactions' => [
|
||||
'Need at least one transaction.',
|
||||
],
|
||||
],
|
||||
|
@@ -172,6 +172,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
|
||||
// call API
|
||||
$group = $this->user()->ruleGroups()->first();
|
||||
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"');
|
||||
|
@@ -257,6 +257,7 @@ class TransactionLinkControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
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.
|
||||
@@ -380,6 +381,7 @@ class TransactionLinkControllerTest extends TestCase
|
||||
];
|
||||
|
||||
// test API
|
||||
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.
|
||||
|
Reference in New Issue
Block a user