mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup and realign.
This commit is contained in:
@@ -174,7 +174,7 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/available_budgets', $data,['Accept' => 'application/json']);
|
||||
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Could not find the indicated currency.');
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
|
@@ -127,6 +127,7 @@ class BillControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* Store with minimum amount more than maximum amount
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\BillController
|
||||
* @covers \FireflyIII\Api\V1\Requests\BillRequest
|
||||
*/
|
||||
|
@@ -124,7 +124,7 @@ class BudgetLimitControllerTest extends TestCase
|
||||
'start' => '2018-01-01',
|
||||
'end' => '2018-01-31',
|
||||
];
|
||||
$uri = '/api/v1/budget_limits?' . http_build_query($params);
|
||||
$uri = '/api/v1/budget_limits?' . http_build_query($params);
|
||||
$response = $this->get($uri);
|
||||
$response->assertStatus(200);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
@@ -149,9 +149,9 @@ class BudgetLimitControllerTest extends TestCase
|
||||
|
||||
// call API
|
||||
$params = [
|
||||
'budget_id' => $budget->id,
|
||||
'start' => '2018-01-01',
|
||||
'end' => '2018-01-31',
|
||||
'budget_id' => $budget->id,
|
||||
'start' => '2018-01-01',
|
||||
'end' => '2018-01-31',
|
||||
];
|
||||
$response = $this->get('/api/v1/budget_limits?' . http_build_query($params));
|
||||
$response->assertStatus(200);
|
||||
|
@@ -97,7 +97,8 @@ class CurrencyControllerTest extends TestCase
|
||||
$response = $this->get('/api/v1/currencies');
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['data' => [],]);
|
||||
$response->assertJson([
|
||||
$response->assertJson(
|
||||
[
|
||||
'meta' => [
|
||||
'pagination' => [
|
||||
'total' => $collection->count(),
|
||||
|
@@ -103,40 +103,6 @@ class CurrencyExchangeRateControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
||||
*/
|
||||
public function testIndexBadSource(): void
|
||||
{
|
||||
// mock repository
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$service = $this->mock(ExchangeRateInterface::class);
|
||||
|
||||
$rate = new CurrencyExchangeRate();
|
||||
$rate->date = new Carbon();
|
||||
$rate->updated_at = new Carbon();
|
||||
$rate->created_at = new Carbon();
|
||||
$rate->rate = '0.5';
|
||||
$rate->to_currency_id = 1;
|
||||
$rate->from_currency_id = 2;
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
|
||||
|
||||
// test API
|
||||
$params = [
|
||||
'from' => 'EUR',
|
||||
'to' => 'USD',
|
||||
'date' => '2018-01-01',
|
||||
];
|
||||
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Unknown source currency.');
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
||||
*/
|
||||
@@ -170,4 +136,38 @@ class CurrencyExchangeRateControllerTest extends TestCase
|
||||
$response->assertSee('Unknown destination currency.');
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
|
||||
*/
|
||||
public function testIndexBadSource(): void
|
||||
{
|
||||
// mock repository
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$service = $this->mock(ExchangeRateInterface::class);
|
||||
|
||||
$rate = new CurrencyExchangeRate();
|
||||
$rate->date = new Carbon();
|
||||
$rate->updated_at = new Carbon();
|
||||
$rate->created_at = new Carbon();
|
||||
$rate->rate = '0.5';
|
||||
$rate->to_currency_id = 1;
|
||||
$rate->from_currency_id = 2;
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
|
||||
|
||||
// test API
|
||||
$params = [
|
||||
'from' => 'EUR',
|
||||
'to' => 'USD',
|
||||
'date' => '2018-01-01',
|
||||
];
|
||||
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Unknown source currency.');
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
@@ -749,12 +749,12 @@ class RecurrenceControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
||||
* Add a recurring but refer to an asset as destination.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||
*/
|
||||
public function testStoreFailInvalidWeekly(): void
|
||||
public function testStoreFailInvalidDestinationId(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
@@ -776,6 +776,19 @@ class RecurrenceControllerTest extends TestCase
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
|
||||
// entries used by the transformer
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Note text');
|
||||
$repository->shouldReceive('repetitionDescription')->andReturn('Some description.');
|
||||
$repository->shouldReceive('getXOccurrences')->andReturn([]);
|
||||
|
||||
// entries used by the transformer (the fake entry has a category + a budget):
|
||||
$factory->shouldReceive('findOrCreate')->andReturn(null);
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn(null);
|
||||
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
@@ -788,16 +801,17 @@ class RecurrenceControllerTest extends TestCase
|
||||
'active' => 1,
|
||||
'transactions' => [
|
||||
[
|
||||
'amount' => '100',
|
||||
'currency_id' => '1',
|
||||
'description' => 'Test description',
|
||||
'source_id' => '1',
|
||||
'amount' => '100',
|
||||
'currency_id' => '1',
|
||||
'description' => 'Test description',
|
||||
'source_id' => '1',
|
||||
'destination_id' => $assetAccount->id,
|
||||
],
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'weekly',
|
||||
'moment' => '8',
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => '0',
|
||||
'weekend' => '1',
|
||||
|
||||
@@ -811,8 +825,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
[
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'repetitions.0.moment' => [
|
||||
'Invalid repetition moment for this type of repetition.',
|
||||
'transactions.0.destination_id' => [
|
||||
'This value is invalid for this field.',
|
||||
],
|
||||
],
|
||||
]
|
||||
@@ -967,6 +981,79 @@ class RecurrenceControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||
*/
|
||||
public function testStoreFailInvalidNdomCount(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$factory->shouldReceive('setUser');
|
||||
$budgetRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
$firstDate->addDays(2);
|
||||
$data = [
|
||||
'type' => 'withdrawal',
|
||||
'title' => 'Hello',
|
||||
'first_date' => $firstDate->format('Y-m-d'),
|
||||
'apply_rules' => 1,
|
||||
'active' => 1,
|
||||
'transactions' => [
|
||||
[
|
||||
'amount' => '100',
|
||||
'currency_id' => '1',
|
||||
'description' => 'Test description',
|
||||
'source_id' => '1',
|
||||
],
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'ndom',
|
||||
'moment' => '9',
|
||||
'skip' => '0',
|
||||
'weekend' => '1',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']);
|
||||
$response->assertExactJson(
|
||||
[
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'repetitions.0.moment' => [
|
||||
'Invalid repetition moment for this type of repetition.',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
$response->assertStatus(422);
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the minimum amount to store a recurring transaction (using source ID field).
|
||||
*
|
||||
@@ -1046,7 +1133,7 @@ class RecurrenceControllerTest extends TestCase
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||
*/
|
||||
public function testStoreFailInvalidNdomCount(): void
|
||||
public function testStoreFailInvalidWeekly(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
@@ -1088,8 +1175,8 @@ class RecurrenceControllerTest extends TestCase
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'ndom',
|
||||
'moment' => '9',
|
||||
'type' => 'weekly',
|
||||
'moment' => '8',
|
||||
'skip' => '0',
|
||||
'weekend' => '1',
|
||||
|
||||
@@ -1113,93 +1200,6 @@ class RecurrenceControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a recurring but refer to an asset as destination.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
|
||||
*/
|
||||
public function testStoreFailInvalidDestinationId(): void
|
||||
{
|
||||
/** @var Recurrence $recurrence */
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$factory = $this->mock(CategoryFactory::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$assetAccount = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$factory->shouldReceive('setUser');
|
||||
$budgetRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
|
||||
// used by the validator to find the source_id:
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
|
||||
->andReturn(new Collection([$assetAccount]));
|
||||
|
||||
|
||||
// entries used by the transformer
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Note text');
|
||||
$repository->shouldReceive('repetitionDescription')->andReturn('Some description.');
|
||||
$repository->shouldReceive('getXOccurrences')->andReturn([]);
|
||||
|
||||
// entries used by the transformer (the fake entry has a category + a budget):
|
||||
$factory->shouldReceive('findOrCreate')->andReturn(null);
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn(null);
|
||||
|
||||
|
||||
// data to submit
|
||||
$firstDate = new Carbon;
|
||||
$firstDate->addDays(2);
|
||||
$data = [
|
||||
'type' => 'withdrawal',
|
||||
'title' => 'Hello',
|
||||
'first_date' => $firstDate->format('Y-m-d'),
|
||||
'apply_rules' => 1,
|
||||
'active' => 1,
|
||||
'transactions' => [
|
||||
[
|
||||
'amount' => '100',
|
||||
'currency_id' => '1',
|
||||
'description' => 'Test description',
|
||||
'source_id' => '1',
|
||||
'destination_id' => $assetAccount->id,
|
||||
],
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => '0',
|
||||
'weekend' => '1',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']);
|
||||
$response->assertExactJson(
|
||||
[
|
||||
'message' => 'The given data was invalid.',
|
||||
'errors' => [
|
||||
'transactions.0.destination_id' => [
|
||||
'This value is invalid for this field.',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
$response->assertStatus(422);
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit without a source account.
|
||||
*
|
||||
|
@@ -27,7 +27,6 @@ namespace Tests\Feature\Controllers\Account;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
|
@@ -30,8 +30,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class DeleteControllerTest
|
||||
@@ -46,6 +47,7 @@ class DeleteControllerTest extends TestCase
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\DeleteController
|
||||
* @covers \FireflyIII\Http\Controllers\Controller
|
||||
|
@@ -26,16 +26,16 @@ namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
use Amount;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class EditControllerTest
|
||||
@@ -50,6 +50,7 @@ class EditControllerTest extends TestCase
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\EditController
|
||||
*/
|
||||
|
@@ -32,8 +32,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ConfigurationControllerTest
|
||||
@@ -217,7 +217,7 @@ class ReconcileControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getReconciliation')->andReturn(new Account);
|
||||
$repository->shouldReceive('findNull')->andReturn(new Account);
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'currency_id'])->andReturn('1');
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
$data = [
|
||||
'transactions' => [1, 2, 3],
|
||||
|
@@ -147,7 +147,7 @@ class ShowControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @expectedExceptionMessage End is after start!
|
||||
*/
|
||||
public function testShowBrokenBadDates(): void
|
||||
@@ -165,7 +165,7 @@ class ShowControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @expectedExceptionMessage Expected a transaction
|
||||
*/
|
||||
public function testShowBrokenInitial(): void
|
||||
|
@@ -97,8 +97,8 @@ class UpdateControllerTest extends TestCase
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn(new Configuration);
|
||||
|
||||
$version = config('firefly.version');
|
||||
$date = new Carbon;
|
||||
$version = config('firefly.version');
|
||||
$date = new Carbon;
|
||||
$date->subDays(5);
|
||||
$releases = [
|
||||
new Release(['id' => 'x', 'title' => $version . '.1', 'content' => '', 'updated' => $date]),
|
||||
|
@@ -96,7 +96,7 @@ class UserControllerTest extends TestCase
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
//$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(3)->andReturn(true);
|
||||
$user = $this->user();
|
||||
$user = $this->user();
|
||||
$repository->shouldReceive('all')->andReturn(new Collection([$user]));
|
||||
|
||||
$this->be($user);
|
||||
|
@@ -139,7 +139,7 @@ class AttachmentControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection([Attachment::first()]))->once();
|
||||
$repository->shouldReceive('exists')->andReturn(true)->once();
|
||||
|
||||
|
@@ -74,8 +74,8 @@ class TwoFactorControllerTest extends TestCase
|
||||
|
||||
$falsePreference = new Preference;
|
||||
$falsePreference->data = false;
|
||||
$langPreference = new Preference;
|
||||
$langPreference->data = 'en_US';
|
||||
$langPreference = new Preference;
|
||||
$langPreference->data = 'en_US';
|
||||
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice();
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn(null)->once();
|
||||
|
@@ -27,7 +27,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
@@ -65,9 +64,9 @@ class BillControllerTest extends TestCase
|
||||
public function testCreate(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -83,9 +82,9 @@ class BillControllerTest extends TestCase
|
||||
public function testDelete(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -101,10 +100,10 @@ class BillControllerTest extends TestCase
|
||||
public function testDestroy(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -121,9 +120,9 @@ class BillControllerTest extends TestCase
|
||||
public function testEdit(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -140,11 +139,11 @@ class BillControllerTest extends TestCase
|
||||
public function testIndex(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$bill = factory(Bill::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$bill = factory(Bill::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$collection = new Collection([$bill]);
|
||||
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
|
||||
@@ -166,12 +165,12 @@ class BillControllerTest extends TestCase
|
||||
public function testRescan(): void
|
||||
{
|
||||
// mock stuff
|
||||
$rule = Rule::first();
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journal = factory(TransactionJournal::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$rule = Rule::first();
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journal = factory(TransactionJournal::class)->make();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
|
||||
|
||||
@@ -196,10 +195,10 @@ class BillControllerTest extends TestCase
|
||||
public function testRescanInactive(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -214,11 +213,11 @@ class BillControllerTest extends TestCase
|
||||
public function testShow(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('getYearAverage')->andReturn('0');
|
||||
$repository->shouldReceive('getOverallAverage')->andReturn('0');
|
||||
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
|
||||
@@ -252,10 +251,10 @@ class BillControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$bill = $this->user()->bills()->first();
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn($bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
@@ -286,11 +285,11 @@ class BillControllerTest extends TestCase
|
||||
public function testStoreCreateAnother(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$bill = $this->user()->bills()->first();
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$bill = $this->user()->bills()->first();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn($bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
@@ -314,41 +313,6 @@ class BillControllerTest extends TestCase
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
* @covers \FireflyIII\Http\Requests\Request
|
||||
*/
|
||||
public function testStoreNoGroup(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
||||
'amount_min' => '100',
|
||||
'transaction_currency_id' => 1,
|
||||
'skip' => 0,
|
||||
'create_another' => '1',
|
||||
'strict' => 1,
|
||||
'amount_max' => '100',
|
||||
'date' => '2016-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
];
|
||||
$this->session(['bills.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
@@ -357,10 +321,10 @@ class BillControllerTest extends TestCase
|
||||
public function testStoreError(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(null);
|
||||
|
||||
@@ -381,6 +345,41 @@ class BillControllerTest extends TestCase
|
||||
$response->assertRedirect(route('bills.create'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
* @covers \FireflyIII\Http\Requests\Request
|
||||
*/
|
||||
public function testStoreNoGroup(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Bill ' . random_int(1000, 9999),
|
||||
'amount_min' => '100',
|
||||
'transaction_currency_id' => 1,
|
||||
'skip' => 0,
|
||||
'create_another' => '1',
|
||||
'strict' => 1,
|
||||
'amount_max' => '100',
|
||||
'date' => '2016-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
];
|
||||
$this->session(['bills.create.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::update
|
||||
* @covers \FireflyIII\Http\Requests\BillFormRequest
|
||||
@@ -389,10 +388,10 @@ class BillControllerTest extends TestCase
|
||||
public function testUpdate(): void
|
||||
{
|
||||
// mock stuff
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
|
||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('update')->andReturn(new Bill);
|
||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||
|
@@ -24,13 +24,9 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Category;
|
||||
|
||||
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@@ -38,7 +34,10 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Navigation;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ShowControllerTest
|
||||
@@ -200,7 +199,7 @@ class ShowControllerTest extends TestCase
|
||||
public function testShowEmpty(string $range): void
|
||||
{
|
||||
$latestJournal = $this->user()->transactionJournals()
|
||||
->orderBy('date','DESC')->first();
|
||||
->orderBy('date', 'DESC')->first();
|
||||
|
||||
Log::debug(sprintf('Test testShowEmpty(%s)', $range));
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
@@ -29,8 +29,9 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class CurrencyControllerTest
|
||||
*
|
||||
|
@@ -22,11 +22,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use Mockery;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
@@ -34,6 +33,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -111,11 +111,11 @@ class HomeControllerTest extends TestCase
|
||||
public function testIndex(string $range): void
|
||||
{
|
||||
// mock stuff
|
||||
$account = factory(Account::class)->make();
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('count')->andReturn(1);
|
||||
|
@@ -167,7 +167,6 @@ class IndexControllerTest extends TestCase
|
||||
$ynabPrerequisites->shouldReceive('setUser')->times(2);
|
||||
|
||||
|
||||
|
||||
$repository->shouldReceive('create')->withArgs(['fake'])->andReturn($importJob);
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'has_prereq'])->andReturn($importJob)->once();
|
||||
|
||||
|
@@ -107,6 +107,28 @@ class JavascriptControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @dataProvider dateRangeProvider
|
||||
*/
|
||||
public function testVariablesCustom(string $range): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->session(['is_custom_range' => true]);
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
@@ -132,27 +154,4 @@ class JavascriptControllerTest extends TestCase
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @dataProvider dateRangeProvider
|
||||
*/
|
||||
public function testVariablesCustom(string $range): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->session(['is_custom_range' => true]);
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@@ -108,23 +108,6 @@ class AutoCompleteControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
public function testCurrencyNames(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currency = TransactionCurrency::find(1);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection([$currency]))->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.currency-names'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['Euro']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
@@ -159,6 +142,22 @@ class AutoCompleteControllerTest extends TestCase
|
||||
$response->assertExactJson([$category->name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
public function testCurrencyNames(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currency = TransactionCurrency::find(1);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection([$currency]))->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.currency-names'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertExactJson(['Euro']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
|
||||
*/
|
||||
|
@@ -117,9 +117,9 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testBalanceTransactions(): void
|
||||
{
|
||||
$transaction = new Transaction;
|
||||
$transaction = new Transaction;
|
||||
$transaction->transaction_currency_id = 1;
|
||||
$transaction->transaction_amount ='5';
|
||||
$transaction->transaction_amount = '5';
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@@ -171,17 +171,20 @@ class BoxControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController::netWorth()
|
||||
*/
|
||||
public function testNetWorthVirtual(): void
|
||||
public function testNetWorthFuture(): void
|
||||
{
|
||||
$account = $this->user()->accounts()->first();
|
||||
$account->virtual_balance = '1000';
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
|
||||
$start = new Carbon;
|
||||
$start->addMonths(6)->startOfMonth();
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
$this->session(['start' => $start, 'end' => $end]);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
@@ -207,20 +210,17 @@ class BoxControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController::netWorth()
|
||||
*/
|
||||
public function testNetWorthFuture(): void
|
||||
public function testNetWorthVirtual(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$account = $this->user()->accounts()->first();
|
||||
$account->virtual_balance = '1000';
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
|
||||
$start = new Carbon;
|
||||
$start->addMonths(6)->startOfMonth();
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
$this->session(['start' => $start, 'end' => $end]);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
|
@@ -228,9 +228,9 @@ class ProfileControllerTest extends TestCase
|
||||
$listPref->data = '50';
|
||||
Preferences::shouldReceive('get')->withArgs(['list-length', '10'])->andReturn($listPref)->once();
|
||||
|
||||
$secretPref= new Preference;
|
||||
$secretPref = new Preference;
|
||||
$secretPref->data = 'X';
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->twice()->andReturn(null,$secretPref);
|
||||
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->twice()->andReturn(null, $secretPref);
|
||||
|
||||
// set pref
|
||||
Preferences::shouldReceive('set')->once()->withArgs(['twoFactorAuthEnabled', 1]);
|
||||
@@ -313,7 +313,7 @@ class ProfileControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
|
||||
$data = [
|
||||
$data = [
|
||||
'email' => $this->user()->email,
|
||||
];
|
||||
$this->be($this->user());
|
||||
@@ -467,7 +467,7 @@ class ProfileControllerTest extends TestCase
|
||||
*/
|
||||
public function testRegenerate(): void
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
|
||||
$token = '';
|
||||
$currentToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first();
|
||||
|
@@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace tests\Feature\Controllers\Rule;
|
||||
|
||||
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
|
@@ -75,32 +75,6 @@ class BulkControllerTest extends TestCase
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
*/
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
|
||||
|
||||
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.bulk.edit', $transfers));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Bulk edit a number of transactions');
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
|
||||
*/
|
||||
@@ -136,6 +110,32 @@ class BulkControllerTest extends TestCase
|
||||
$response->assertSee('multiple destination accounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
|
||||
*/
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
|
||||
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
|
||||
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
|
||||
|
||||
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.bulk.edit', $transfers));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Bulk edit a number of transactions');
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
|
||||
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
|
||||
|
@@ -107,35 +107,6 @@ class LinkControllerTest extends TestCase
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreSame(): void
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
$journal = $this->user()->transactionJournals()->first();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [$journal->id]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
@@ -167,7 +138,7 @@ class LinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreInvalid(): void
|
||||
{
|
||||
$data = [
|
||||
$data = [
|
||||
'link_other' => 0,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
@@ -183,6 +154,33 @@ class LinkControllerTest extends TestCase
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreSame(): void
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
$journal = $this->user()->transactionJournals()->first();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [$journal->id]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::switchLink
|
||||
*/
|
||||
|
@@ -202,8 +202,8 @@ class MassControllerTest extends TestCase
|
||||
'amount' => [$deposit->id => 1600],
|
||||
'amount_currency_id_amount_' . $deposit->id => 1,
|
||||
'date' => [$deposit->id => '2014-07-24'],
|
||||
'source_name' => [$deposit->id => 'Job'],
|
||||
'destination_id' => [$deposit->id => 1],
|
||||
'source_name' => [$deposit->id => 'Job'],
|
||||
'destination_id' => [$deposit->id => 1],
|
||||
'category' => [$deposit->id => 'Salary'],
|
||||
];
|
||||
|
||||
|
@@ -29,7 +29,6 @@ use FireflyIII\Events\StoredTransactionJournal;
|
||||
use FireflyIII\Events\UpdatedTransactionJournal;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -849,7 +848,6 @@ class SingleControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
|
||||
|
||||
|
||||
|
||||
$linkRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
|
||||
$attRepos->shouldReceive('saveAttachmentsForModel');
|
||||
|
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Transaction;
|
||||
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -77,7 +76,6 @@ class SplitControllerTest extends TestCase
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
|
||||
|
||||
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
|
||||
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
|
||||
$account = $destination->account;
|
||||
@@ -131,7 +129,6 @@ class SplitControllerTest extends TestCase
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
|
||||
|
||||
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
|
||||
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
|
||||
@@ -292,15 +289,15 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
|
||||
$data = [
|
||||
'id' => $deposit->id,
|
||||
'what' => 'deposit',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'id' => $deposit->id,
|
||||
'what' => 'deposit',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_destination_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_name' => 'Job',
|
||||
@@ -342,15 +339,15 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
|
||||
$data = [
|
||||
'id' => $opening->id,
|
||||
'what' => 'opening balance',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'id' => $opening->id,
|
||||
'what' => 'opening balance',
|
||||
'journal_description' => 'Updated salary',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_destination_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_name' => 'Job',
|
||||
@@ -390,18 +387,18 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$data = [
|
||||
'id' => $transfer->id,
|
||||
'what' => 'transfer',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'id' => $transfer->id,
|
||||
'what' => 'transfer',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_id' => '1',
|
||||
'source_id' => '1',
|
||||
'destination_id' => '2',
|
||||
'transaction_currency_id' => 1,
|
||||
'amount' => 1591,
|
||||
@@ -446,15 +443,15 @@ class SplitControllerTest extends TestCase
|
||||
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
|
||||
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
|
||||
$data = [
|
||||
'id' => $withdrawal->id,
|
||||
'what' => 'withdrawal',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
'id' => $withdrawal->id,
|
||||
'what' => 'withdrawal',
|
||||
'journal_description' => 'Some updated withdrawal',
|
||||
'journal_currency_id' => 1,
|
||||
'journal_source_id' => 1,
|
||||
'journal_amount' => 1591,
|
||||
'date' => '2014-01-24',
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_description' => 'Split #1',
|
||||
'source_id' => '1',
|
||||
|
@@ -65,7 +65,7 @@ class TransactionControllerTest extends TestCase
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
// mock stuff
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
|
||||
@@ -99,7 +99,7 @@ class TransactionControllerTest extends TestCase
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
// mock stuff
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
|
||||
@@ -143,7 +143,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
@@ -186,7 +186,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
@@ -204,7 +204,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->shouldReceive('getJournals')->andReturn($collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01','2015-12-31']));
|
||||
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01', '2015-12-31']));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
@@ -229,7 +229,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
@@ -272,7 +272,7 @@ class TransactionControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
|
||||
|
||||
|
@@ -31,7 +31,8 @@ class FakeApiContext
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toJson(): string{
|
||||
public function toJson(): string
|
||||
{
|
||||
return json_encode(['a' => 'b']);
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,6 @@ abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $range
|
||||
|
@@ -69,46 +69,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test minimal set of data to make factory work (asset account).
|
||||
*
|
||||
* @covers \FireflyIII\Factory\AccountFactory
|
||||
* @covers \FireflyIII\Factory\AccountMetaFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
|
||||
*/
|
||||
public function testCreateBasicEmptyVb(): void
|
||||
{
|
||||
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'accountType' => 'asset',
|
||||
'iban' => null,
|
||||
'name' => 'Basic asset account #' . random_int(1, 10000),
|
||||
'virtualBalance' => '',
|
||||
'active' => true,
|
||||
'accountRole' => 'defaultAsset',
|
||||
];
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($this->user());
|
||||
$account = $factory->create($data);
|
||||
|
||||
// assert stuff about account:
|
||||
$this->assertEquals($account->name, $data['name']);
|
||||
$this->assertEquals(AccountType::ASSET, $account->accountType->type);
|
||||
$this->assertEquals('', $account->iban);
|
||||
$this->assertTrue($account->active);
|
||||
$this->assertEquals('0', $account->virtual_balance);
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
@@ -148,17 +109,56 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('ccAsset', $meta->data);
|
||||
|
||||
// get the date:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','ccMonthlyPaymentDate')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'ccMonthlyPaymentDate')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('2018-01-01', $meta->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test minimal set of data to make factory work (asset account).
|
||||
*
|
||||
* @covers \FireflyIII\Factory\AccountFactory
|
||||
* @covers \FireflyIII\Factory\AccountMetaFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
|
||||
*/
|
||||
public function testCreateBasicEmptyVb(): void
|
||||
{
|
||||
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'accountType' => 'asset',
|
||||
'iban' => null,
|
||||
'name' => 'Basic asset account #' . random_int(1, 10000),
|
||||
'virtualBalance' => '',
|
||||
'active' => true,
|
||||
'accountRole' => 'defaultAsset',
|
||||
];
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($this->user());
|
||||
$account = $factory->create($data);
|
||||
|
||||
// assert stuff about account:
|
||||
$this->assertEquals($account->name, $data['name']);
|
||||
$this->assertEquals(AccountType::ASSET, $account->accountType->type);
|
||||
$this->assertEquals('', $account->iban);
|
||||
$this->assertTrue($account->active);
|
||||
$this->assertEquals('0', $account->virtual_balance);
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an expense account. This overrules the virtual balance.
|
||||
* Role should not be set.
|
||||
@@ -194,7 +194,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNull($meta);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNull($meta);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
@@ -320,7 +320,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
@@ -362,7 +362,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
@@ -401,7 +401,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
@@ -487,7 +487,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
|
@@ -67,6 +67,20 @@ class TransactionCurrencyFactoryTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* submit ID = 1000
|
||||
*
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
public function testFindByBadID(): void
|
||||
{
|
||||
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$result = $factory->find(1000, $currency->code);
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
@@ -92,20 +106,6 @@ class TransactionCurrencyFactoryTest extends TestCase
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* submit ID = 1000
|
||||
*
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
public function testFindByBadID(): void
|
||||
{
|
||||
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$result = $factory->find(1000, $currency->code);
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
|
@@ -704,11 +704,11 @@ class TransactionFactoryTest extends TestCase
|
||||
public function testCreatePairReconciliation(): void
|
||||
{
|
||||
// objects:
|
||||
$asset = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$asset = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$reconAccount = $this->user()->accounts()->where('account_type_id', 10)->first();
|
||||
//$opposing = $this->user()->accounts()->where('id', '!=', $asset->id)->where('account_type_id', 3)->first();
|
||||
$euro = TransactionCurrency::first();
|
||||
$foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
|
||||
$euro = TransactionCurrency::first();
|
||||
$foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
|
||||
|
||||
// mocked classes
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
@@ -90,7 +90,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
'data' => 'bye!',
|
||||
]
|
||||
);
|
||||
$count = $journal->transactionJournalMeta()->count();
|
||||
$count = $journal->transactionJournalMeta()->count();
|
||||
|
||||
$set = [
|
||||
'journal' => $journal,
|
||||
@@ -101,7 +101,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
$factory = app(TransactionJournalMetaFactory::class);
|
||||
$factory->updateOrCreate($set);
|
||||
|
||||
$this->assertEquals($count-1, $journal->transactionJournalMeta()->count());
|
||||
$this->assertEquals($count - 1, $journal->transactionJournalMeta()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -169,7 +169,7 @@ class AmountCreditTest extends TestCase
|
||||
foreach ($values as $value => $expected) {
|
||||
$converter = new AmountCredit;
|
||||
$result = $converter->convert($value);
|
||||
//$this->assertEquals($expected, $result, sprintf('The original value was %s, expected was %s', $value, $expected));
|
||||
//$this->assertEquals($expected, $result, sprintf('The original value was %s, expected was %s', $value, $expected));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,8 +28,8 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\Routine\SpectreRoutine;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\StageAuthenticatedHandler;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
|
||||
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
@@ -39,37 +39,6 @@ use Tests\TestCase;
|
||||
*/
|
||||
class SpectreRoutineTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Routine\SpectreRoutine
|
||||
*/
|
||||
public function testRunDoAuthenticate(): void
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'SR1A' . random_int(1, 10000);
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'do-authenticate';
|
||||
$job->provider = 'spectre';
|
||||
$job->file_type = '';
|
||||
$job->configuration = [];
|
||||
$job->save();
|
||||
|
||||
// mock handler and repository
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// mock calls for repository
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
|
||||
|
||||
$routine = new SpectreRoutine;
|
||||
$routine->setImportJob($job);
|
||||
try {
|
||||
$routine->run();
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Routine\SpectreRoutine
|
||||
*/
|
||||
@@ -108,6 +77,37 @@ class SpectreRoutineTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Routine\SpectreRoutine
|
||||
*/
|
||||
public function testRunDoAuthenticate(): void
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'SR1A' . random_int(1, 10000);
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'do-authenticate';
|
||||
$job->provider = 'spectre';
|
||||
$job->file_type = '';
|
||||
$job->configuration = [];
|
||||
$job->save();
|
||||
|
||||
// mock handler and repository
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// mock calls for repository
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
|
||||
|
||||
$routine = new SpectreRoutine;
|
||||
$routine->setImportJob($job);
|
||||
try {
|
||||
$routine->run();
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Routine\SpectreRoutine
|
||||
*/
|
||||
|
@@ -112,7 +112,9 @@ class AbnAmroDescriptionTest extends TestCase
|
||||
*/
|
||||
public function testSepaBasic(): void
|
||||
{
|
||||
$row = [0, 1, 2, 3, 4, 5, 6, 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238', '',''];
|
||||
$row = [0, 1, 2, 3, 4, 5, 6,
|
||||
'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238',
|
||||
'', ''];
|
||||
$parser = new AbnAmroDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('1232138 1232131233 412321 iBOOD.com iBOOD.com B.V.', $result[7]);
|
||||
@@ -127,7 +129,9 @@ class AbnAmroDescriptionTest extends TestCase
|
||||
*/
|
||||
public function testSepaBasicNoDescription(): void
|
||||
{
|
||||
$row = [0, 1, 2, 3, 4, 5, 6, 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: Kenmerk: 12-12-2014 21:03 002000 0213123238', '',''];
|
||||
$row = [0, 1, 2, 3, 4, 5, 6,
|
||||
'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: Kenmerk: 12-12-2014 21:03 002000 0213123238',
|
||||
'', ''];
|
||||
$parser = new AbnAmroDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals(' PLAIN: SEPA iDEAL - Silver Ocean B.V. (12-12-2014)', $result[7]);
|
||||
@@ -140,23 +144,27 @@ class AbnAmroDescriptionTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\AbnAmroDescription
|
||||
*/
|
||||
public function testTRTPBasic(): void {
|
||||
public function testTRTPBasic(): void
|
||||
{
|
||||
|
||||
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED', '',''];
|
||||
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED', '',
|
||||
''];
|
||||
$parser = new AbnAmroDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('Nullijn', $result[7]);
|
||||
$this->assertEquals('baasd dsdsT CJ', $result[8]);
|
||||
$this->assertEquals('NL23ABNA0000000000', $result[9]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic TRTP data with empty description
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\AbnAmroDescription
|
||||
*/
|
||||
public function testTRTPEmptyDescr(): void {
|
||||
public function testTRTPEmptyDescr(): void
|
||||
{
|
||||
|
||||
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI//EREF/NOTPROVIDED', '',''];
|
||||
$row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI//EREF/NOTPROVIDED', '', ''];
|
||||
$parser = new AbnAmroDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('SEPA OVERBOEKING - (NOTPROVIDED)', $result[7]);
|
||||
|
@@ -32,6 +32,52 @@ use Tests\TestCase;
|
||||
*/
|
||||
class IngDescriptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test changes to BA row.
|
||||
*
|
||||
* Remove specific fields.
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunBABasic(): void
|
||||
{
|
||||
$row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('XX XX', $result[8]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty description? Use "tegenrekening".
|
||||
* Remove specific fields.
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunEmptyDescr(): void
|
||||
{
|
||||
$row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('Bla bla', $result[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* See if the description is removed
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunGTRemoveDescr(): void
|
||||
{
|
||||
$iban = 'NL66INGB0665877351';
|
||||
$row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('Should be removed', $result[8]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try if the IBAN is removed in GT transactions
|
||||
*
|
||||
@@ -47,21 +93,6 @@ class IngDescriptionTest extends TestCase
|
||||
$this->assertEquals('Should be removed', $result[8]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try if the IBAN is removed in OV transactions
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunOVRemoveIban(): void
|
||||
{
|
||||
$iban = 'NL66INGB0665877351';
|
||||
$row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('Should be removed', $result[8]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try if the IBAN is removed in IC transactions
|
||||
*
|
||||
@@ -78,44 +109,14 @@ class IngDescriptionTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty description? Use "tegenrekening".
|
||||
* Remove specific fields.
|
||||
* Try if the IBAN is removed in OV transactions
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunEmptyDescr(): void
|
||||
{
|
||||
$row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('Bla bla', $result[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test changes to BA row.
|
||||
*
|
||||
* Remove specific fields.
|
||||
*
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunBABasic(): void
|
||||
{
|
||||
$row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals('XX XX', $result[8]);
|
||||
}
|
||||
|
||||
/**
|
||||
* See if the description is removed
|
||||
* @covers \FireflyIII\Import\Specifics\IngDescription
|
||||
*/
|
||||
public function testRunGTRemoveDescr(): void
|
||||
public function testRunOVRemoveIban(): void
|
||||
{
|
||||
$iban = 'NL66INGB0665877351';
|
||||
$row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
|
||||
$row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
|
||||
|
||||
$parser = new IngDescription;
|
||||
$result = $parser->run($row);
|
||||
|
@@ -36,20 +36,9 @@ class PresidentsChoiceTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
|
||||
*/
|
||||
public function testRunBasic():void {
|
||||
$row = [''];
|
||||
|
||||
$parser = new PresidentsChoice;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals($row, $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
|
||||
*/
|
||||
public function testRunAmount():void {
|
||||
$row = ['','Descr','12.34','',''];
|
||||
public function testRunAmount(): void
|
||||
{
|
||||
$row = ['', 'Descr', '12.34', '', ''];
|
||||
|
||||
$parser = new PresidentsChoice;
|
||||
$result = $parser->run($row);
|
||||
@@ -58,4 +47,17 @@ class PresidentsChoiceTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
|
||||
*/
|
||||
public function testRunBasic(): void
|
||||
{
|
||||
$row = [''];
|
||||
|
||||
$parser = new PresidentsChoice;
|
||||
$result = $parser->run($row);
|
||||
$this->assertEquals($row, $result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -155,8 +155,6 @@ class ImportArrayStorageTest extends TestCase
|
||||
$collector->shouldReceive('addFilter')->andReturnSelf();
|
||||
|
||||
|
||||
|
||||
|
||||
$storage = new ImportArrayStorage;
|
||||
$storage->setImportJob($job);
|
||||
$result = new Collection;
|
||||
@@ -409,7 +407,6 @@ class ImportArrayStorageTest extends TestCase
|
||||
$journalRepos->shouldReceive('findByHash')->andReturn(null)->times(2);
|
||||
|
||||
|
||||
|
||||
$storage = new ImportArrayStorage;
|
||||
$storage->setImportJob($job);
|
||||
$result = new Collection;
|
||||
|
@@ -23,10 +23,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Middleware;
|
||||
|
||||
use Log;
|
||||
use Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AuthenticateTest
|
||||
*/
|
||||
|
@@ -534,7 +534,7 @@ class BinderTest extends TestCase
|
||||
);
|
||||
|
||||
// mock fiscal helper:
|
||||
$date = new Carbon;
|
||||
$date = new Carbon;
|
||||
$helper = $this->mock(FiscalHelperInterface::class);
|
||||
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
|
||||
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
|
||||
|
@@ -44,15 +44,6 @@ class IsDemoUserTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser
|
||||
*/
|
||||
public function testMiddlewareNotAuthenticated(): void
|
||||
{
|
||||
$response = $this->get('/_test/is-demo');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser
|
||||
*/
|
||||
@@ -64,6 +55,15 @@ class IsDemoUserTest extends TestCase
|
||||
$response->assertSessionHas('info');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser
|
||||
*/
|
||||
public function testMiddlewareNotAuthenticated(): void
|
||||
{
|
||||
$response = $this->get('/_test/is-demo');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
|
@@ -25,10 +25,10 @@ namespace Tests\Unit\Middleware;
|
||||
|
||||
use FireflyIII\Http\Middleware\Sandstorm;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Mockery;
|
||||
use Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
|
||||
/**
|
||||
* Class RangeTest
|
||||
|
@@ -159,7 +159,7 @@ class TransactionUpdateServiceTest extends TestCase
|
||||
{
|
||||
/** @var Transaction $source */
|
||||
$source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||
$data = [
|
||||
$data = [
|
||||
'currency_id' => 1,
|
||||
'currency_code' => null,
|
||||
'description' => 'Some new description',
|
||||
@@ -187,7 +187,6 @@ class TransactionUpdateServiceTest extends TestCase
|
||||
$result = $service->update($source, $data);
|
||||
|
||||
|
||||
|
||||
$this->assertEquals($source->id, $result->id);
|
||||
$this->assertEquals($result->description, $data['description']);
|
||||
$this->assertEquals($data['foreign_amount'], $result->foreign_amount);
|
||||
@@ -202,7 +201,7 @@ class TransactionUpdateServiceTest extends TestCase
|
||||
{
|
||||
/** @var Transaction $source */
|
||||
$source = $this->user()->transactions()->where('amount', '<', 0)->inRandomOrder()->first();
|
||||
$data = [
|
||||
$data = [
|
||||
'currency_id' => 1,
|
||||
'currency_code' => null,
|
||||
'description' => 'Some new description',
|
||||
|
@@ -287,10 +287,10 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// data:
|
||||
$data = ['account_mapping' => [], 'apply_rules' => true,];
|
||||
$config = [
|
||||
'accounts' => [
|
||||
'accounts' => [
|
||||
0 => ['id' => 1234, 'name' => 'bunq'],
|
||||
],
|
||||
'apply-rules' => true,
|
||||
'apply-rules' => true,
|
||||
|
||||
];
|
||||
|
||||
|
@@ -27,7 +27,6 @@ namespace Tests\Unit\Support\Import\JobConfiguration\Bunq;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\JobConfiguration\Bunq\NewBunqJobHandler;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NewBunqJobHandlerTest extends TestCase
|
||||
|
@@ -43,6 +43,7 @@ class DoAuthenticateHandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* No token in config, but grab it from users preferences.
|
||||
*
|
||||
* @covers \FireflyIII\Support\Import\Information\GetSpectreTokenTrait
|
||||
* @covers \FireflyIII\Support\Import\JobConfiguration\Spectre\DoAuthenticateHandler
|
||||
*/
|
||||
|
@@ -69,6 +69,48 @@ class CurrencyMapperTest extends TestCase
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
|
||||
*/
|
||||
public function testEmpty(): void
|
||||
{
|
||||
|
||||
// mock data
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
|
||||
$result = $mapper->map(null, []);
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
|
||||
*/
|
||||
public function testFindAndCreate(): void
|
||||
{
|
||||
$currency = TransactionCurrency::inRandomOrder()->first();
|
||||
// mock data
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findBySymbolNull')->withArgs([$currency->symbol])->andReturn(null)->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])->andReturn(null)->once();
|
||||
$repository->shouldReceive('findByNameNull')->withArgs([$currency->name])->andReturn(null)->once();
|
||||
|
||||
// nothing found, mapper will try to create it.
|
||||
$repository->shouldReceive('store')
|
||||
->withArgs([['code' => $currency->code, 'name' => $currency->name, 'symbol' => $currency->symbol, 'decimal_places' => 2]])
|
||||
->once()->andReturn($currency);
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
|
||||
$result = $mapper->map(null, ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol]);
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
|
||||
*/
|
||||
@@ -79,7 +121,7 @@ class CurrencyMapperTest extends TestCase
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])
|
||||
->andReturn($currency)->once();
|
||||
->andReturn($currency)->once();
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
@@ -126,46 +168,4 @@ class CurrencyMapperTest extends TestCase
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
|
||||
*/
|
||||
public function testFindAndCreate(): void
|
||||
{
|
||||
$currency = TransactionCurrency::inRandomOrder()->first();
|
||||
// mock data
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findBySymbolNull')->withArgs([$currency->symbol])->andReturn(null)->once();
|
||||
$repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])->andReturn(null)->once();
|
||||
$repository->shouldReceive('findByNameNull')->withArgs([$currency->name])->andReturn(null)->once();
|
||||
|
||||
// nothing found, mapper will try to create it.
|
||||
$repository->shouldReceive('store')
|
||||
->withArgs([['code' => $currency->code, 'name' => $currency->name, 'symbol' => $currency->symbol,'decimal_places'=>2]])
|
||||
->once()->andReturn($currency);
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
|
||||
$result = $mapper->map(null, ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol]);
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
|
||||
*/
|
||||
public function testEmpty(): void
|
||||
{
|
||||
|
||||
// mock data
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
|
||||
$mapper = new CurrencyMapper();
|
||||
$mapper->setUser($this->user());
|
||||
|
||||
$result = $mapper->map(null, []);
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class ImportableCreatorTest extends TestCase
|
||||
*/
|
||||
public function testConvertSets(): void
|
||||
{
|
||||
$columnValue =new ColumnValue();
|
||||
$columnValue = new ColumnValue();
|
||||
$columnValue->setOriginalRole('account-name');
|
||||
$columnValue->setRole('account-id');
|
||||
$columnValue->setValue('Checking Account');
|
||||
@@ -47,13 +47,13 @@ class ImportableCreatorTest extends TestCase
|
||||
|
||||
$input = [
|
||||
[
|
||||
$columnValue
|
||||
]
|
||||
$columnValue,
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$creator = new ImportableCreator;
|
||||
$result = $creator->convertSets($input);
|
||||
$result = $creator->convertSets($input);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertInstanceOf(ImportTransaction::class, $result[0]);
|
||||
|
@@ -103,7 +103,7 @@ class MappingConvergerTest extends TestCase
|
||||
5 => 'USD',
|
||||
6 => 'SomeNumber',
|
||||
7 => 'I am a description',
|
||||
8 => 'IBANX'
|
||||
8 => 'IBANX',
|
||||
],
|
||||
[
|
||||
0 => 'CheckingX Account',
|
||||
@@ -114,7 +114,7 @@ class MappingConvergerTest extends TestCase
|
||||
5 => 'USA',
|
||||
6 => 'SomeANumber',
|
||||
7 => 'I am X description',
|
||||
8 => 'IBANXX'
|
||||
8 => 'IBANXX',
|
||||
],
|
||||
];
|
||||
|
||||
|
@@ -62,7 +62,7 @@ class OpposingAccountMapperTest extends TestCase
|
||||
*/
|
||||
public function testAccountIdBadType(): void
|
||||
{
|
||||
$expected = $this->user()->accounts()->where('account_type_id', 5)->inRandomOrder()->first();
|
||||
$expected = $this->user()->accounts()->where('account_type_id', 5)->inRandomOrder()->first();
|
||||
$expected->iban = null;
|
||||
$expected->save();
|
||||
$amount = '-12.34';
|
||||
@@ -160,30 +160,6 @@ class OpposingAccountMapperTest extends TestCase
|
||||
$mapper->map(null, $amount, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount = negative
|
||||
* ID = null
|
||||
* other data = null
|
||||
* Should call store() with "(no name") for expense account
|
||||
*
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\OpposingAccountMapper
|
||||
*/
|
||||
public function testFindByAccountNumber(): void
|
||||
{
|
||||
$expected = $this->user()->accounts()->where('account_type_id', 4)->inRandomOrder()->first();
|
||||
$amount = '-12.34';
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findByAccountNumber')->withArgs(['12345', [AccountType::EXPENSE]])
|
||||
->andReturn($expected)->once();
|
||||
|
||||
|
||||
$mapper = new OpposingAccountMapper;
|
||||
$mapper->setUser($this->user());
|
||||
$result = $mapper->map(null, $amount, ['number' => '12345']);
|
||||
$this->assertEquals($result->id, $expected->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount = positive
|
||||
* ID = null
|
||||
@@ -216,4 +192,28 @@ class OpposingAccountMapperTest extends TestCase
|
||||
$mapper->map(null, $amount, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount = negative
|
||||
* ID = null
|
||||
* other data = null
|
||||
* Should call store() with "(no name") for expense account
|
||||
*
|
||||
* @covers \FireflyIII\Support\Import\Routine\File\OpposingAccountMapper
|
||||
*/
|
||||
public function testFindByAccountNumber(): void
|
||||
{
|
||||
$expected = $this->user()->accounts()->where('account_type_id', 4)->inRandomOrder()->first();
|
||||
$amount = '-12.34';
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findByAccountNumber')->withArgs(['12345', [AccountType::EXPENSE]])
|
||||
->andReturn($expected)->once();
|
||||
|
||||
|
||||
$mapper = new OpposingAccountMapper;
|
||||
$mapper->setUser($this->user());
|
||||
$result = $mapper->map(null, $amount, ['number' => '12345']);
|
||||
$this->assertEquals($result->id, $expected->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class ClearBudgetTest extends TestCase
|
||||
$this->assertEquals(0, $journal->budgets()->count());
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach($journal->transactions as $transaction) {
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$this->assertEquals(0, $transaction->budgets()->count());
|
||||
}
|
||||
|
||||
|
@@ -56,7 +56,7 @@ class ClearCategoryTest extends TestCase
|
||||
$this->assertEquals(0, $journal->categories()->count());
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach($journal->transactions as $transaction) {
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
$this->assertEquals(0, $transaction->categories()->count());
|
||||
}
|
||||
}
|
||||
|
@@ -86,11 +86,11 @@ class BudgetIsTest extends TestCase
|
||||
|
||||
/** @var Collection $transactions */
|
||||
$transactions = $journal->transactions()->get();
|
||||
$budget = $journal->user->budgets()->first();
|
||||
$budget = $journal->user->budgets()->first();
|
||||
|
||||
$journal->budgets()->detach();
|
||||
/** @var Transaction $transaction */
|
||||
foreach($transactions as $transaction) {
|
||||
foreach ($transactions as $transaction) {
|
||||
$transaction->budgets()->detach();
|
||||
$transaction->budgets()->save($budget);
|
||||
$this->assertEquals(1, $transaction->budgets()->count());
|
||||
|
@@ -92,8 +92,8 @@ class FromAccountEndsTest extends TestCase
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$value = '';
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ class FromAccountEndsTest extends TestCase
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$value = 'x';
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ class FromAccountEndsTest extends TestCase
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$value = null;
|
||||
$result = FromAccountEnds::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class FromAccountIsTest
|
||||
*/
|
||||
@@ -76,8 +76,8 @@ class FromAccountIsTest extends TestCase
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$value = '';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ class FromAccountIsTest extends TestCase
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$value = 'x';
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ class FromAccountIsTest extends TestCase
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$value = null;
|
||||
$result = FromAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
@@ -103,8 +103,8 @@ class FromAccountStartsTest extends TestCase
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$value = '';
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ class FromAccountStartsTest extends TestCase
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$value = 'x';
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@ class FromAccountStartsTest extends TestCase
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$value = null;
|
||||
$result = FromAccountStarts::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
@@ -38,9 +38,9 @@ class HasAttachmentTest extends TestCase
|
||||
{
|
||||
do {
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$count = $journal->attachments()->count();
|
||||
} while($count !== 0);
|
||||
|
||||
$count = $journal->attachments()->count();
|
||||
} while ($count !== 0);
|
||||
|
||||
$attachment = $journal->user->attachments()->first();
|
||||
$journal->attachments()->save($attachment);
|
||||
$this->assertEquals(1, $journal->attachments()->count());
|
||||
@@ -58,8 +58,8 @@ class HasAttachmentTest extends TestCase
|
||||
do {
|
||||
// this is kind of cheating but OK.
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$count = $journal->attachments()->count();
|
||||
} while($count !== 0);
|
||||
$count = $journal->attachments()->count();
|
||||
} while ($count !== 0);
|
||||
|
||||
$this->assertEquals(0, $journal->attachments()->count());
|
||||
|
||||
|
@@ -74,8 +74,8 @@ class HasNoBudgetTest extends TestCase
|
||||
{
|
||||
$loopCount = 0;
|
||||
do {
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$count = $journal->transactions()->count();
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$count = $journal->transactions()->count();
|
||||
} while ($loopCount < 30 && $count !== 2);
|
||||
|
||||
$transactions = $journal->transactions()->get();
|
||||
|
@@ -77,8 +77,8 @@ class ToAccountContainsTest extends TestCase
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$value = '';
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ class ToAccountContainsTest extends TestCase
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$value = 'x';
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ class ToAccountContainsTest extends TestCase
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$value = null;
|
||||
$result = ToAccountContains::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class ToAccountIsTest
|
||||
@@ -48,7 +47,6 @@ class ToAccountIsTest extends TestCase
|
||||
$repository->shouldReceive('getJournalDestinationAccounts')->once()->andReturn($collection);
|
||||
|
||||
|
||||
|
||||
$trigger = ToAccountIs::makeFromStrings($account->name, false);
|
||||
$result = $trigger->triggered($journal);
|
||||
$this->assertTrue($result);
|
||||
@@ -78,8 +76,8 @@ class ToAccountIsTest extends TestCase
|
||||
public function testWillMatchEverythingEmpty(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = '';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$value = '';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
@@ -89,8 +87,8 @@ class ToAccountIsTest extends TestCase
|
||||
public function testWillMatchEverythingNotNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = 'x';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$value = 'x';
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
@@ -100,8 +98,8 @@ class ToAccountIsTest extends TestCase
|
||||
public function testWillMatchEverythingNull(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$value = null;
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$value = null;
|
||||
$result = ToAccountIs::willMatchEverything($value);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,6 @@ namespace Tests\Unit\Transformers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Transformers\BillTransformer;
|
||||
use Illuminate\Support\Collection;
|
||||
|
Reference in New Issue
Block a user