mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage.
This commit is contained in:
@@ -76,6 +76,7 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
// mock facades.
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($currency);
|
||||
Preferences::shouldReceive('mark');
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -110,6 +111,9 @@ class CurrencyControllerTest extends TestCase
|
||||
$transformer = $this->mock(CurrencyTransformer::class);
|
||||
$userRepository = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock facades.
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($currency);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
|
||||
@@ -124,8 +128,8 @@ class CurrencyControllerTest extends TestCase
|
||||
$repository->shouldReceive('store')->andReturn($currency);
|
||||
Preferences::shouldReceive('set')->withArgs(['currencyPreference', 'EUR'])->once();
|
||||
Preferences::shouldReceive('mark')->once();
|
||||
Preferences::shouldReceive('lastActivity')->once();
|
||||
Preferences::shouldReceive('getForUser')->once()->andReturn($preference);
|
||||
//Preferences::shouldReceive('lastActivity')->once();
|
||||
//Preferences::shouldReceive('getForUser')->once()->andReturn($preference);
|
||||
|
||||
// data to submit:
|
||||
$data = [
|
||||
@@ -162,6 +166,8 @@ class CurrencyControllerTest extends TestCase
|
||||
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
Preferences::shouldReceive('mark');
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($currency);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
@@ -210,8 +216,9 @@ class CurrencyControllerTest extends TestCase
|
||||
$repository->shouldReceive('update')->andReturn($currency);
|
||||
Preferences::shouldReceive('set')->withArgs(['currencyPreference', 'EUR'])->once();
|
||||
Preferences::shouldReceive('mark')->once();
|
||||
Preferences::shouldReceive('lastActivity')->once();
|
||||
Preferences::shouldReceive('getForUser')->once()->andReturn($preference);
|
||||
//Preferences::shouldReceive('lastActivity')->once();
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($currency);
|
||||
//Preferences::shouldReceive('getForUser')->once()->andReturn($preference);
|
||||
|
||||
// data to submit:
|
||||
$data = [
|
||||
|
@@ -24,17 +24,18 @@ declare(strict_types=1);
|
||||
namespace Tests\Api\V1\Controllers;
|
||||
|
||||
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||
use FireflyIII\Jobs\Job;
|
||||
use FireflyIII\Models\Rule;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||
use FireflyIII\Transformers\RuleTransformer;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Queue;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -117,6 +118,7 @@ class RuleControllerTest extends TestCase
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(RuleTransformer::class);
|
||||
Preferences::shouldReceive('mark');
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
@@ -250,8 +252,23 @@ class RuleControllerTest extends TestCase
|
||||
$rule = $this->user()->rules()->first();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$expense = $this->getRandomExpense();
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
Preferences::shouldReceive('mark');
|
||||
|
||||
// new mocks for ruleEngine
|
||||
$ruleEngine->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setRulesToApply')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setTriggerMode')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('processJournalArray')->atLeast()->once();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->atLeast()->once();
|
||||
$collector->shouldReceive('setRange')->atLeast()->once();
|
||||
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn([['x']]);
|
||||
|
||||
|
||||
$asset = $this->getRandomAsset();
|
||||
$expense = $this->getRandomExpense();
|
||||
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
@@ -259,16 +276,8 @@ class RuleControllerTest extends TestCase
|
||||
$repository->shouldReceive('findNull')->withArgs([2])->andReturn($expense);
|
||||
$repository->shouldReceive('findNull')->withArgs([3])->andReturn(null);
|
||||
|
||||
Queue::fake();
|
||||
|
||||
$response = $this->post(route('api.v1.rules.trigger', [$rule->id]) . '?accounts=1,2,3&start_date=2019-01-01&end_date=2019-01-02');
|
||||
$response->assertStatus(204);
|
||||
|
||||
Queue::assertPushed(
|
||||
ExecuteRuleOnExistingTransactions::class, function (Job $job) use ($rule) {
|
||||
return $job->getRule()->id === $rule->id;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,12 +24,14 @@ declare(strict_types=1);
|
||||
namespace Tests\Api\V1\Controllers;
|
||||
|
||||
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||
use FireflyIII\Jobs\Job;
|
||||
use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||
use FireflyIII\Transformers\RuleGroupTransformer;
|
||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||
@@ -171,6 +173,21 @@ class RuleGroupControllerTest extends TestCase
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$matcher = $this->mock(TransactionMatcher::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
|
||||
|
||||
// new mocks for ruleEngine
|
||||
$ruleEngine->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setRulesToApply')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setTriggerMode')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('processJournalArray')->atLeast()->once();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->atLeast()->once();
|
||||
$collector->shouldReceive('setRange')->atLeast()->once();
|
||||
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn([['x']]);
|
||||
|
||||
|
||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$ruleGroupRepos->shouldReceive('getActiveRules')->once()->andReturn(new Collection([$rule]));
|
||||
@@ -181,16 +198,9 @@ class RuleGroupControllerTest extends TestCase
|
||||
$repository->shouldReceive('isAsset')->withArgs([1])->andReturn(true);
|
||||
$repository->shouldReceive('isAsset')->withArgs([2])->andReturn(false);
|
||||
|
||||
Queue::fake();
|
||||
$response = $this->post(route('api.v1.rule_groups.trigger', [$group->id]) . '?accounts=1,2,3&start_date=2019-01-01&end_date=2019-01-02');
|
||||
$response->assertStatus(204);
|
||||
|
||||
|
||||
Queue::assertPushed(
|
||||
ExecuteRuleOnExistingTransactions::class, function (Job $job) use ($rule) {
|
||||
return $job->getRule()->id === $rule->id;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,16 +24,16 @@ declare(strict_types=1);
|
||||
namespace tests\Feature\Controllers\Rule;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||
use FireflyIII\Jobs\Job;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
@@ -61,10 +61,23 @@ class SelectControllerTest extends TestCase
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$this->mockDefaultSession();
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
|
||||
|
||||
$this->session(['first' => new Carbon('2010-01-01')]);
|
||||
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
|
||||
Queue::fake();
|
||||
|
||||
// new mocks for ruleEngine
|
||||
$ruleEngine->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setRulesToApply')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setTriggerMode')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('processJournalArray')->atLeast()->once();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->atLeast()->once();
|
||||
$collector->shouldReceive('setRange')->atLeast()->once();
|
||||
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn([['x']]);
|
||||
|
||||
|
||||
$data = [
|
||||
'accounts' => [1],
|
||||
@@ -77,11 +90,6 @@ class SelectControllerTest extends TestCase
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
Queue::assertPushed(
|
||||
ExecuteRuleOnExistingTransactions::class, function (Job $job) {
|
||||
return 1 === $job->getRule()->id;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -23,14 +23,19 @@ namespace Tests\Feature\Controllers\RuleGroup;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ExecutionControllerTest
|
||||
*/
|
||||
class ExecutionControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
@@ -50,9 +55,21 @@ class ExecutionControllerTest extends TestCase
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection);
|
||||
|
||||
$this->expectsJobs(ExecuteRuleGroupOnExistingTransactions::class);
|
||||
// new mocks for ruleEngine
|
||||
$ruleEngine->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setRulesToApply')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('setTriggerMode')->atLeast()->once();
|
||||
$ruleEngine->shouldReceive('processJournalArray')->atLeast()->once();
|
||||
|
||||
$collector->shouldReceive('setAccounts')->atLeast()->once();
|
||||
$collector->shouldReceive('setRange')->atLeast()->once();
|
||||
$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn([['x']]);
|
||||
|
||||
$this->session(['first' => new Carbon('2010-01-01')]);
|
||||
$data = [
|
||||
|
@@ -39,6 +39,7 @@ use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Recurrence;
|
||||
@@ -66,6 +67,13 @@ use RuntimeException;
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @return ImportJob
|
||||
*/
|
||||
public function getRandomImportJob(): ImportJob
|
||||
{
|
||||
return $this->user()->importJobs()->inRandomOrder()->first();
|
||||
}
|
||||
/**
|
||||
* @return Recurrence
|
||||
*/
|
||||
|
@@ -102,6 +102,6 @@ class PiggyBankFactoryTest extends TestCase
|
||||
/** @var PiggyBankFactory $factory */
|
||||
$factory = app(PiggyBankFactory::class);
|
||||
$factory->setUser($this->user());
|
||||
$this->assertNull($factory->find(null, 'I dont exist.' . random_int(1, 10000)));
|
||||
$this->assertNull($factory->find(null, 'I dont exist.' . $this->randomInt()));
|
||||
}
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ class AttachmentHelperTest extends TestCase
|
||||
'attachable_id' => $journal->id,
|
||||
'user_id' => $this->user()->id,
|
||||
'attachable_type' => TransactionJournal::class,
|
||||
'md5' => md5('Hello' . random_int(1, 10000)),
|
||||
'md5' => md5('Hello' . $this->randomInt()),
|
||||
'filename' => 'file.txt',
|
||||
'title' => 'Some title',
|
||||
'description' => 'Some descr',
|
||||
@@ -151,7 +151,7 @@ class AttachmentHelperTest extends TestCase
|
||||
'attachable_id' => $journal->id,
|
||||
'user_id' => $this->user()->id,
|
||||
'attachable_type' => TransactionJournal::class,
|
||||
'md5' => md5('Hello' . random_int(1, 10000)),
|
||||
'md5' => md5('Hello' . $this->randomInt()),
|
||||
'filename' => 'file.txt',
|
||||
'title' => 'Some title',
|
||||
'description' => 'Some descr',
|
||||
|
@@ -25,12 +25,13 @@ namespace Tests\Unit\Import\Routine;
|
||||
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Import\Routine\BunqRoutine;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Import\Routine\FileRoutine;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Support\Import\Routine\Bunq\StageImportDataHandler;
|
||||
use FireflyIII\Support\Import\Routine\File\CSVProcessor;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
@@ -60,7 +61,7 @@ class FileRoutineTest extends TestCase
|
||||
$job->key = 'brY_' . $this->randomInt();
|
||||
$job->status = 'ready_to_run';
|
||||
$job->stage = 'go-for-import';
|
||||
$job->provider = 'bunq';
|
||||
$job->provider = 'file';
|
||||
$job->file_type = '';
|
||||
$job->configuration = [];
|
||||
$job->save();
|
||||
@@ -68,19 +69,27 @@ class FileRoutineTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
$handler = $this->mock(StageImportDataHandler::class);
|
||||
$this->mock(AttachmentHelperInterface::class);
|
||||
$csv = $this->mock(CSVProcessor::class);
|
||||
|
||||
$csv->shouldReceive('setImportJob')->atLeast()->once();
|
||||
$csv->shouldReceive('run')->atLeast()->once();
|
||||
|
||||
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running']);
|
||||
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'provider_finished']);
|
||||
$repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'final']);
|
||||
$repository->shouldReceive('appendTransactions')->withArgs([Mockery::any(), ['a' => 'c']])->once();
|
||||
$repository->shouldReceive('getConfiguration')->atLeast()->once()->andReturn([]);
|
||||
//$repository->shouldReceive('getAttachments')->atLeast()->once()->andReturn(new Collection);
|
||||
$repository->shouldReceive('setTransactions')->atLeast()->once();
|
||||
//$repository->shouldReceive('appendTransactions')->withArgs([Mockery::any(), ['a' => 'c']])->once();
|
||||
|
||||
$handler->shouldReceive('setImportJob')->once();
|
||||
$handler->shouldReceive('run')->once();
|
||||
$handler->shouldReceive('getTransactions')->once()->andReturn(['a' => 'c']);
|
||||
//$handler->shouldReceive('setImportJob')->once();
|
||||
//$handler->shouldReceive('run')->once();
|
||||
//$handler->shouldReceive('getTransactions')->once()->andReturn(['a' => 'c']);
|
||||
$handler->shouldReceive('isStillRunning')->andReturn(false);
|
||||
$routine = new BunqRoutine;
|
||||
$routine = new FileRoutine;
|
||||
$routine->setImportJob($job);
|
||||
try {
|
||||
$routine->run();
|
||||
|
@@ -80,12 +80,23 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
/**
|
||||
* Submit one, but offer no occurrences.
|
||||
*
|
||||
* TODO there is a random element in this test that breaks the test.
|
||||
*
|
||||
* @covers \FireflyIII\Jobs\CreateRecurringTransactions
|
||||
*/
|
||||
public function testSingle(): void
|
||||
{
|
||||
Log::info(sprintf('Now in test %s.', __METHOD__));
|
||||
// mock classes
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$date = new Carbon;
|
||||
$date->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $date;
|
||||
$recurrence->save();
|
||||
|
||||
Log::debug(sprintf('Test is going to use Recurrence #%d', $recurrence->id), $recurrence->toArray());
|
||||
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$groupRepos = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
@@ -308,7 +319,14 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
$date = new Carbon();
|
||||
$this->expectsEvents([StoredTransactionGroup::class]);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
// mock classes
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
@@ -359,11 +377,21 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
*/
|
||||
public function testForced(): void
|
||||
{
|
||||
Log::info(sprintf('Now in test %s.', __METHOD__));
|
||||
Event::fake();
|
||||
$date = new Carbon();
|
||||
$this->expectsEvents([StoredTransactionGroup::class]);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
// overrule some fields in the recurrence.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
@@ -418,11 +446,12 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
Event::fake();
|
||||
$date = new Carbon();
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
// mock classes
|
||||
@@ -459,11 +488,12 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
$tomorrow = new Carbon();
|
||||
$tomorrow->addDays(2);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
// mock classes
|
||||
@@ -503,12 +533,16 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
$date = new Carbon();
|
||||
$this->expectsEvents([StoredTransactionGroup::class]);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
$piggy = $this->getRandomPiggyBank();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
// mock classes
|
||||
|
@@ -1537,6 +1537,8 @@ class BinderTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO there is a random element in this test that breaks the middleware.
|
||||
*
|
||||
* @covers \FireflyIII\Http\Middleware\Binder
|
||||
* @covers \FireflyIII\Support\Binder\TagOrId
|
||||
*/
|
||||
|
344
tests/Unit/Rules/BelongsUserTest.php
Normal file
344
tests/Unit/Rules/BelongsUserTest.php
Normal file
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
/**
|
||||
* BelongsUserTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Rules;
|
||||
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Rules\BelongsUser;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class BelongsUserTest
|
||||
*/
|
||||
class BelongsUserTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBillId(): void
|
||||
{
|
||||
$attribute = 'bill_id';
|
||||
$bill = $this->getRandomBill();
|
||||
$value = $bill->id;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBillIdFalse(): void
|
||||
{
|
||||
$attribute = 'bill_id';
|
||||
$value = '-1';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBillName(): void
|
||||
{
|
||||
$attribute = 'bill_name';
|
||||
$bill = $this->getRandomBill();
|
||||
$value = $bill->name;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBillNameFalse(): void
|
||||
{
|
||||
$attribute = 'bill_name';
|
||||
$value = 'Some random name';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testAccountIdFalse(): void
|
||||
{
|
||||
$attribute = 'source_id';
|
||||
$value = '-1';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testAccountId(): void
|
||||
{
|
||||
$attribute = 'destination_id';
|
||||
$asset =$this->getRandomAsset();
|
||||
$value = $asset->id;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBudgetId(): void
|
||||
{
|
||||
$attribute = 'budget_id';
|
||||
$budget = $this->getRandomBudget();
|
||||
$value = $budget->id;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBudgetIdFalse(): void
|
||||
{
|
||||
$attribute = 'budget_id';
|
||||
$value = '-1';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBudgetName(): void
|
||||
{
|
||||
$attribute = 'budget_name';
|
||||
$budget = $this->getRandomBudget();
|
||||
$value = $budget->name;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testBudgetNameFalse(): void
|
||||
{
|
||||
$attribute = 'budget_name';
|
||||
$value = 'Some random budget';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testCategoryId(): void
|
||||
{
|
||||
$attribute = 'category_id';
|
||||
$category = $this->getRandomCategory();
|
||||
$value = $category->id;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testCategoryIdFalse(): void
|
||||
{
|
||||
$attribute = 'category_id';
|
||||
$value = '-1';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testPiggyBankId(): void
|
||||
{
|
||||
$attribute = 'piggy_bank_id';
|
||||
$piggyBank = $this->getRandomPiggyBank();
|
||||
$value = $piggyBank->id;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testPiggyBankIdFalse(): void
|
||||
{
|
||||
$attribute = 'piggy_bank_id';
|
||||
$value = '-1';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testPiggyBankIdLongAttribute(): void
|
||||
{
|
||||
$attribute = 'a.b.piggy_bank_id';
|
||||
$piggyBank = $this->getRandomPiggyBank();
|
||||
$value = $piggyBank->id;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testPiggyBankName(): void
|
||||
{
|
||||
$attribute = 'piggy_bank_name';
|
||||
$piggyBank = $this->getRandomPiggyBank();
|
||||
$value = $piggyBank->name;
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\BelongsUser
|
||||
*/
|
||||
public function testPiggyBankNameFalse(): void
|
||||
{
|
||||
$attribute = 'piggy_bank_name';
|
||||
$value = 'Some random name';
|
||||
|
||||
$this->be($this->user());
|
||||
$engine = new BelongsUser;
|
||||
try {
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
} catch (FireflyException $e) {
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
83
tests/Unit/Rules/IsAssetAccountIdTest.php
Normal file
83
tests/Unit/Rules/IsAssetAccountIdTest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* IsAssetAccountIdTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Rules;
|
||||
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Rules\IsAssetAccountId;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class IsAssetAccountIdTest
|
||||
*/
|
||||
class IsAssetAccountIdTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsAssetAccountId
|
||||
*/
|
||||
public function testNotAsset(): void
|
||||
{
|
||||
$attribute = 'not-used';
|
||||
$expense = $this->getRandomExpense();
|
||||
$value = $expense->id;
|
||||
|
||||
$engine = new IsAssetAccountId();
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsAssetAccountId
|
||||
*/
|
||||
public function testAsset(): void
|
||||
{
|
||||
$attribute = 'not-used';
|
||||
$asset = $this->getRandomAsset();
|
||||
$value = $asset->id;
|
||||
|
||||
$engine = new IsAssetAccountId();
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsAssetAccountId
|
||||
*/
|
||||
public function testNull(): void
|
||||
{
|
||||
$attribute = 'not-used';
|
||||
$value = '-1';
|
||||
|
||||
$engine = new IsAssetAccountId();
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
}
|
78
tests/Unit/Rules/IsBooleanTest.php
Normal file
78
tests/Unit/Rules/IsBooleanTest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* IsBooleanTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Rules;
|
||||
|
||||
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Rules\IsBoolean;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class IsBooleanTest
|
||||
*/
|
||||
class IsBooleanTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsBoolean
|
||||
*/
|
||||
public function testFalse(): void
|
||||
{
|
||||
$attribute = 'not-important';
|
||||
|
||||
$false = ['not', 2, -1, []];
|
||||
|
||||
/** @var mixed $value */
|
||||
foreach ($false as $value) {
|
||||
|
||||
$engine = new IsBoolean();
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsBoolean
|
||||
*/
|
||||
public function testTrue(): void
|
||||
{
|
||||
$attribute = 'not-important';
|
||||
|
||||
$true = [true, false, 0, 1, '0', '1', 'true', 'false', 'yes', 'no', 'on', 'off'];
|
||||
|
||||
/** @var mixed $value */
|
||||
foreach ($true as $value) {
|
||||
|
||||
$engine = new IsBoolean();
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
74
tests/Unit/Rules/IsDateOrTimeTest.php
Normal file
74
tests/Unit/Rules/IsDateOrTimeTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* IsDateOrTimeTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Rules;
|
||||
|
||||
|
||||
use FireflyIII\Rules\IsDateOrTime;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class IsDateOrTimeTest
|
||||
*/
|
||||
class IsDateOrTimeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsDateOrTime
|
||||
*/
|
||||
public function testFalse(): void
|
||||
{
|
||||
$attribute = 'not-important';
|
||||
$values = ['20xx-01-x','1234567890', '2xx0101', '', false];
|
||||
|
||||
/** @var mixed $value */
|
||||
foreach ($values as $value) {
|
||||
$engine = new IsDateOrTime();
|
||||
$this->assertFalse($engine->passes($attribute, $value), $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsDateOrTime
|
||||
*/
|
||||
public function testTrue(): void
|
||||
{
|
||||
$attribute = 'not-important';
|
||||
$values = ['2019-01-01', '20190101', '2019-01-01 12:12:12', '12:12:12'];
|
||||
|
||||
/** @var mixed $value */
|
||||
foreach ($values as $value) {
|
||||
$engine = new IsDateOrTime();
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
164
tests/Unit/Rules/IsValidAttachmentModelTest.php
Normal file
164
tests/Unit/Rules/IsValidAttachmentModelTest.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* IsValidAttachmentModelTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Rules;
|
||||
|
||||
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Rules\IsValidAttachmentModel;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class IsValidAttachmentModelTest
|
||||
*/
|
||||
class IsValidAttachmentModelTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testBillFull(): void
|
||||
{
|
||||
$bill = $this->getRandomBill();
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
|
||||
$billRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$billRepos->shouldReceive('find')->atLeast()->once()->withArgs([$bill->id])->andReturn($bill);
|
||||
|
||||
$value = $bill->id;
|
||||
$attribute = 'not-important';
|
||||
$this->be($this->user());
|
||||
$engine = new IsValidAttachmentModel(Bill::class);
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testImportJob(): void
|
||||
{
|
||||
$job = $this->getRandomImportJob();
|
||||
$jobRepos = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
$jobRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$jobRepos->shouldReceive('find')->atLeast()->once()->withArgs([$job->id])->andReturn($job);
|
||||
|
||||
$value = $job->id;
|
||||
$attribute = 'not-important';
|
||||
$this->be($this->user());
|
||||
$engine = new IsValidAttachmentModel(ImportJob::class);
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testTransaction(): void
|
||||
{
|
||||
$transaction = $this->getRandomWithdrawal()->transactions()->first();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('findTransaction')->atLeast()->once()->withArgs([$transaction->id])->andReturn($transaction);
|
||||
|
||||
$value = $transaction->id;
|
||||
$attribute = 'not-important';
|
||||
$this->be($this->user());
|
||||
$engine = new IsValidAttachmentModel(Transaction::class);
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testTransactionJournal(): void
|
||||
{
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('findNull')->atLeast()->once()->withArgs([$journal->id])->andReturn($journal);
|
||||
|
||||
$value = $journal->id;
|
||||
$attribute = 'not-important';
|
||||
$this->be($this->user());
|
||||
$engine = new IsValidAttachmentModel(TransactionJournal::class);
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testBadModel(): void
|
||||
{
|
||||
$value = '123';
|
||||
$attribute = 'not-important';
|
||||
$this->be($this->user());
|
||||
$engine = new IsValidAttachmentModel('False');
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testBillPartial(): void
|
||||
{
|
||||
$bill = $this->getRandomBill();
|
||||
$billRepos = $this->mock(BillRepositoryInterface::class);
|
||||
|
||||
$billRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$billRepos->shouldReceive('find')->atLeast()->once()->withAnyArgs([$bill->id])->andReturn($bill);
|
||||
|
||||
$value = $bill->id;
|
||||
$attribute = 'not-important';
|
||||
$this->be($this->user());
|
||||
$engine = new IsValidAttachmentModel('Bill');
|
||||
$this->assertTrue($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\IsValidAttachmentModel
|
||||
*/
|
||||
public function testNotLoggedIn(): void
|
||||
{
|
||||
$value = '1';
|
||||
$attribute = 'not-important';
|
||||
$engine = new IsValidAttachmentModel(Bill::class);
|
||||
$this->assertFalse($engine->passes($attribute, $value));
|
||||
}
|
||||
|
||||
}
|
150
tests/Unit/Rules/UniqueIbanTest.php
Normal file
150
tests/Unit/Rules/UniqueIbanTest.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* UniqueIbanTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Rules;
|
||||
|
||||
|
||||
use FireflyIII\Rules\UniqueIban;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class UniqueIbanTest
|
||||
*/
|
||||
class UniqueIbanTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\UniqueIban
|
||||
*/
|
||||
public function testBasic(): void
|
||||
{
|
||||
$asset = $this->getRandomAsset();
|
||||
$iban = $asset->iban;
|
||||
$asset->iban = 'NL123';
|
||||
$asset->save();
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
$engine = new UniqueIban(null, 'asset');
|
||||
$this->assertFalse($engine->passes('not-important', $asset->iban));
|
||||
|
||||
$asset->iban = $iban;
|
||||
$asset->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\UniqueIban
|
||||
*/
|
||||
public function testBasicSkipExisting(): void
|
||||
{
|
||||
$asset = $this->getRandomAsset();
|
||||
$iban = $asset->iban;
|
||||
$asset->iban = 'NL123';
|
||||
$asset->save();
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
$engine = new UniqueIban($asset, 'asset');
|
||||
$this->assertTrue($engine->passes('not-important', $asset->iban));
|
||||
|
||||
$asset->iban = $iban;
|
||||
$asset->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\UniqueIban
|
||||
*/
|
||||
public function testRevenue(): void
|
||||
{
|
||||
// give revenue account new IBAN.
|
||||
// should be OK to give it to an expense account
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$iban = $revenue->iban;
|
||||
$revenue->iban = 'NL123';
|
||||
$revenue->save();
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
// returns true because this mix is OK.
|
||||
$engine = new UniqueIban(null, 'expense');
|
||||
$this->assertTrue($engine->passes('not-important', 'NL123'));
|
||||
|
||||
|
||||
$revenue->iban = $iban;
|
||||
$revenue->save();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\UniqueIban
|
||||
*/
|
||||
public function testExpense(): void
|
||||
{
|
||||
// give expense account new IBAN.
|
||||
// should be OK to give it to an expense account
|
||||
$expense = $this->getRandomExpense();
|
||||
$iban = $expense->iban;
|
||||
$expense->iban = 'NL123';
|
||||
$expense->save();
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
// returns true because this mix is OK.
|
||||
$engine = new UniqueIban(null, 'revenue');
|
||||
$this->assertTrue($engine->passes('not-important', 'NL123'));
|
||||
|
||||
$expense->iban = $iban;
|
||||
$expense->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Rules\UniqueIban
|
||||
*/
|
||||
public function testRevenueAsset(): void
|
||||
{
|
||||
// give revenue account new IBAN.
|
||||
// should be OK to give it to an expense account
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$iban = $revenue->iban;
|
||||
$revenue->iban = 'NL123';
|
||||
$revenue->save();
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
// returns false because this mix is not OK.
|
||||
$engine = new UniqueIban(null, 'asset');
|
||||
$this->assertFalse($engine->passes('not-important', 'NL123'));
|
||||
|
||||
|
||||
$revenue->iban = $iban;
|
||||
$revenue->save();
|
||||
}
|
||||
|
||||
}
|
@@ -24,9 +24,11 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\Services\Internal\Destroy;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\RecurrenceTransaction;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
|
||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use FireflyIII\Services\Internal\Destroy\RecurrenceDestroyService;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -49,8 +51,9 @@ class AccountDestroyServiceTest extends TestCase
|
||||
*/
|
||||
public function testDestroyBasic(): void
|
||||
{
|
||||
$this->mock(RecurrenceDestroyService::class);
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . $this->randomInt(),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
/** @var AccountDestroyService $service */
|
||||
@@ -60,14 +63,51 @@ class AccountDestroyServiceTest extends TestCase
|
||||
$this->assertDatabaseMissing('accounts', ['id' => $account->id, 'deleted_at' => null]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Destroy\AccountDestroyService
|
||||
*/
|
||||
public function testDestroyWithRecurrence(): void
|
||||
{
|
||||
$recService = $this->mock(RecurrenceDestroyService::class);
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . $this->randomInt(),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrenceTransaction = RecurrenceTransaction::create(
|
||||
[
|
||||
'recurrence_id' => $recurrence->id,
|
||||
'transaction_currency_id' => $this->getEuro()->id,
|
||||
'source_id' => $account->id,
|
||||
'destination_id' => $account->id,
|
||||
'amount' => 10,
|
||||
'description' => 'Hello',
|
||||
]
|
||||
);
|
||||
|
||||
$recService->shouldReceive('destroyById')->once()
|
||||
->withAnyArgs([$recurrenceTransaction->id]);
|
||||
|
||||
/** @var AccountDestroyService $service */
|
||||
$service = app(AccountDestroyService::class);
|
||||
$service->destroy($account, null);
|
||||
|
||||
$this->assertDatabaseMissing('accounts', ['id' => $account->id, 'deleted_at' => null]);
|
||||
|
||||
$recurrenceTransaction->forceDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Destroy\AccountDestroyService
|
||||
*/
|
||||
public function testDestroyDontMove(): void
|
||||
{
|
||||
$this->mock(RecurrenceDestroyService::class);
|
||||
// create objects:
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . $this->randomInt(),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
Transaction::create(['account_id' => $account->id, 'transaction_journal_id' => 1, 'amount' => 10, 'transaction_currency_id' => 1]);
|
||||
@@ -88,12 +128,13 @@ class AccountDestroyServiceTest extends TestCase
|
||||
*/
|
||||
public function testDestroyMove(): void
|
||||
{
|
||||
$this->mock(RecurrenceDestroyService::class);
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . $this->randomInt(),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
$move = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . $this->randomInt(),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
$transaction = Transaction::create(['account_id' => $account->id, 'transaction_journal_id' => 1, 'amount' => 10, 'transaction_currency_id' => 1]);
|
||||
|
@@ -29,7 +29,9 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
|
||||
use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\AccountUpdateService;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
@@ -54,36 +56,22 @@ class AccountUpdateServiceTest extends TestCase
|
||||
*/
|
||||
public function testDeleteExistingIB(): void
|
||||
{
|
||||
/** @var Account $account */
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
$opposing = $this->user()->accounts()->first();
|
||||
$journal = TransactionJournal::create(
|
||||
['user_id' => $this->user()->id, 'transaction_type_id' => 4, 'transaction_currency_id' => 1, 'description' => 'IB',
|
||||
'date' => '2018-01-01', 'completed' => true, 'tag_count' => 0,
|
||||
]
|
||||
);
|
||||
// transactions:
|
||||
Transaction::create(
|
||||
['account_id' => $account->id, 'transaction_journal_id' => $journal->id,
|
||||
'transaction_currency_id' => 1, 'amount' => '100', 'identifier' => 0,]
|
||||
);
|
||||
Transaction::create(
|
||||
['account_id' => $opposing->id, 'transaction_journal_id' => $journal->id,
|
||||
'transaction_currency_id' => 1, 'amount' => '-100', 'identifier' => 0,]
|
||||
);
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$destroySerice = $this->mock(TransactionGroupDestroyService::class);
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceGroup')->atLeast()->once()->andReturn($group);
|
||||
$destroySerice->shouldReceive('destroy')->atLeast()->once();
|
||||
$account = $this->getRandomAsset();
|
||||
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
'name' => 'Some new name #' . $this->randomInt(),
|
||||
'active' => true,
|
||||
'virtual_balance' => '0',
|
||||
'iban' => null,
|
||||
'account_role' => 'defaultAsset',
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
@@ -91,7 +79,6 @@ class AccountUpdateServiceTest extends TestCase
|
||||
$account = $service->update($account, $data);
|
||||
|
||||
$this->assertEquals($data['name'], $account->name);
|
||||
$this->assertEquals(0, $account->transactions()->count());
|
||||
/** @var Note $note */
|
||||
$note = $account->notes()->first();
|
||||
$this->assertEquals($data['notes'], $note->text);
|
||||
@@ -106,11 +93,11 @@ class AccountUpdateServiceTest extends TestCase
|
||||
/** @var Account $account */
|
||||
$account = $this->user()->accounts()->first();
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'name' => 'Some new name #' . $this->randomInt(),
|
||||
'active' => true,
|
||||
'virtual_balance' => '0',
|
||||
'iban' => null,
|
||||
'account_role' => 'defaultAsset',
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
@@ -129,12 +116,12 @@ class AccountUpdateServiceTest extends TestCase
|
||||
/** @var Account $account */
|
||||
$account = $this->user()->accounts()->first();
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'notes' => '',
|
||||
'name' => 'Some new name #' . $this->randomInt(),
|
||||
'active' => true,
|
||||
'virtual_balance' => '0',
|
||||
'iban' => null,
|
||||
'account_role' => 'defaultAsset',
|
||||
'notes' => '',
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
@@ -159,12 +146,12 @@ class AccountUpdateServiceTest extends TestCase
|
||||
$note->save();
|
||||
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'notes' => '',
|
||||
'name' => 'Some new name #' . $this->randomInt(),
|
||||
'active' => true,
|
||||
'virtual_balance' => '0',
|
||||
'iban' => null,
|
||||
'account_role' => 'defaultAsset',
|
||||
'notes' => '',
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
@@ -182,38 +169,27 @@ class AccountUpdateServiceTest extends TestCase
|
||||
*/
|
||||
public function testUpdateExistingIB(): void
|
||||
{
|
||||
/** @var Account $account */
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
$opposing = $this->user()->accounts()->first();
|
||||
$journal = TransactionJournal::create(
|
||||
['user_id' => $this->user()->id, 'transaction_type_id' => 4, 'transaction_currency_id' => 1, 'description' => 'IB',
|
||||
'date' => '2018-01-01', 'completed' => true, 'tag_count' => 0,
|
||||
]
|
||||
);
|
||||
// transactions:
|
||||
Transaction::create(
|
||||
['account_id' => $account->id, 'transaction_journal_id' => $journal->id,
|
||||
'transaction_currency_id' => 1, 'amount' => '100', 'identifier' => 0,]
|
||||
);
|
||||
Transaction::create(
|
||||
['account_id' => $opposing->id, 'transaction_journal_id' => $journal->id,
|
||||
'transaction_currency_id' => 1, 'amount' => '-100', 'identifier' => 0,]
|
||||
);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$destroySerice = $this->mock(TransactionGroupDestroyService::class);
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// make sure one transaction has the account as the asset.
|
||||
$journal = $group->transactionJournals()->first();
|
||||
$account = $journal->transactions()->first()->account;
|
||||
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('getOpeningBalanceGroup')->atLeast()->once()->andReturn($group);
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'openingBalance' => '105',
|
||||
'openingBalanceDate' => new Carbon('2018-01-01'),
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
'name' => 'Some new name #' . $this->randomInt(),
|
||||
'active' => true,
|
||||
'virtual_balance' => '0',
|
||||
'iban' => null,
|
||||
'account_role' => 'defaultAsset',
|
||||
'opening_balance' => '105',
|
||||
'opening_balance_date' => new Carbon('2018-01-01'),
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
@@ -221,8 +197,6 @@ class AccountUpdateServiceTest extends TestCase
|
||||
$account = $service->update($account, $data);
|
||||
|
||||
$this->assertEquals($data['name'], $account->name);
|
||||
$this->assertEquals(1, $account->transactions()->count());
|
||||
$this->assertEquals(105, $account->transactions()->first()->amount);
|
||||
/** @var Note $note */
|
||||
$note = $account->notes()->first();
|
||||
$this->assertEquals($data['notes'], $note->text);
|
||||
@@ -234,12 +208,13 @@ class AccountUpdateServiceTest extends TestCase
|
||||
*/
|
||||
public function testUpdateExistingIBZero(): void
|
||||
{
|
||||
|
||||
$deleteService = $this->mock(JournalDestroyService::class);
|
||||
$deleteService->shouldReceive('destroy')->once();
|
||||
//$deleteService->shouldReceive('destroy')->once();
|
||||
|
||||
/** @var Account $account */
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . $this->randomInt(),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
$opposing = $this->user()->accounts()->first();
|
||||
@@ -260,53 +235,15 @@ class AccountUpdateServiceTest extends TestCase
|
||||
|
||||
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'openingBalance' => '0',
|
||||
'openingBalanceDate' => new Carbon('2018-01-01'),
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
$service = app(AccountUpdateService::class);
|
||||
$account = $service->update($account, $data);
|
||||
|
||||
$this->assertEquals($data['name'], $account->name);
|
||||
$this->assertEquals(1, $account->transactions()->count());
|
||||
$this->assertEquals(100, $account->transactions()->first()->amount);
|
||||
/** @var Note $note */
|
||||
$note = $account->notes()->first();
|
||||
$this->assertEquals($data['notes'], $note->text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Update\AccountUpdateService
|
||||
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
|
||||
*/
|
||||
public function testUpdateNewIB(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var Account $account */
|
||||
$account = Account::create(
|
||||
['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . random_int(1, 10000),
|
||||
'virtual_balance' => '0', 'iban' => null, 'active' => true]
|
||||
);
|
||||
$data = [
|
||||
'name' => 'Some new name #' . random_int(1, 10000),
|
||||
'active' => true,
|
||||
'virtualBalance' => '0',
|
||||
'iban' => null,
|
||||
'accountRole' => 'defaultAsset',
|
||||
'openingBalance' => '100',
|
||||
'openingBalanceDate' => new Carbon('2018-01-01'),
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
'name' => 'Some new name #' . $this->randomInt(),
|
||||
'active' => true,
|
||||
'virtual_balance' => '0',
|
||||
'iban' => null,
|
||||
'account_role' => 'defaultAsset',
|
||||
'opening_balance' => '0',
|
||||
'opening_balance_date' => new Carbon('2018-01-01'),
|
||||
'notes' => 'Hello',
|
||||
'currency_id' => 1,
|
||||
];
|
||||
|
||||
/** @var AccountUpdateService $service */
|
||||
|
@@ -1,242 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* JournalUpdateServiceTest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Services\Internal\Update;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Factory\BillFactory;
|
||||
use FireflyIII\Factory\TagFactory;
|
||||
use FireflyIII\Factory\TransactionFactory;
|
||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Services\Internal\Update\JournalUpdateService;
|
||||
use FireflyIII\Services\Internal\Update\TransactionUpdateService;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class JournalUpdateServiceTest
|
||||
*/
|
||||
class JournalUpdateServiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Update\JournalUpdateService
|
||||
* @covers \FireflyIII\Services\Internal\Support\JournalServiceTrait
|
||||
*/
|
||||
public function testUpdateBasic(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock other stuff:
|
||||
$transactionFactory = $this->mock(TransactionFactory::class);
|
||||
$transactionService = $this->mock(TransactionUpdateService::class);
|
||||
$billFactory = $this->mock(BillFactory::class);
|
||||
$tagFactory = $this->mock(TagFactory::class);
|
||||
$metaFactory = $this->mock(TransactionJournalMetaFactory::class);
|
||||
|
||||
// mock calls
|
||||
$billFactory->shouldReceive('setUser');
|
||||
$billFactory->shouldReceive('find')->andReturn(null);
|
||||
$transactionService->shouldReceive('setUser');
|
||||
$transactionFactory->shouldReceive('setUser');
|
||||
$tagFactory->shouldReceive('setUser');
|
||||
$metaFactory->shouldReceive('setUser');
|
||||
|
||||
$metaFactory->shouldReceive('updateOrCreate');
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
|
||||
$data = [
|
||||
'description' => 'Updated journal #' . random_int(1, 10000),
|
||||
'date' => new Carbon('2018-01-01'),
|
||||
'bill_id' => null,
|
||||
'bill_name' => null,
|
||||
'tags' => [],
|
||||
'notes' => 'Hello',
|
||||
'transactions' => [],
|
||||
];
|
||||
|
||||
/** @var JournalUpdateService $service */
|
||||
$service = app(JournalUpdateService::class);
|
||||
$result = $service->update($journal, $data);
|
||||
|
||||
$this->assertEquals($data['description'], $result->description);
|
||||
$this->assertEquals(0, $result->transactions()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Update\JournalUpdateService
|
||||
* @covers \FireflyIII\Services\Internal\Support\JournalServiceTrait
|
||||
*/
|
||||
public function testUpdateBasicEmptyNote(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock other stuff:
|
||||
$transactionFactory = $this->mock(TransactionFactory::class);
|
||||
$transactionService = $this->mock(TransactionUpdateService::class);
|
||||
$billFactory = $this->mock(BillFactory::class);
|
||||
$tagFactory = $this->mock(TagFactory::class);
|
||||
$metaFactory = $this->mock(TransactionJournalMetaFactory::class);
|
||||
|
||||
// mock calls
|
||||
$billFactory->shouldReceive('setUser');
|
||||
$billFactory->shouldReceive('find')->andReturn(null);
|
||||
$transactionService->shouldReceive('setUser');
|
||||
$transactionFactory->shouldReceive('setUser');
|
||||
$tagFactory->shouldReceive('setUser');
|
||||
$metaFactory->shouldReceive('setUser');
|
||||
$metaFactory->shouldReceive('updateOrCreate');
|
||||
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 2)->first();
|
||||
$data = [
|
||||
'description' => 'Updated journal #' . random_int(1, 10000),
|
||||
'date' => new Carbon('2018-01-01'),
|
||||
'bill_id' => null,
|
||||
'bill_name' => null,
|
||||
'tags' => [],
|
||||
'notes' => '',
|
||||
'transactions' => [],
|
||||
];
|
||||
|
||||
/** @var JournalUpdateService $service */
|
||||
$service = app(JournalUpdateService::class);
|
||||
$result = $service->update($journal, $data);
|
||||
|
||||
$this->assertEquals($data['description'], $result->description);
|
||||
$this->assertEquals(0, $result->transactions()->count());
|
||||
$this->assertEquals(0, $result->notes()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Update\JournalUpdateService
|
||||
*/
|
||||
public function testUpdateBudget(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$budget = $this->user()->budgets()->first();
|
||||
$service = $this->mock(TransactionUpdateService::class);
|
||||
$service->shouldReceive('setUser');
|
||||
$service->shouldReceive('updateBudget')->withArgs([Mockery::any(), $budget->id])->twice();
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
|
||||
// call update service to update budget. Should call transaction service twice.
|
||||
/** @var JournalUpdateService $service */
|
||||
$service = app(JournalUpdateService::class);
|
||||
$service->updateBudget($withdrawal, $budget->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Update\JournalUpdateService
|
||||
*/
|
||||
public function testUpdateCategory(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$service = $this->mock(TransactionUpdateService::class);
|
||||
$service->shouldReceive('setUser');
|
||||
$service->shouldReceive('updateCategory')->withArgs([Mockery::any(), 'New category'])->twice();
|
||||
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
|
||||
// call update service to update budget. Should call transaction service twice.
|
||||
/** @var JournalUpdateService $service */
|
||||
$service = app(JournalUpdateService::class);
|
||||
$service->updateCategory($withdrawal, 'New category');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Services\Internal\Update\JournalUpdateService
|
||||
* @covers \FireflyIII\Services\Internal\Support\JournalServiceTrait
|
||||
*/
|
||||
public function testUpdateLotsOfTransactions(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock other stuff:
|
||||
$transactionFactory = $this->mock(TransactionFactory::class);
|
||||
$transactionService = $this->mock(TransactionUpdateService::class);
|
||||
$billFactory = $this->mock(BillFactory::class);
|
||||
$tagFactory = $this->mock(TagFactory::class);
|
||||
$metaFactory = $this->mock(TransactionJournalMetaFactory::class);
|
||||
|
||||
|
||||
// mock calls
|
||||
$billFactory->shouldReceive('setUser');
|
||||
$billFactory->shouldReceive('find')->andReturn(null);
|
||||
$transactionService->shouldReceive('setUser');
|
||||
$transactionFactory->shouldReceive('setUser');
|
||||
$transactionService->shouldReceive('update')->times(2);
|
||||
$transactionFactory->shouldReceive('createPair')->times(2);
|
||||
$tagFactory->shouldReceive('setUser');
|
||||
$metaFactory->shouldReceive('setUser');
|
||||
$metaFactory->shouldReceive('updateOrCreate');
|
||||
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->skip(4)->where('transaction_type_id', 1)->first();
|
||||
$data = [
|
||||
'description' => 'Updated journal #' . random_int(1, 10000),
|
||||
'date' => new Carbon('2018-01-01'),
|
||||
'bill_id' => null,
|
||||
'bill_name' => null,
|
||||
'tags' => [],
|
||||
'notes' => 'Hello',
|
||||
'transactions' => [
|
||||
['identifier' => 0],
|
||||
['identifier' => 1],
|
||||
['identifier' => 2],
|
||||
],
|
||||
];
|
||||
|
||||
/** @var JournalUpdateService $service */
|
||||
$service = app(JournalUpdateService::class);
|
||||
$result = $service->update($journal, $data);
|
||||
|
||||
$this->assertEquals($data['description'], $result->description);
|
||||
$this->assertEquals(2, $result->transactions()->count());
|
||||
}
|
||||
|
||||
}
|
@@ -1,265 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionUpdateServiceTest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Services\Internal\Update;
|
||||
|
||||
|
||||
use FireflyIII\Factory\BudgetFactory;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Services\Internal\Update\TransactionUpdateService;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class TransactionUpdateServiceTest
|
||||
*/
|
||||
class TransactionUpdateServiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// */
|
||||
// public function testReconcile(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// $transaction = $this->user()->transactions()->inRandomOrder()->first();
|
||||
//
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $result = $service->reconcile($transaction->id);
|
||||
// $this->assertEquals($result->id, $transaction->id);
|
||||
// $this->assertEquals(true, $result->reconciled);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||
// */
|
||||
// public function testReconcileNull(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $result = $service->reconcile(-1);
|
||||
// $this->assertNull($result);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||
// */
|
||||
// public function testUpdateBudget(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// /** @var Transaction $source */
|
||||
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||
// $budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
//
|
||||
// $factory = $this->mock(BudgetFactory::class);
|
||||
// $factory->shouldReceive('setUser');
|
||||
// $factory->shouldReceive('find')->andReturn($budget);
|
||||
//
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $result = $service->updateBudget($source, $budget->id);
|
||||
//
|
||||
// $this->assertEquals(1, $result->budgets()->count());
|
||||
// $this->assertEquals($budget->name, $result->budgets()->first()->name);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||
// */
|
||||
// public function testUpdateCategory(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// /** @var Transaction $source */
|
||||
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||
// $category = $this->user()->categories()->inRandomOrder()->first();
|
||||
//
|
||||
// $factory = $this->mock(CategoryFactory::class);
|
||||
// $factory->shouldReceive('setUser');
|
||||
// $factory->shouldReceive('findOrCreate')->andReturn($category);
|
||||
//
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $result = $service->updateCategory($source, $category->name);
|
||||
//
|
||||
// $this->assertEquals(1, $result->categories()->count());
|
||||
// $this->assertEquals($category->name, $result->categories()->first()->name);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||
// */
|
||||
// public function testUpdateDestinationBasic(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// /** @var Transaction $source */
|
||||
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||
// $data = [
|
||||
// 'currency_id' => 1,
|
||||
// 'currency_code' => null,
|
||||
// 'description' => 'Some new description',
|
||||
// 'reconciled' => false,
|
||||
// 'foreign_amount' => null,
|
||||
// 'budget_id' => null,
|
||||
// 'budget_name' => null,
|
||||
// 'destination_id' => (int)$source->account_id,
|
||||
// 'destination_name' => null,
|
||||
// 'category_id' => null,
|
||||
// 'category_name' => null,
|
||||
// 'amount' => $source->amount,
|
||||
// 'foreign_currency_id' => null,
|
||||
// 'foreign_currency_code' => null,
|
||||
// ];
|
||||
//
|
||||
// // mock repository:
|
||||
// $accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
// $accountRepos->shouldReceive('setUser');
|
||||
// $accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
||||
//
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $result = $service->update($source, $data);
|
||||
//
|
||||
// $this->assertEquals($source->id, $result->id);
|
||||
// $this->assertEquals($result->description, $data['description']);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||
// */
|
||||
// public function testUpdateDestinationForeign(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// /** @var Transaction $source */
|
||||
// $source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
|
||||
// $data = [
|
||||
// 'currency_id' => 1,
|
||||
// 'currency_code' => null,
|
||||
// 'description' => 'Some new description',
|
||||
// 'reconciled' => false,
|
||||
// 'foreign_amount' => '12.34',
|
||||
// 'budget_id' => null,
|
||||
// 'budget_name' => null,
|
||||
// 'destination_id' => (int)$source->account_id,
|
||||
// 'destination_name' => null,
|
||||
// 'category_id' => null,
|
||||
// 'category_name' => null,
|
||||
// 'amount' => $source->amount,
|
||||
// 'foreign_currency_id' => 2,
|
||||
// 'foreign_currency_code' => null,
|
||||
// ];
|
||||
//
|
||||
// // mock repository:
|
||||
// $accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
// $accountRepos->shouldReceive('setUser');
|
||||
// $accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
||||
//
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $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);
|
||||
// $this->assertEquals($data['foreign_currency_id'], $result->foreign_currency_id);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @covers \FireflyIII\Services\Internal\Update\TransactionUpdateService
|
||||
// * @covers \FireflyIII\Services\Internal\Support\TransactionServiceTrait
|
||||
// */
|
||||
// public function testUpdateSourceBasic(): void
|
||||
// {
|
||||
// $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
//
|
||||
// return;
|
||||
// /** @var Transaction $source */
|
||||
// $source = $this->user()->transactions()->where('amount', '<', 0)->inRandomOrder()->first();
|
||||
// $data = [
|
||||
// 'currency_id' => 1,
|
||||
// 'currency_code' => null,
|
||||
// 'description' => 'Some new description',
|
||||
// 'reconciled' => false,
|
||||
// 'foreign_amount' => null,
|
||||
// 'budget_id' => null,
|
||||
// 'budget_name' => null,
|
||||
// 'source_id' => (int)$source->account_id,
|
||||
// 'source_name' => null,
|
||||
// 'category_id' => null,
|
||||
// 'category_name' => null,
|
||||
// 'amount' => $source->amount,
|
||||
// 'foreign_currency_id' => null,
|
||||
// 'foreign_currency_code' => null,
|
||||
// ];
|
||||
//
|
||||
// // mock repository:
|
||||
// $accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
// $accountRepos->shouldReceive('setUser');
|
||||
// $accountRepos->shouldReceive('findNull')->andReturn($source->account);
|
||||
//
|
||||
// /** @var TransactionUpdateService $service */
|
||||
// $service = app(TransactionUpdateService::class);
|
||||
// $service->setUser($this->user());
|
||||
// $result = $service->update($source, $data);
|
||||
//
|
||||
// $this->assertEquals($source->id, $result->id);
|
||||
// $this->assertEquals($result->description, $data['description']);
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
142
tests/Unit/Support/Cronjobs/RecurringCronjobTest.php
Normal file
142
tests/Unit/Support/Cronjobs/RecurringCronjobTest.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* RecurringCronjobTest.php
|
||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Tests\Unit\Support\Cronjobs;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Jobs\CreateRecurringTransactions;
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class RecurringCronjobTest
|
||||
*/
|
||||
class RecurringCronjobTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Cronjobs\RecurringCronjob
|
||||
*/
|
||||
public function testBasic(): void
|
||||
{
|
||||
$class = $this->mock(CreateRecurringTransactions::class);
|
||||
$force = false;
|
||||
$date = new Carbon;
|
||||
$config = new Configuration;
|
||||
$config->data = 0;
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->atLeast()->once()->andReturn($config);
|
||||
|
||||
$class->shouldReceive('setDate')->atleast()->once();
|
||||
$class->shouldReceive('setForce')->atleast()->once()->withArgs([$force]);
|
||||
$class->shouldReceive('handle')->atleast()->once();
|
||||
|
||||
FireflyConfig::shouldReceive('set')->atLeast()->once()->withArgs(['last_rt_job', Mockery::any()]);
|
||||
|
||||
$job = new RecurringCronjob;
|
||||
$job->setDate($date);
|
||||
$job->setForce($force);
|
||||
$job->fire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Cronjobs\RecurringCronjob
|
||||
*/
|
||||
public function testShort(): void
|
||||
{
|
||||
$this->mock(CreateRecurringTransactions::class);
|
||||
$force = false;
|
||||
$date = new Carbon;
|
||||
$time = time() - 100;
|
||||
$config = new Configuration;
|
||||
$config->data = $time;
|
||||
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->atLeast()->once()->andReturn($config);
|
||||
|
||||
$job = new RecurringCronjob;
|
||||
$job->setDate($date);
|
||||
$job->setForce($force);
|
||||
$job->fire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Cronjobs\RecurringCronjob
|
||||
*/
|
||||
public function testShortForced(): void
|
||||
{
|
||||
$class = $this->mock(CreateRecurringTransactions::class);
|
||||
$force = true;
|
||||
$date = new Carbon;
|
||||
$time = time() - 100;
|
||||
$config = new Configuration;
|
||||
$config->data = $time;
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->atLeast()->once()->andReturn($config);
|
||||
|
||||
$class->shouldReceive('setDate')->atleast()->once();
|
||||
$class->shouldReceive('setForce')->atleast()->once()->withArgs([$force]);
|
||||
$class->shouldReceive('handle')->atleast()->once();
|
||||
|
||||
FireflyConfig::shouldReceive('set')->atLeast()->once()->withArgs(['last_rt_job', Mockery::any()]);
|
||||
|
||||
$job = new RecurringCronjob;
|
||||
$job->setDate($date);
|
||||
$job->setForce($force);
|
||||
$job->fire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Support\Cronjobs\RecurringCronjob
|
||||
*/
|
||||
public function testTwoDays(): void
|
||||
{
|
||||
$class = $this->mock(CreateRecurringTransactions::class);
|
||||
$force = false;
|
||||
$date = new Carbon;
|
||||
$time = time() - 43300;
|
||||
$config = new Configuration;
|
||||
$config->data = $time;
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->atLeast()->once()->andReturn($config);
|
||||
|
||||
$class->shouldReceive('setDate')->atleast()->once();
|
||||
$class->shouldReceive('setForce')->atleast()->once()->withArgs([$force]);
|
||||
$class->shouldReceive('handle')->atleast()->once();
|
||||
|
||||
FireflyConfig::shouldReceive('set')->atLeast()->once()->withArgs(['last_rt_job', Mockery::any()]);
|
||||
|
||||
$job = new RecurringCronjob;
|
||||
$job->setDate($date);
|
||||
$job->setForce($force);
|
||||
$job->fire();
|
||||
}
|
||||
|
||||
}
|
@@ -60,7 +60,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'caha' . random_int(1, 10000);
|
||||
$job->key = 'caha' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -91,7 +91,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahb' . random_int(1, 10000);
|
||||
$job->key = 'cahb' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -124,7 +124,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahc' . random_int(1, 10000);
|
||||
$job->key = 'cahc' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -179,7 +179,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahd' . random_int(1, 10000);
|
||||
$job->key = 'cahd' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -234,7 +234,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahe' . random_int(1, 10000);
|
||||
$job->key = 'cahe' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -289,7 +289,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahf' . random_int(1, 10000);
|
||||
$job->key = 'cahf' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -335,7 +335,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahg' . random_int(1, 10000);
|
||||
$job->key = 'cahg' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -398,7 +398,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cahg' . random_int(1, 10000);
|
||||
$job->key = 'cahg' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
|
@@ -51,7 +51,7 @@ class NewBunqJobHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'cXha' . random_int(1, 10000);
|
||||
$job->key = 'cXha' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
|
@@ -63,7 +63,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapG' . random_int(1, 10000);
|
||||
$job->key = 'mapG' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -131,7 +131,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapA' . random_int(1, 10000);
|
||||
$job->key = 'mapA' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -165,7 +165,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapE' . random_int(1, 10000);
|
||||
$job->key = 'mapE' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -230,7 +230,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapC' . random_int(1, 10000);
|
||||
$job->key = 'mapC' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -260,7 +260,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapH' . random_int(1, 10000);
|
||||
$job->key = 'mapH' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -343,7 +343,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapD' . random_int(1, 10000);
|
||||
$job->key = 'mapD' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -372,7 +372,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapF' . random_int(1, 10000);
|
||||
$job->key = 'mapF' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -461,7 +461,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapB' . random_int(1, 10000);
|
||||
$job->key = 'mapB' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -491,7 +491,7 @@ class ConfigureMappingHandlerTest extends TestCase
|
||||
$importRepos->shouldReceive('setUser')->once();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'mapB' . random_int(1, 10000);
|
||||
$job->key = 'mapB' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
@@ -134,7 +134,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-B' . random_int(1, 10000);
|
||||
$job->key = 'role-B' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -215,7 +215,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-x' . random_int(1, 10000);
|
||||
$job->key = 'role-x' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -297,7 +297,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-x' . random_int(1, 10000);
|
||||
$job->key = 'role-x' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -368,7 +368,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-x' . random_int(1, 10000);
|
||||
$job->key = 'role-x' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -543,7 +543,7 @@ class ConfigureRolesHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'role-A' . random_int(1, 10000);
|
||||
$job->key = 'role-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
@@ -53,7 +53,7 @@ class ConfigureUploadHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'upload-B' . random_int(1, 10000);
|
||||
$job->key = 'upload-B' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -102,7 +102,7 @@ class ConfigureUploadHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'upload-B' . random_int(1, 10000);
|
||||
$job->key = 'upload-B' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -150,7 +150,7 @@ class ConfigureUploadHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'upload-A' . random_int(1, 10000);
|
||||
$job->key = 'upload-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
@@ -56,7 +56,7 @@ class NewFileJobHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'newfile-A' . random_int(1, 10000);
|
||||
$job->key = 'newfile-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -111,7 +111,7 @@ class NewFileJobHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'newfile-A' . random_int(1, 10000);
|
||||
$job->key = 'newfile-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -169,7 +169,7 @@ class NewFileJobHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'newfile-A' . random_int(1, 10000);
|
||||
$job->key = 'newfile-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -216,7 +216,7 @@ class NewFileJobHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'newfile-x' . random_int(1, 10000);
|
||||
$job->key = 'newfile-x' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
@@ -264,7 +264,7 @@ class NewFileJobHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'newfile-x' . random_int(1, 10000);
|
||||
$job->key = 'newfile-x' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
@@ -64,7 +64,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-A' . random_int(1, 10000);
|
||||
$job->key = 'sca-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -99,7 +99,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-B' . random_int(1, 10000);
|
||||
$job->key = 'sca-B' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -138,7 +138,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-c' . random_int(1, 10000);
|
||||
$job->key = 'sca-c' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -197,7 +197,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-E' . random_int(1, 10000);
|
||||
$job->key = 'sca-E' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -256,7 +256,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-D' . random_int(1, 10000);
|
||||
$job->key = 'sca-D' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -313,7 +313,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-E' . random_int(1, 10000);
|
||||
$job->key = 'sca-E' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -443,7 +443,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-F' . random_int(1, 10000);
|
||||
$job->key = 'sca-F' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -596,7 +596,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
// fake job:
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sca-F' . random_int(1, 10000);
|
||||
$job->key = 'sca-F' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
|
@@ -62,7 +62,7 @@ class ChooseLoginHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'slh-A' . random_int(1, 10000);
|
||||
$job->key = 'slh-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -85,7 +85,7 @@ class ChooseLoginHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'slh-B' . random_int(1, 10000);
|
||||
$job->key = 'slh-B' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -109,7 +109,7 @@ class ChooseLoginHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'slh-C' . random_int(1, 10000);
|
||||
$job->key = 'slh-C' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -149,7 +149,7 @@ class ChooseLoginHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'slh-C' . random_int(1, 10000);
|
||||
$job->key = 'slh-C' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -269,7 +269,7 @@ class ChooseLoginHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'slh-C' . random_int(1, 10000);
|
||||
$job->key = 'slh-C' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
|
@@ -62,7 +62,7 @@ class DoAuthenticateHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sda-A' . random_int(1, 10000);
|
||||
$job->key = 'sda-A' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
|
@@ -67,7 +67,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sidh_bbunq_' . random_int(1, 10000);
|
||||
$job->key = 'sidh_bbunq_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -117,7 +117,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
$payment = new BunqPayment($amount, $pointer, 'Some descr', null, null);
|
||||
$payment->setAmount($amount);
|
||||
$payment->setCounterpartyAlias($labelMonetaryAccount);
|
||||
$payment->setDescription('Random description #' . random_int(1, 10000));
|
||||
$payment->setDescription('Random description #' . $this->randomInt());
|
||||
$value = [$payment];
|
||||
$list = new BunqResponsePaymentList($value, [], null);
|
||||
|
||||
@@ -216,7 +216,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
// {
|
||||
// $job = new ImportJob;
|
||||
// $job->user_id = $this->user()->id;
|
||||
// $job->key = 'sidA_bbunq_' . random_int(1, 10000);
|
||||
// $job->key = 'sidA_bbunq_' . $this->randomInt();
|
||||
// $job->status = 'new';
|
||||
// $job->stage = 'new';
|
||||
// $job->provider = 'bunq';
|
||||
@@ -290,7 +290,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
// {
|
||||
// $job = new ImportJob;
|
||||
// $job->user_id = $this->user()->id;
|
||||
// $job->key = 'sidh_bbunq_' . random_int(1, 10000);
|
||||
// $job->key = 'sidh_bbunq_' . $this->randomInt();
|
||||
// $job->status = 'new';
|
||||
// $job->stage = 'new';
|
||||
// $job->provider = 'bunq';
|
||||
@@ -344,7 +344,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
//
|
||||
// $payment = new BunqPayment($amount, $pointer, 'Some descr', null, null);
|
||||
// $payment->setAmount($amount);
|
||||
// $payment->setDescription('Some random thing #' . random_int(1, 10000));
|
||||
// $payment->setDescription('Some random thing #' . $this->randomInt());
|
||||
// $payment->setCounterpartyAlias($labelMonetaryAccount);
|
||||
// $value = [$payment];
|
||||
// $list = new BunqResponsePaymentList($value, [], null);
|
||||
@@ -427,7 +427,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
// {
|
||||
// $job = new ImportJob;
|
||||
// $job->user_id = $this->user()->id;
|
||||
// $job->key = 'sidh_bbunq_' . random_int(1, 10000);
|
||||
// $job->key = 'sidh_bbunq_' . $this->randomInt();
|
||||
// $job->status = 'new';
|
||||
// $job->stage = 'new';
|
||||
// $job->provider = 'bunq';
|
||||
@@ -477,7 +477,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
// $payment = new BunqPayment($amount, $pointer, 'Some descr', null, null);
|
||||
// $payment->setAmount($amount);
|
||||
// $payment->setCounterpartyAlias($labelMonetaryAccount);
|
||||
// $payment->setDescription('Random transfer #' . random_int(1, 10000));
|
||||
// $payment->setDescription('Random transfer #' . $this->randomInt());
|
||||
// $value = [$payment];
|
||||
// $list = new BunqResponsePaymentList($value, [], null);
|
||||
//
|
||||
|
@@ -67,7 +67,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'snh_bunq_' . random_int(1, 10000);
|
||||
$job->key = 'snh_bunq_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -154,7 +154,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'snha_bunq_' . random_int(1, 10000);
|
||||
$job->key = 'snha_bunq_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
@@ -246,7 +246,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'snh_bbunq_' . random_int(1, 10000);
|
||||
$job->key = 'snh_bbunq_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'bunq';
|
||||
|
@@ -87,8 +87,8 @@ class ImportableConverterTest extends TestCase
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
|
||||
// get default currency
|
||||
$euro = TransactionCurrency::whereCode('EUR')->first();
|
||||
$usd = TransactionCurrency::whereCode('USD')->first();
|
||||
$euro = $this->getEuro();
|
||||
$usd = $this->getDollar();
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
|
||||
|
||||
// set user and config:
|
||||
@@ -113,9 +113,9 @@ class ImportableConverterTest extends TestCase
|
||||
$result = $converter->convert($importables);
|
||||
|
||||
// verify content of $result
|
||||
$this->assertEquals('withdrawal', $result[0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
|
||||
$this->assertEquals($importable->tags, $result[0]['tags']);
|
||||
$this->assertEquals('withdrawal', $result[0]['transactions'][0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
|
||||
$this->assertEquals($importable->tags, $result[0]['transactions'][0]['tags']);
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
}
|
||||
|
||||
@@ -176,9 +176,9 @@ class ImportableConverterTest extends TestCase
|
||||
|
||||
// verify content of $result
|
||||
$today = new Carbon();
|
||||
$this->assertEquals('transfer', $result[0]['type']);
|
||||
$this->assertEquals($today->format('Y-m-d H:i:s'), $result[0]['date']);
|
||||
$this->assertEquals([], $result[0]['tags']);
|
||||
$this->assertEquals('transfer', $result[0]['transactions'][0]['type']);
|
||||
$this->assertEquals($today->format('Y-m-d H:i:s'), $result[0]['transactions'][0]['date']);
|
||||
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
|
||||
$this->assertEquals($euro->id, $result[0]['transactions'][0]['currency_id']);
|
||||
}
|
||||
|
||||
@@ -237,13 +237,13 @@ class ImportableConverterTest extends TestCase
|
||||
$result = $converter->convert($importables);
|
||||
|
||||
// verify content of $result
|
||||
$this->assertEquals('deposit', $result[0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
|
||||
$this->assertEquals([], $result[0]['tags']);
|
||||
$this->assertEquals('deposit', $result[0]['transactions'][0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
|
||||
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
$this->assertEquals($revenue->id, $result[0]['transactions'][0]['source_id']);
|
||||
$this->assertEquals($asset->id, $result[0]['transactions'][0]['destination_id']);
|
||||
$this->assertEquals('2018-01-02 00:00:00', $result[0]['book_date']);
|
||||
$this->assertEquals('2018-01-02 00:00:00', $result[0]['transactions'][0]['book_date']);
|
||||
|
||||
}
|
||||
|
||||
@@ -361,11 +361,11 @@ class ImportableConverterTest extends TestCase
|
||||
$result = $converter->convert($importables);
|
||||
|
||||
// verify content of $result
|
||||
$this->assertEquals('transfer', $result[0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
|
||||
$this->assertEquals([], $result[0]['tags']);
|
||||
$this->assertEquals(2, $result[0]['bill_id']); // will NOT be ignored.
|
||||
$this->assertEquals($importable->billName, $result[0]['bill_name']);
|
||||
$this->assertEquals('transfer', $result[0]['transactions'][0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
|
||||
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
|
||||
$this->assertEquals(2, $result[0]['transactions'][0]['bill_id']); // will NOT be ignored.
|
||||
$this->assertEquals($importable->billName, $result[0]['transactions'][0]['bill_name']);
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
|
||||
// since amount is positive, $asset recieves the money
|
||||
@@ -434,11 +434,11 @@ class ImportableConverterTest extends TestCase
|
||||
$result = $converter->convert($importables);
|
||||
|
||||
// verify content of $result
|
||||
$this->assertEquals('transfer', $result[0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
|
||||
$this->assertEquals([], $result[0]['tags']);
|
||||
$this->assertEquals(3, $result[0]['bill_id']);
|
||||
$this->assertEquals($importable->billName, $result[0]['bill_name']);
|
||||
$this->assertEquals('transfer', $result[0]['transactions'][0]['type']);
|
||||
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
|
||||
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
|
||||
$this->assertEquals(3, $result[0]['transactions'][0]['bill_id']);
|
||||
$this->assertEquals($importable->billName, $result[0]['transactions'][0]['bill_name']);
|
||||
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
|
||||
|
||||
// since amount is negative, $asset sends the money
|
||||
|
@@ -55,7 +55,7 @@ class LineReaderTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'linerA' . random_int(1, 10000);
|
||||
$job->key = 'linerA' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
@@ -132,7 +132,7 @@ class MappingConvergerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'linerB' . random_int(1, 10000);
|
||||
$job->key = 'linerB' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'fake';
|
||||
|
@@ -72,16 +72,16 @@ class OpposingAccountMapperTest extends TestCase
|
||||
*/
|
||||
public function testAccountIdBadType(): void
|
||||
{
|
||||
$expected = $this->user()->accounts()->where('account_type_id', 5)->inRandomOrder()->first();
|
||||
$expected = $this->getRandomRevenue();
|
||||
$expected->iban = null;
|
||||
$expected->save();
|
||||
$amount = '-12.34';
|
||||
$expectedArgs = [
|
||||
'name' => $expected->name,
|
||||
'iban' => null,
|
||||
'accountNumber' => null,
|
||||
'account_number' => null,
|
||||
'account_type_id' => null,
|
||||
'accountType' => AccountType::EXPENSE,
|
||||
'account_type' => AccountType::EXPENSE,
|
||||
'active' => true,
|
||||
'BIC' => null,
|
||||
];
|
||||
@@ -116,9 +116,9 @@ class OpposingAccountMapperTest extends TestCase
|
||||
$expectedArgs = [
|
||||
'name' => $expected->name,
|
||||
'iban' => $expected->iban,
|
||||
'accountNumber' => null,
|
||||
'account_number' => null,
|
||||
'account_type_id' => null,
|
||||
'accountType' => AccountType::EXPENSE,
|
||||
'account_type' => AccountType::EXPENSE,
|
||||
'active' => true,
|
||||
'BIC' => null,
|
||||
];
|
||||
@@ -152,9 +152,9 @@ class OpposingAccountMapperTest extends TestCase
|
||||
$expectedArgs = [
|
||||
'name' => '(no name)',
|
||||
'iban' => null,
|
||||
'accountNumber' => null,
|
||||
'account_number' => null,
|
||||
'account_type_id' => null,
|
||||
'accountType' => AccountType::EXPENSE,
|
||||
'account_type' => AccountType::EXPENSE,
|
||||
'active' => true,
|
||||
'BIC' => null,
|
||||
];
|
||||
@@ -184,9 +184,9 @@ class OpposingAccountMapperTest extends TestCase
|
||||
$expectedArgs = [
|
||||
'name' => '(no name)',
|
||||
'iban' => null,
|
||||
'accountNumber' => null,
|
||||
'account_number' => null,
|
||||
'account_type_id' => null,
|
||||
'accountType' => AccountType::REVENUE,
|
||||
'account_type' => AccountType::REVENUE,
|
||||
'active' => true,
|
||||
'BIC' => null,
|
||||
];
|
||||
|
@@ -122,7 +122,7 @@ class StageAuthenticatedHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sa_a_' . random_int(1, 10000);
|
||||
$job->key = 'sa_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -251,7 +251,7 @@ class StageAuthenticatedHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sa_a_' . random_int(1, 10000);
|
||||
$job->key = 'sa_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -380,7 +380,7 @@ class StageAuthenticatedHandlerTest extends TestCase
|
||||
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sa_a_' . random_int(1, 10000);
|
||||
$job->key = 'sa_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
|
@@ -325,7 +325,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sid_a_' . random_int(1, 10000);
|
||||
$job->key = 'sid_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -524,7 +524,7 @@ class StageImportDataHandlerTest extends TestCase
|
||||
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sid_a_' . random_int(1, 10000);
|
||||
$job->key = 'sid_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
|
@@ -67,7 +67,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sn_a_' . random_int(1, 10000);
|
||||
$job->key = 'sn_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -134,7 +134,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sn_a_' . random_int(1, 10000);
|
||||
$job->key = 'sn_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -187,7 +187,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sn_a_' . random_int(1, 10000);
|
||||
$job->key = 'sn_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
@@ -256,7 +256,7 @@ class StageNewHandlerTest extends TestCase
|
||||
{
|
||||
$job = new ImportJob;
|
||||
$job->user_id = $this->user()->id;
|
||||
$job->key = 'sn_a_' . random_int(1, 10000);
|
||||
$job->key = 'sn_a_' . $this->randomInt();
|
||||
$job->status = 'new';
|
||||
$job->stage = 'new';
|
||||
$job->provider = 'spectre';
|
||||
|
@@ -75,7 +75,7 @@ class AddTagTest extends TestCase
|
||||
*/
|
||||
public function testActNoTag(): void
|
||||
{
|
||||
$newTagName = 'TestTag-' . random_int(1, 10000);
|
||||
$newTagName = 'TestTag-' . $th;
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = $newTagName;
|
||||
|
@@ -59,7 +59,7 @@ class ConvertToDepositTest extends TestCase
|
||||
|
||||
return;
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$name = 'Random revenue #' . random_int(1, 10000);
|
||||
$name = 'Random revenue #' . $this->randomInt();
|
||||
$journal = $this->getRandomTransfer();
|
||||
|
||||
// journal is a transfer:
|
||||
@@ -98,7 +98,7 @@ class ConvertToDepositTest extends TestCase
|
||||
|
||||
return;
|
||||
$revenue = $this->getRandomRevenue();
|
||||
$name = 'Random revenue #' . random_int(1, 10000);
|
||||
$name = 'Random revenue #' . $this->randomInt();
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
|
||||
// journal is a withdrawal:
|
||||
|
@@ -59,7 +59,7 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
|
||||
return;
|
||||
$expense = $this->getRandomExpense();
|
||||
$name = 'Random expense #' . random_int(1, 10000);
|
||||
$name = 'Random expense #' . $this->randomInt();
|
||||
$deposit = $this->getRandomDeposit();
|
||||
|
||||
// journal is a deposit:
|
||||
@@ -98,7 +98,7 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
|
||||
return;
|
||||
$expense = $this->getRandomExpense();
|
||||
$name = 'Random expense #' . random_int(1, 10000);
|
||||
$name = 'Random expense #' . $this->randomInt();
|
||||
$transfer = $this->getRandomTransfer();
|
||||
|
||||
// journal is a transfer:
|
||||
|
@@ -38,7 +38,7 @@ class PrependDescriptionTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// get journal, give fixed description
|
||||
$description = 'text' . random_int(1, 10000);
|
||||
$description = 'text' . $this->randomInt();
|
||||
$prepend = 'prepend' . random_int(1, 1234);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal->description = $description;
|
||||
|
@@ -38,7 +38,7 @@ class SetDescriptionTest extends TestCase
|
||||
public function testAct(): void
|
||||
{
|
||||
// get journal, give fixed description
|
||||
$description = 'text' . random_int(1, 10000);
|
||||
$description = 'text' . $this->randomInt();
|
||||
$newDescription = 'new description' . random_int(1, 1234);
|
||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
$journal->description = $description;
|
||||
|
@@ -94,7 +94,7 @@ class SetDestinationAccountTest extends TestCase
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Not existing asset account #' . random_int(1, 10000);
|
||||
$ruleAction->action_value = 'Not existing asset account #' . $this->randomInt();
|
||||
$action = new SetDestinationAccount($ruleAction);
|
||||
$result = $action->act($deposit);
|
||||
$this->assertFalse($result);
|
||||
@@ -121,7 +121,7 @@ class SetDestinationAccountTest extends TestCase
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Not existing expense account #' . random_int(1, 10000);
|
||||
$ruleAction->action_value = 'Not existing expense account #' . $this->randomInt();
|
||||
$action = new SetDestinationAccount($ruleAction);
|
||||
$result = $action->act($withdrawal);
|
||||
|
||||
@@ -186,7 +186,7 @@ class SetDestinationAccountTest extends TestCase
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Some new asset ' . random_int(1, 10000);
|
||||
$ruleAction->action_value = 'Some new asset ' . $this->randomInt();
|
||||
$action = new SetDestinationAccount($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
|
@@ -93,7 +93,7 @@ class SetSourceAccountTest extends TestCase
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Some new revenue #' . random_int(1, 10000);
|
||||
$ruleAction->action_value = 'Some new revenue #' . $this->randomInt();
|
||||
$action = new SetSourceAccount($ruleAction);
|
||||
$result = $action->act($deposit);
|
||||
$this->assertTrue($result);
|
||||
@@ -155,7 +155,7 @@ class SetSourceAccountTest extends TestCase
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Some new account #' . random_int(1, 10000);
|
||||
$ruleAction->action_value = 'Some new account #' . $this->randomInt();
|
||||
$action = new SetSourceAccount($ruleAction);
|
||||
$result = $action->act($withdrawal);
|
||||
$this->assertFalse($result);
|
||||
@@ -181,7 +181,7 @@ class SetSourceAccountTest extends TestCase
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
$ruleAction->action_value = 'Some new asset ' . random_int(1, 10000);
|
||||
$ruleAction->action_value = 'Some new asset ' . $this->randomInt();
|
||||
$action = new SetSourceAccount($ruleAction);
|
||||
$result = $action->act($journal);
|
||||
$this->assertFalse($result);
|
||||
|
@@ -53,7 +53,7 @@ class AttachmentTransformerTest extends TestCase
|
||||
public function testBasic(): void
|
||||
{
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$md5 = md5('hello' . random_int(1, 10000));
|
||||
$md5 = md5('hello' . $this->randomInt());
|
||||
$attachment = Attachment::create(
|
||||
[
|
||||
'user_id' => $this->user()->id,
|
||||
|
@@ -44,7 +44,7 @@ class TagTransformerTest extends TestCase
|
||||
$tag = Tag::create(
|
||||
[
|
||||
'user_id' => $this->user()->id,
|
||||
'tag' => 'Some tag ' . random_int(1, 10000),
|
||||
'tag' => 'Some tag ' . $this->randomInt(),
|
||||
'tagMode' => 'nothing',
|
||||
'date' => '2018-01-01',
|
||||
'description' => 'Some tag',
|
||||
|
Reference in New Issue
Block a user