diff --git a/tests/Api/V1/Controllers/AboutControllerTest.php b/tests/Api/V1/Controllers/AboutControllerTest.php
index eeeaba4290..c901ecedd8 100644
--- a/tests/Api/V1/Controllers/AboutControllerTest.php
+++ b/tests/Api/V1/Controllers/AboutControllerTest.php
@@ -24,8 +24,9 @@ declare(strict_types=1);
namespace Tests\Api\V1\Controllers;
use Laravel\Passport\Passport;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
+
/**
* Class AboutControllerTest
*/
diff --git a/tests/Api/V1/Controllers/AccountControllerTest.php b/tests/Api/V1/Controllers/AccountControllerTest.php
index a342fe2461..1b22e62ef3 100644
--- a/tests/Api/V1/Controllers/AccountControllerTest.php
+++ b/tests/Api/V1/Controllers/AccountControllerTest.php
@@ -28,8 +28,8 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Laravel\Passport\Passport;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
/**
* Class AccountControllerTest
diff --git a/tests/Api/V1/Controllers/TransactionControllerTest.php b/tests/Api/V1/Controllers/TransactionControllerTest.php
index 1b7c43fd61..2da89ce3e6 100644
--- a/tests/Api/V1/Controllers/TransactionControllerTest.php
+++ b/tests/Api/V1/Controllers/TransactionControllerTest.php
@@ -26,6 +26,7 @@ namespace Tests\Api\V1\Controllers;
use FireflyIII\Helpers\Collector\JournalCollector;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
+use FireflyIII\Helpers\Filter\NegativeAmountFilter;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -1349,7 +1350,7 @@ class TransactionControllerTest extends TestCase
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
$collector->shouldReceive('setJournals')->andReturnSelf()->once();
- $collector->shouldReceive('addFilter')->andReturnSelf()->once();
+ $collector->shouldReceive('addFilter')->withArgs([NegativeAmountFilter::class])->andReturnSelf()->once();
$collector->shouldReceive('getJournals')->andReturn($transactions);
// test API
@@ -1360,6 +1361,7 @@ class TransactionControllerTest extends TestCase
'data' => [
'attributes' => [
'description' => $journal->description,
+ 'type' => 'Deposit',
],
'links' => [
0 => [],
@@ -2172,8 +2174,8 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$source]), new Collection([$dest]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
- $piggy = $this->user()->piggyBanks()->first();
- $data = [
+ $piggy = $this->user()->piggyBanks()->first();
+ $data = [
'description' => 'Some transfer #' . rand(1, 1000),
'date' => '2018-01-01',
'type' => 'transfer',
@@ -2209,7 +2211,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
- $data = [
+ $data = [
'description' => 'Some transaction #' . rand(1, 1000),
'date' => '2018-01-01',
'type' => 'withdrawal',
@@ -2247,7 +2249,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
- $data = [
+ $data = [
'description' => 'Some transaction #' . rand(1, 1000),
'date' => '2018-01-01',
'type' => 'withdrawal',
@@ -2285,7 +2287,7 @@ class TransactionControllerTest extends TestCase
*/
public function testSuccessStoreTags()
{
- $tags = [
+ $tags = [
'TagOne' . rand(1, 1000),
'TagTwoBlarg' . rand(1, 1000),
'SomeThreeTag' . rand(1, 1000),
@@ -2299,7 +2301,7 @@ class TransactionControllerTest extends TestCase
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection([$account]));
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
- $data = [
+ $data = [
'description' => 'Some transaction #' . rand(1, 1000),
'date' => '2018-01-01',
'type' => 'withdrawal',
@@ -2319,5 +2321,4 @@ class TransactionControllerTest extends TestCase
$response = $this->post('/api/v1/transactions?include=tags', $data, ['Accept' => 'application/json']);
$response->assertStatus(200);
}
-
}
\ No newline at end of file
diff --git a/tests/Feature/Controllers/Account/ReconcileControllerTest.php b/tests/Feature/Controllers/Account/ReconcileControllerTest.php
index e9d929fc9b..27dd4d6eca 100644
--- a/tests/Feature/Controllers/Account/ReconcileControllerTest.php
+++ b/tests/Feature/Controllers/Account/ReconcileControllerTest.php
@@ -31,8 +31,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
/**
* Class ConfigurationControllerTest
diff --git a/tests/Feature/Controllers/AccountControllerTest.php b/tests/Feature/Controllers/AccountControllerTest.php
index c9a037c2e5..ba83d35bb3 100644
--- a/tests/Feature/Controllers/AccountControllerTest.php
+++ b/tests/Feature/Controllers/AccountControllerTest.php
@@ -182,8 +182,8 @@ class AccountControllerTest extends TestCase
$this->session(['start' => $date, 'end' => clone $date]);
// mock stuff:
- $tasker = $this->mock(AccountTaskerInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $tasker = $this->mock(AccountTaskerInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
@@ -222,7 +222,7 @@ class AccountControllerTest extends TestCase
public function testShowBrokenInitial()
{
// mock
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$date = new Carbon;
@@ -244,8 +244,8 @@ class AccountControllerTest extends TestCase
public function testShowByDateEmpty(string $range)
{
// mock stuff
- $collector = $this->mock(JournalCollectorInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAccounts')->andReturnSelf();
@@ -278,9 +278,9 @@ class AccountControllerTest extends TestCase
public function testShowInitial()
{
// mock stuff
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$date = new Carbon;
$this->session(['start' => $date, 'end' => clone $date]);
@@ -298,8 +298,8 @@ class AccountControllerTest extends TestCase
public function testStore()
{
// mock stuff
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -326,8 +326,8 @@ class AccountControllerTest extends TestCase
public function testStoreAnother()
{
// mock stuff
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -352,8 +352,8 @@ class AccountControllerTest extends TestCase
public function testUpdate()
{
// mock stuff
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('update')->once();
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -378,8 +378,8 @@ class AccountControllerTest extends TestCase
public function testUpdateAgain()
{
// mock stuff
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('update')->once();
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
diff --git a/tests/Feature/Controllers/Admin/LinkControllerTest.php b/tests/Feature/Controllers/Admin/LinkControllerTest.php
index 9a442da258..95c0571b36 100644
--- a/tests/Feature/Controllers/Admin/LinkControllerTest.php
+++ b/tests/Feature/Controllers/Admin/LinkControllerTest.php
@@ -25,8 +25,9 @@ namespace Tests\Feature\Controllers\Admin;
use FireflyIII\Models\LinkType;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use Illuminate\Support\Collection;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
+
/**
* Class LinkControllerTest
*
@@ -226,7 +227,7 @@ class LinkControllerTest extends TestCase
public function testUpdateNonEditable()
{
$repository = $this->mock(LinkTypeRepositoryInterface::class);
- $linkType = LinkType::where('editable', 0)->first();
+ $linkType = LinkType::where('editable', 0)->first();
$data = [
'name' => 'test ' . rand(1, 1000),
diff --git a/tests/Feature/Controllers/Admin/UpdateControllerTest.php b/tests/Feature/Controllers/Admin/UpdateControllerTest.php
index 119d978569..db791f2520 100644
--- a/tests/Feature/Controllers/Admin/UpdateControllerTest.php
+++ b/tests/Feature/Controllers/Admin/UpdateControllerTest.php
@@ -28,9 +28,9 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Configuration;
use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest;
+use Log;
use Mockery;
use Tests\TestCase;
-use Log;
/**
* Class UpdateControllerTest
diff --git a/tests/Feature/Controllers/Admin/UserControllerTest.php b/tests/Feature/Controllers/Admin/UserControllerTest.php
index 4f3d7aeec6..c6ed1b9257 100644
--- a/tests/Feature/Controllers/Admin/UserControllerTest.php
+++ b/tests/Feature/Controllers/Admin/UserControllerTest.php
@@ -24,8 +24,9 @@ namespace Tests\Feature\Controllers\Admin;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
+
/**
* Class UserControllerTest
*
diff --git a/tests/Feature/Controllers/AttachmentControllerTest.php b/tests/Feature/Controllers/AttachmentControllerTest.php
index 8da5e4c9c8..1b1fe59405 100644
--- a/tests/Feature/Controllers/AttachmentControllerTest.php
+++ b/tests/Feature/Controllers/AttachmentControllerTest.php
@@ -43,7 +43,7 @@ class AttachmentControllerTest extends TestCase
{
// mock stuff
$attachRepository = $this->mock(AttachmentRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('attachments.delete', [1]));
@@ -112,7 +112,7 @@ class AttachmentControllerTest extends TestCase
public function testEdit()
{
$attachRepository = $this->mock(AttachmentRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('attachments.edit', [1]));
diff --git a/tests/Feature/Controllers/Auth/ForgotPasswordControllerTest.php b/tests/Feature/Controllers/Auth/ForgotPasswordControllerTest.php
index 9f202ff36a..262f2410b6 100644
--- a/tests/Feature/Controllers/Auth/ForgotPasswordControllerTest.php
+++ b/tests/Feature/Controllers/Auth/ForgotPasswordControllerTest.php
@@ -23,8 +23,8 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Auth;
use FireflyIII\Repositories\User\UserRepositoryInterface;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
/**
* Class ForgotPasswordControllerTest
@@ -50,6 +50,7 @@ class ForgotPasswordControllerTest extends TestCase
*/
public function testSendResetLinkEmail()
{
+
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('hasRole')->andReturn(false)->once();
$data = [
diff --git a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php
index 7cbbda6cba..5792d1cdb8 100644
--- a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php
+++ b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php
@@ -24,9 +24,9 @@ namespace Tests\Feature\Controllers\Auth;
use FireflyIII\Models\Preference;
use Google2FA;
+use Log;
use Preferences;
use Tests\TestCase;
-use Log;
/**
* Class TwoFactorControllerTest
diff --git a/tests/Feature/Controllers/BudgetControllerTest.php b/tests/Feature/Controllers/BudgetControllerTest.php
index f8243d1481..faed7e71b7 100644
--- a/tests/Feature/Controllers/BudgetControllerTest.php
+++ b/tests/Feature/Controllers/BudgetControllerTest.php
@@ -295,7 +295,7 @@ class BudgetControllerTest extends TestCase
{
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository = $this->mock(BudgetRepositoryInterface::class);
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
$accountRepos->shouldReceive('setUser');
@@ -314,7 +314,7 @@ class BudgetControllerTest extends TestCase
{
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository = $this->mock(BudgetRepositoryInterface::class);
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
$accountRepos->shouldReceive('setUser');
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
diff --git a/tests/Feature/Controllers/CategoryControllerTest.php b/tests/Feature/Controllers/CategoryControllerTest.php
index 5545a2746d..127abe15a2 100644
--- a/tests/Feature/Controllers/CategoryControllerTest.php
+++ b/tests/Feature/Controllers/CategoryControllerTest.php
@@ -70,8 +70,8 @@ class CategoryControllerTest extends TestCase
{
// mock stuff
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -88,8 +88,8 @@ class CategoryControllerTest extends TestCase
{
// mock stuff
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$categoryRepos->shouldReceive('destroy')->andReturn(true);
@@ -108,8 +108,8 @@ class CategoryControllerTest extends TestCase
{
// mock stuff
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -126,10 +126,10 @@ class CategoryControllerTest extends TestCase
public function testIndex()
{
// mock stuff
- $category = factory(Category::class)->make();
+ $category = factory(Category::class)->make();
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$categoryRepos->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();
$categoryRepos->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
@@ -151,10 +151,10 @@ class CategoryControllerTest extends TestCase
public function testNoCategory(string $range)
{
// mock stuff
- $collector = $this->mock(JournalCollectorInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
@@ -188,10 +188,10 @@ class CategoryControllerTest extends TestCase
public function testNoCategoryAll(string $range)
{
// mock stuff
- $collector = $this->mock(JournalCollectorInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
@@ -224,10 +224,10 @@ class CategoryControllerTest extends TestCase
public function testNoCategoryDate(string $range)
{
// mock stuff
- $collector = $this->mock(JournalCollectorInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
@@ -267,10 +267,10 @@ class CategoryControllerTest extends TestCase
*/
public function testShow(string $range)
{
- $transaction = factory(Transaction::class)->make();
+ $transaction = factory(Transaction::class)->make();
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
// mock stuff
diff --git a/tests/Feature/Controllers/Chart/BudgetControllerTest.php b/tests/Feature/Controllers/Chart/BudgetControllerTest.php
index f6ff72de33..c15058e09d 100644
--- a/tests/Feature/Controllers/Chart/BudgetControllerTest.php
+++ b/tests/Feature/Controllers/Chart/BudgetControllerTest.php
@@ -112,10 +112,10 @@ class BudgetControllerTest extends TestCase
public function testExpenseAsset(string $range)
{
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
- $generator = $this->mock(GeneratorInterface::class);
- $collector = $this->mock(JournalCollectorInterface::class);
- $transactions = factory(Transaction::class, 10)->make();
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
+ $transactions = factory(Transaction::class, 10)->make();
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
$collector->shouldReceive('setAllAssetAccounts')->once()->andReturnSelf();
@@ -140,13 +140,12 @@ class BudgetControllerTest extends TestCase
*/
public function testExpenseCategory(string $range)
{
- $generator = $this->mock(GeneratorInterface::class);
- $collector = $this->mock(JournalCollectorInterface::class);
- $catRepos = $this->mock(CategoryRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
+ $catRepos = $this->mock(CategoryRepositoryInterface::class);
$repository = $this->mock(BudgetRepositoryInterface::class);
-
$transactions = factory(Transaction::class, 10)->make();
$categories = factory(Category::class, 10)->make();
@@ -178,7 +177,7 @@ class BudgetControllerTest extends TestCase
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository = $this->mock(BudgetRepositoryInterface::class);
$transactions = factory(Transaction::class, 10)->make();
$accounts = factory(Account::class, 10)->make();
diff --git a/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php b/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php
index 0bd3f6423d..69151a3bb8 100644
--- a/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php
+++ b/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php
@@ -52,8 +52,8 @@ class BudgetReportControllerTest extends TestCase
public function testAccountExpense()
{
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
- $generator = $this->mock(GeneratorInterface::class);
- $pieChart = $this->mock(MetaPieChartInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
@@ -75,8 +75,8 @@ class BudgetReportControllerTest extends TestCase
public function testBudgetExpense()
{
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
- $generator = $this->mock(GeneratorInterface::class);
- $pieChart = $this->mock(MetaPieChartInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setBudgets')->once()->andReturnSelf();
diff --git a/tests/Feature/Controllers/Chart/CategoryControllerTest.php b/tests/Feature/Controllers/Chart/CategoryControllerTest.php
index 6f227873b1..b939d38186 100644
--- a/tests/Feature/Controllers/Chart/CategoryControllerTest.php
+++ b/tests/Feature/Controllers/Chart/CategoryControllerTest.php
@@ -54,7 +54,7 @@ class CategoryControllerTest extends TestCase
$repository = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$generator = $this->mock(GeneratorInterface::class);
- $firstUse = new Carbon;
+ $firstUse = new Carbon;
$firstUse->subDays(3);
$repository->shouldReceive('spentInPeriod')->andReturn('0');
diff --git a/tests/Feature/Controllers/CurrencyControllerTest.php b/tests/Feature/Controllers/CurrencyControllerTest.php
index f2b64054a1..42a8033878 100644
--- a/tests/Feature/Controllers/CurrencyControllerTest.php
+++ b/tests/Feature/Controllers/CurrencyControllerTest.php
@@ -46,8 +46,8 @@ class CurrencyControllerTest extends TestCase
{
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$userRepos->shouldReceive('hasRole')->once()->andReturn(false);
@@ -106,8 +106,8 @@ class CurrencyControllerTest extends TestCase
{
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
@@ -126,8 +126,8 @@ class CurrencyControllerTest extends TestCase
{
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -187,8 +187,8 @@ class CurrencyControllerTest extends TestCase
{
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
diff --git a/tests/Feature/Controllers/DebugControllerTest.php b/tests/Feature/Controllers/DebugControllerTest.php
index 4c7d8f6649..4c66eebdf9 100644
--- a/tests/Feature/Controllers/DebugControllerTest.php
+++ b/tests/Feature/Controllers/DebugControllerTest.php
@@ -22,14 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
-use FireflyIII\Helpers\Collector\JournalCollectorInterface;
-use FireflyIII\Models\Account;
-use FireflyIII\Models\AccountType;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\Bill\BillRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
-use Illuminate\Support\Collection;
use Tests\TestCase;
/**
diff --git a/tests/Feature/Controllers/Import/IndexControllerTest.php b/tests/Feature/Controllers/Import/IndexControllerTest.php
index 5b2ae47799..9d05a54d1f 100644
--- a/tests/Feature/Controllers/Import/IndexControllerTest.php
+++ b/tests/Feature/Controllers/Import/IndexControllerTest.php
@@ -81,7 +81,7 @@ class IndexControllerTest extends TestCase
public function testStart()
{
$repository = $this->mock(ImportJobRepositoryInterface::class);
- $routine = $this->mock(FileRoutine::class);
+ $routine = $this->mock(FileRoutine::class);
$routine->shouldReceive('setJob')->once();
$routine->shouldReceive('run')->once()->andReturn(true);
@@ -97,7 +97,7 @@ class IndexControllerTest extends TestCase
public function testStartFailed()
{
$repository = $this->mock(ImportJobRepositoryInterface::class);
- $routine = $this->mock(FileRoutine::class);
+ $routine = $this->mock(FileRoutine::class);
$routine->shouldReceive('setJob')->once();
$routine->shouldReceive('run')->once()->andReturn(false);
diff --git a/tests/Feature/Controllers/JavascriptControllerTest.php b/tests/Feature/Controllers/JavascriptControllerTest.php
index 20ebcff46c..227c847e0e 100644
--- a/tests/Feature/Controllers/JavascriptControllerTest.php
+++ b/tests/Feature/Controllers/JavascriptControllerTest.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
-use FireflyIII\Factory\AccountFactory;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionCurrency;
diff --git a/tests/Feature/Controllers/Report/OperationsControllerTest.php b/tests/Feature/Controllers/Report/OperationsControllerTest.php
index 77a80b6df4..16b4e8f144 100644
--- a/tests/Feature/Controllers/Report/OperationsControllerTest.php
+++ b/tests/Feature/Controllers/Report/OperationsControllerTest.php
@@ -22,10 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Report;
-use FireflyIII\Helpers\Collector\JournalCollectorInterface;
-use FireflyIII\Helpers\Filter\InternalTransferFilter;
-use FireflyIII\Models\Transaction;
-use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use Tests\TestCase;
@@ -43,7 +39,7 @@ class OperationsControllerTest extends TestCase
*/
public function testExpenses()
{
- $tasker = $this->mock(AccountTaskerInterface::class);
+ $tasker = $this->mock(AccountTaskerInterface::class);
$tasker->shouldReceive('getExpenseReport')->andReturn([]);
$this->be($this->user());
@@ -56,7 +52,7 @@ class OperationsControllerTest extends TestCase
*/
public function testIncome()
{
- $tasker = $this->mock(AccountTaskerInterface::class);
+ $tasker = $this->mock(AccountTaskerInterface::class);
$tasker->shouldReceive('getIncomeReport')->andReturn([]);
$this->be($this->user());
@@ -69,7 +65,7 @@ class OperationsControllerTest extends TestCase
*/
public function testOperations()
{
- $tasker = $this->mock(AccountTaskerInterface::class);
+ $tasker = $this->mock(AccountTaskerInterface::class);
$tasker->shouldReceive('getExpenseReport')->andReturn([]);
$tasker->shouldReceive('getIncomeReport')->andReturn([]);
diff --git a/tests/Feature/Controllers/ReportControllerTest.php b/tests/Feature/Controllers/ReportControllerTest.php
index cecae0a6ab..e9700b667f 100644
--- a/tests/Feature/Controllers/ReportControllerTest.php
+++ b/tests/Feature/Controllers/ReportControllerTest.php
@@ -549,7 +549,7 @@ class ReportControllerTest extends TestCase
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
- $tag = $this->user()->tags()->find(1);
+ $tag = $this->user()->tags()->find(1);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
$tagRepos->shouldReceive('findByTag')->andReturn($tag)->twice();
@@ -603,7 +603,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$tagRepos = $this->mock(TagRepositoryInterface::class);
$generator = $this->mock(TYRG::class);
- $tag = $this->user()->tags()->find(1);
+ $tag = $this->user()->tags()->find(1);
$tagRepos->shouldReceive('setUser');
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
diff --git a/tests/Feature/Controllers/TagControllerTest.php b/tests/Feature/Controllers/TagControllerTest.php
index bebbb584e2..3d2ca65bab 100644
--- a/tests/Feature/Controllers/TagControllerTest.php
+++ b/tests/Feature/Controllers/TagControllerTest.php
@@ -47,7 +47,7 @@ class TagControllerTest extends TestCase
public function testCreate()
{
// mock stuff
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -63,7 +63,7 @@ class TagControllerTest extends TestCase
public function testDelete()
{
// mock stuff
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -96,7 +96,7 @@ class TagControllerTest extends TestCase
public function testEdit()
{
// mock stuff
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
diff --git a/tests/Feature/Controllers/Transaction/BulkControllerTest.php b/tests/Feature/Controllers/Transaction/BulkControllerTest.php
index a64d645edc..749f8a9f19 100644
--- a/tests/Feature/Controllers/Transaction/BulkControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/BulkControllerTest.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Transaction;
-use DB;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -86,8 +85,8 @@ class BulkControllerTest extends TestCase
// default transactions
$collection = $this->user()->transactionJournals()->take(4)->get();
- $allIds = $collection->pluck('id')->toArray();
- $route = route('transactions.bulk.edit', join(',', $allIds));
+ $allIds = $collection->pluck('id')->toArray();
+ $route = route('transactions.bulk.edit', join(',', $allIds));
$this->be($this->user());
$response = $this->get($route);
$response->assertStatus(200);
@@ -122,8 +121,8 @@ class BulkControllerTest extends TestCase
// default transactions
$collection = $this->user()->transactionJournals()->take(4)->get();
- $allIds = $collection->pluck('id')->toArray();
- $route = route('transactions.bulk.edit', join(',', $allIds));
+ $allIds = $collection->pluck('id')->toArray();
+ $route = route('transactions.bulk.edit', join(',', $allIds));
$this->be($this->user());
$response = $this->get($route);
$response->assertStatus(200);
diff --git a/tests/Feature/Controllers/Transaction/ConvertControllerTest.php b/tests/Feature/Controllers/Transaction/ConvertControllerTest.php
index b11897fa2f..ae7c786ea6 100644
--- a/tests/Feature/Controllers/Transaction/ConvertControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/ConvertControllerTest.php
@@ -369,7 +369,7 @@ class ConvertControllerTest extends TestCase
{
// mock stuff
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $repository = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(JournalRepositoryInterface::class);
$repository->shouldReceive('convert')->andReturn(new MessageBag);
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
diff --git a/tests/Feature/Controllers/Transaction/LinkControllerTest.php b/tests/Feature/Controllers/Transaction/LinkControllerTest.php
index 5904b15a24..871bebe9ff 100644
--- a/tests/Feature/Controllers/Transaction/LinkControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/LinkControllerTest.php
@@ -56,7 +56,7 @@ class LinkControllerTest extends TestCase
public function testDestroy()
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(LinkTypeRepositoryInterface::class);
+ $repository = $this->mock(LinkTypeRepositoryInterface::class);
$repository->shouldReceive('destroyLink');
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -127,7 +127,7 @@ class LinkControllerTest extends TestCase
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
- $data = [
+ $data = [
'link_other' => 0,
'link_type' => '1_inward',
];
@@ -147,7 +147,7 @@ class LinkControllerTest extends TestCase
public function testSwitchLink()
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(LinkTypeRepositoryInterface::class);
+ $repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('switchLink')->andReturn(false);
$this->be($this->user());
diff --git a/tests/Feature/Controllers/Transaction/MassControllerTest.php b/tests/Feature/Controllers/Transaction/MassControllerTest.php
index 9b0c042908..8492eab6d8 100644
--- a/tests/Feature/Controllers/Transaction/MassControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/MassControllerTest.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Transaction;
-use DB;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -92,7 +91,7 @@ class MassControllerTest extends TestCase
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
- $transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
+ $transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
$transfersArray = $transfers->pluck('id')->toArray();
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -113,7 +112,6 @@ class MassControllerTest extends TestCase
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection);
-
$this->be($this->user());
$response = $this->get(route('transactions.mass.edit', $transfersArray));
$response->assertStatus(200);
@@ -151,8 +149,8 @@ class MassControllerTest extends TestCase
// default transactions
$collection = $this->user()->transactionJournals()->take(4)->get();
- $allIds = $collection->pluck('id')->toArray();
- $route = route('transactions.mass.edit', join(',', $allIds));
+ $allIds = $collection->pluck('id')->toArray();
+ $route = route('transactions.mass.edit', join(',', $allIds));
$this->be($this->user());
$response = $this->get($route);
$response->assertStatus(200);
@@ -191,13 +189,13 @@ class MassControllerTest extends TestCase
// default transactions
$collection = $this->user()->transactionJournals()->take(4)->get();
- $allIds = $collection->pluck('id')->toArray();
+ $allIds = $collection->pluck('id')->toArray();
$this->be($this->user());
$response = $this->get(route('transactions.mass.edit', join(',', $allIds)));
$response->assertStatus(200);
$response->assertSee('Edit a number of transactions');
- $response->assertSessionHas('error','You have selected no valid transactions to edit.');
+ $response->assertSessionHas('error', 'You have selected no valid transactions to edit.');
// has bread crumb
$response->assertSee('
');
}
diff --git a/tests/Feature/Controllers/Transaction/SingleControllerTest.php b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
index e574aa0e45..7f91228b17 100644
--- a/tests/Feature/Controllers/Transaction/SingleControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
@@ -33,7 +33,6 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
diff --git a/tests/Feature/Controllers/TransactionControllerTest.php b/tests/Feature/Controllers/TransactionControllerTest.php
index 4332392b06..5d4182fb0e 100644
--- a/tests/Feature/Controllers/TransactionControllerTest.php
+++ b/tests/Feature/Controllers/TransactionControllerTest.php
@@ -271,8 +271,8 @@ class TransactionControllerTest extends TestCase
public function testShow()
{
// mock stuff
- $tasker = $this->mock(JournalTaskerInterface::class);
- $linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
+ $tasker = $this->mock(JournalTaskerInterface::class);
+ $linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
@@ -291,8 +291,8 @@ class TransactionControllerTest extends TestCase
*/
public function testShowOpeningBalance()
{
- $tasker = $this->mock(JournalTaskerInterface::class);
- $linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
+ $tasker = $this->mock(JournalTaskerInterface::class);
+ $linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
diff --git a/tests/Unit/Factory/BudgetFactoryTest.php b/tests/Unit/Factory/BudgetFactoryTest.php
index a55a6e6e14..7565a484cb 100644
--- a/tests/Unit/Factory/BudgetFactoryTest.php
+++ b/tests/Unit/Factory/BudgetFactoryTest.php
@@ -66,19 +66,6 @@ class BudgetFactoryTest extends TestCase
}
- /**
- * Put in unknown, get NULL
- *
- * @covers \FireflyIII\Factory\BudgetFactory
- */
- public function testFindUnknown()
- {
- /** @var BudgetFactory $factory */
- $factory = app(BudgetFactory::class);
- $factory->setUser($this->user());
- $this->assertNull($factory->find(null, 'I dont exist.'.rand(1,000)));
- }
-
/**
* Put in NULL, will find NULL.
*
@@ -94,4 +81,17 @@ class BudgetFactoryTest extends TestCase
}
+ /**
+ * Put in unknown, get NULL
+ *
+ * @covers \FireflyIII\Factory\BudgetFactory
+ */
+ public function testFindUnknown()
+ {
+ /** @var BudgetFactory $factory */
+ $factory = app(BudgetFactory::class);
+ $factory->setUser($this->user());
+ $this->assertNull($factory->find(null, 'I dont exist.' . rand(1, 000)));
+ }
+
}
\ No newline at end of file
diff --git a/tests/Unit/Factory/TransactionCurrencyFactoryTest.php b/tests/Unit/Factory/TransactionCurrencyFactoryTest.php
index fa061071b0..b629b9efcc 100644
--- a/tests/Unit/Factory/TransactionCurrencyFactoryTest.php
+++ b/tests/Unit/Factory/TransactionCurrencyFactoryTest.php
@@ -49,7 +49,8 @@ class TransactionCurrencyFactoryTest extends TestCase
*/
public function testFindByCode()
{
- $currency = TransactionCurrency::find(1);
+ // ;
+ $currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
$result = $factory->find(null, $currency->code);
@@ -61,7 +62,7 @@ class TransactionCurrencyFactoryTest extends TestCase
*/
public function testFindByID()
{
- $currency = TransactionCurrency::find(1);
+ $currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
$result = $factory->find($currency->id, null);
diff --git a/tests/Unit/Import/Configuration/FileConfiguratorTest.php b/tests/Unit/Import/Configuration/FileConfiguratorTest.php
index be381de6d0..2a5954e7bd 100644
--- a/tests/Unit/Import/Configuration/FileConfiguratorTest.php
+++ b/tests/Unit/Import/Configuration/FileConfiguratorTest.php
@@ -258,9 +258,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextDataUploadConfig()
{
// data
- $config = ['stage' => 'upload-config'];
+ $config = ['stage' => 'upload-config'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -289,9 +289,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextDataUploadInvalid()
{
// data
- $config = ['stage' => 'ksksjje'];
+ $config = ['stage' => 'ksksjje'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -313,9 +313,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextDataUploadMap()
{
// data:
- $config = ['stage' => 'map'];
+ $config = ['stage' => 'map'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -344,9 +344,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextDataUploadReady()
{
// data
- $config = ['stage' => 'ready'];
+ $config = ['stage' => 'ready'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -368,9 +368,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextDataUploadRoles()
{
// data
- $config = ['stage' => 'roles'];
+ $config = ['stage' => 'roles'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -397,9 +397,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextViewInitial()
{
// data
- $config = ['stage' => 'initial'];
+ $config = ['stage' => 'initial'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -426,9 +426,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextViewInvalid()
{
// data
- $config = ['stage' => 'slkds903ms90k'];
+ $config = ['stage' => 'slkds903ms90k'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -450,9 +450,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextViewMap()
{
// data
- $config = ['stage' => 'map'];
+ $config = ['stage' => 'map'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -491,9 +491,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextViewReady()
{
// data
- $config = ['stage' => 'ready'];
+ $config = ['stage' => 'ready'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -515,9 +515,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextViewRoles()
{
// data
- $config = ['stage' => 'roles'];
+ $config = ['stage' => 'roles'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -542,9 +542,9 @@ class FileConfiguratorTest extends TestCase
public function testGetNextViewUploadConfig()
{
// data
- $config = ['stage' => 'upload-config'];
+ $config = ['stage' => 'upload-config'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -569,9 +569,9 @@ class FileConfiguratorTest extends TestCase
public function testGetWarningMessage()
{
// data
- $config = ['stage' => 'upload-config'];
+ $config = ['stage' => 'upload-config'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -609,9 +609,9 @@ class FileConfiguratorTest extends TestCase
public function testIsJobConfiguredFalse()
{
// data
- $config = ['stage' => 'upload-config'];
+ $config = ['stage' => 'upload-config'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
@@ -648,9 +648,9 @@ class FileConfiguratorTest extends TestCase
public function testIsJobConfiguredTrue()
{
// data
- $config = ['stage' => 'ready'];
+ $config = ['stage' => 'ready'];
$extended = ['steps' => 0, 'done' => 0];
- $job = $this->getJob($config);
+ $job = $this->getJob($config);
// mock repos
$repository = $this->mock(ImportJobRepositoryInterface::class);
diff --git a/tests/Unit/Import/Converter/AmountTest.php b/tests/Unit/Import/Converter/AmountTest.php
index 1b02d37ac6..8545718f42 100644
--- a/tests/Unit/Import/Converter/AmountTest.php
+++ b/tests/Unit/Import/Converter/AmountTest.php
@@ -155,7 +155,7 @@ class AmountTest extends TestCase
'€1,44' => '1.44',
'(33.52)' => '-33.52',
'€(63.12)' => '-63.12',
- '($182.77)' => '-182.77',
+ '($182.77)' => '-182.77',
];
foreach ($values as $value => $expected) {
$converter = new Amount;
diff --git a/tests/Unit/Import/Mapper/AssetAccountIbansTest.php b/tests/Unit/Import/Mapper/AssetAccountIbansTest.php
index aea75c48ac..77d2016018 100644
--- a/tests/Unit/Import/Mapper/AssetAccountIbansTest.php
+++ b/tests/Unit/Import/Mapper/AssetAccountIbansTest.php
@@ -57,7 +57,7 @@ class AssetAccountIbansTest extends TestCase
$this->assertCount(3, $mapping);
// assert this is what the result looks like:
$result = [
- 0 => strval(trans('import.map_do_not_map')),
+ 0 => strval(trans('import.map_do_not_map')),
53 => 'Else',
17 => 'IBAN (Something)',
];
diff --git a/tests/Unit/Import/MapperPreProcess/TagsSpaceTest.php b/tests/Unit/Import/MapperPreProcess/TagsSpaceTest.php
index 207b5151cb..b1a55febda 100644
--- a/tests/Unit/Import/MapperPreProcess/TagsSpaceTest.php
+++ b/tests/Unit/Import/MapperPreProcess/TagsSpaceTest.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace Tests\Unit\Import\MapperPreProcess;
-use FireflyIII\Import\MapperPreProcess\TagsComma;
use FireflyIII\Import\MapperPreProcess\TagsSpace;
use Tests\TestCase;
diff --git a/tests/Unit/Middleware/BinderTest.php b/tests/Unit/Middleware/BinderTest.php
index 26ebd4e10b..3195ebbe90 100644
--- a/tests/Unit/Middleware/BinderTest.php
+++ b/tests/Unit/Middleware/BinderTest.php
@@ -1232,7 +1232,7 @@ class BinderTest extends TestCase
{
$tagRepos = $this->mock(TagRepositoryInterface::class);
$tagRepos->shouldReceive('setUser');
- $tags = $this->user()->tags()->whereIn('id', [1, 2])->get(['tags.*']);
+ $tags = $this->user()->tags()->whereIn('id', [1, 2])->get(['tags.*']);
$tagRepos->shouldReceive('get')->once()->andReturn($tags);
Route::middleware(Binder::class)->any(
@@ -1244,7 +1244,6 @@ class BinderTest extends TestCase
$names = join(',', $tags->pluck('tag')->toArray());
-
$this->be($this->user());
$response = $this->get('/_test/binder/' . $names);
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
diff --git a/tests/Unit/Middleware/IsDemoUserTest.php b/tests/Unit/Middleware/IsDemoUserTest.php
index 51bfefd12d..3e93f448d6 100644
--- a/tests/Unit/Middleware/IsDemoUserTest.php
+++ b/tests/Unit/Middleware/IsDemoUserTest.php
@@ -46,7 +46,6 @@ class IsDemoUserTest extends TestCase
}
-
/**
* @covers \FireflyIII\Http\Middleware\IsDemoUser::handle
*/
diff --git a/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php b/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php
new file mode 100644
index 0000000000..c6ef59165d
--- /dev/null
+++ b/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php
@@ -0,0 +1,99 @@
+.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Services\Internal\Destroy;
+
+use FireflyIII\Models\Account;
+use FireflyIII\Models\Transaction;
+use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
+use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
+use Tests\TestCase;
+
+/**
+ * Class AccountDestroyServiceTest
+ */
+class AccountDestroyServiceTest extends TestCase
+{
+ /**
+ * @covers \FireflyIII\Services\Internal\Destroy\AccountDestroyService
+ */
+ public function testDestroyBasic()
+ {
+ $account = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ 'virtual_balance' => '0', 'iban' => null, 'active' => true]
+ );
+ /** @var AccountDestroyService $service */
+ $service = app(AccountDestroyService::class);
+ $service->destroy($account, null);
+
+ $this->assertDatabaseMissing('accounts', ['id' => $account->id, 'deleted_at' => null]);
+ }
+
+ /**
+ * @covers \FireflyIII\Services\Internal\Destroy\AccountDestroyService
+ */
+ public function testDestroyDontMove()
+ {
+ // create objects:
+ $account = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ 'virtual_balance' => '0', 'iban' => null, 'active' => true]
+ );
+ Transaction::create(['account_id' => $account->id, 'transaction_journal_id' => 1, 'amount' => 10, 'transaction_currency_id' => 1]);
+
+ // mock delete service:
+ $service = $this->mock(JournalDestroyService::class);
+ $service->shouldReceive('destroy')->once();
+
+ /** @var AccountDestroyService $service */
+ $service = app(AccountDestroyService::class);
+ $service->destroy($account, null);
+
+ $this->assertDatabaseMissing('accounts', ['id' => $account->id, 'deleted_at' => null]);
+ }
+
+ /**
+ * @covers \FireflyIII\Services\Internal\Destroy\AccountDestroyService
+ */
+ public function testDestroyMove()
+ {
+ $account = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ 'virtual_balance' => '0', 'iban' => null, 'active' => true]
+ );
+ $move = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ 'virtual_balance' => '0', 'iban' => null, 'active' => true]
+ );
+ $transaction = Transaction::create(['account_id' => $account->id, 'transaction_journal_id' => 1, 'amount' => 10, 'transaction_currency_id' => 1]);
+ /** @var AccountDestroyService $service */
+ $service = app(AccountDestroyService::class);
+ $service->destroy($account, $move);
+
+ $this->assertDatabaseMissing('accounts', ['id' => $account->id, 'deleted_at' => null]);
+ $this->assertDatabaseMissing('transactions', ['account_id' => $account->id]);
+ $this->assertDatabaseHas('transactions', ['id' => $transaction->id, 'account_id' => $move->id]);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php b/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php
new file mode 100644
index 0000000000..fb184885d8
--- /dev/null
+++ b/tests/Unit/Services/Internal/Update/AccountUpdateServiceTest.php
@@ -0,0 +1,199 @@
+.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Services\Internal\Update;
+
+
+use Carbon\Carbon;
+use FireflyIII\Models\Account;
+use FireflyIII\Models\Note;
+use FireflyIII\Models\Transaction;
+use FireflyIII\Models\TransactionJournal;
+use FireflyIII\Services\Internal\Update\AccountUpdateService;
+use Tests\TestCase;
+
+/**
+ * Class AccountUpdateServiceTest
+ */
+class AccountUpdateServiceTest extends TestCase
+{
+ /**
+ * @covers \FireflyIII\Services\Internal\Update\AccountUpdateService
+ * @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
+ */
+ public function testDeleteExistingIB()
+ {
+ /** @var Account $account */
+ $account = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ '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,
+ ]
+ );
+ // 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,]
+ );
+
+
+ $data = [
+ 'name' => 'Some new name #' . rand(1, 1000),
+ 'active' => true,
+ 'virtualBalance' => '0',
+ 'iban' => null,
+ 'accountRole' => 'defaultAsset',
+ '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(0, $account->transactions()->count());
+ /** @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 testUpdateBasic()
+ {
+ /** @var Account $account */
+ $account = $this->user()->accounts()->first();
+ $data = [
+ 'name' => 'Some new name #' . rand(1, 1000),
+ 'active' => true,
+ 'virtualBalance' => '0',
+ 'iban' => null,
+ 'accountRole' => 'defaultAsset',
+ ];
+
+ /** @var AccountUpdateService $service */
+ $service = app(AccountUpdateService::class);
+ $account = $service->update($account, $data);
+
+ $this->assertEquals($data['name'], $account->name);
+ }
+
+ /**
+ * @covers \FireflyIII\Services\Internal\Update\AccountUpdateService
+ * @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
+ */
+ public function testUpdateExistingIB()
+ {
+ /** @var Account $account */
+ $account = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ '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,
+ ]
+ );
+ // 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,]
+ );
+
+
+ $data = [
+ 'name' => 'Some new name #' . rand(1, 1000),
+ 'active' => true,
+ 'virtualBalance' => '0',
+ 'iban' => null,
+ 'accountRole' => 'defaultAsset',
+ 'openingBalance' => '105',
+ '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(105, $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()
+ {
+ /** @var Account $account */
+ $account = Account::create(
+ ['user_id' => $this->user()->id, 'account_type_id' => 1, 'name' => 'Some name #' . rand(1, 1000),
+ 'virtual_balance' => '0', 'iban' => null, 'active' => true]
+ );
+ $data = [
+ 'name' => 'Some new name #' . rand(1, 1000),
+ 'active' => true,
+ 'virtualBalance' => '0',
+ 'iban' => null,
+ 'accountRole' => 'defaultAsset',
+ 'openingBalance' => '100',
+ '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);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.php b/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.php
new file mode 100644
index 0000000000..82122c66a9
--- /dev/null
+++ b/tests/Unit/Services/Internal/Update/JournalUpdateServiceTest.php
@@ -0,0 +1,133 @@
+.
+ */
+
+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 Tests\TestCase;
+
+/**
+ * Class JournalUpdateServiceTest
+ */
+class JournalUpdateServiceTest extends TestCase
+{
+ /**
+ * @covers \FireflyIII\Services\Internal\Update\JournalUpdateService
+ * @covers \FireflyIII\Services\Internal\Support\JournalServiceTrait
+ */
+ public function testUpdateBasic()
+ {
+ // 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');
+
+
+ /** @var TransactionJournal $journal */
+ $journal = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
+ $data = [
+ 'description' => 'Updated journal #' . rand(1, 1000),
+ '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 testUpdateLotsOfTransactions()
+ {
+ // 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');
+
+
+ /** @var TransactionJournal $journal */
+ $journal = $this->user()->transactionJournals()->skip(4)->where('transaction_type_id', 1)->first();
+ $data = [
+ 'description' => 'Updated journal #' . rand(1, 1000),
+ '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());
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Unit/TransactionRules/Actions/AddTagTest.php b/tests/Unit/TransactionRules/Actions/AddTagTest.php
index a2215b593f..948ffc4d67 100644
--- a/tests/Unit/TransactionRules/Actions/AddTagTest.php
+++ b/tests/Unit/TransactionRules/Actions/AddTagTest.php
@@ -39,14 +39,17 @@ class AddTagTest extends TestCase
*/
public function testActExistingTag()
{
- $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => 2, 'transaction_journal_id' => 1]);
+ $tag = Tag::inRandomOrder()->whereNull('deleted_at')->first();
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $journal->tags()->sync([$tag->id]);
+ $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
$ruleAction = new RuleAction;
- $ruleAction->action_value = 'housing';
- $journal = TransactionJournal::find(1);
- $action = new AddTag($ruleAction);
- $result = $action->act($journal);
+ $ruleAction->action_value = $tag->tag;
+
+ $action = new AddTag($ruleAction);
+ $result = $action->act($journal);
$this->assertFalse($result);
- $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => 2, 'transaction_journal_id' => 1]);
+ $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
}
/**
@@ -54,15 +57,15 @@ class AddTagTest extends TestCase
*/
public function testActNoTag()
{
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$ruleAction = new RuleAction;
$ruleAction->action_value = 'TestTag-' . rand(1, 1000);
- $journal = TransactionJournal::find(1);
$action = new AddTag($ruleAction);
$result = $action->act($journal);
$this->assertTrue($result);
// find newly created tag:
$tag = Tag::orderBy('id', 'DESC')->first();
- $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => 1]);
+ $this->assertDatabaseHas('tag_transaction_journal', ['tag_id' => $tag->id, 'transaction_journal_id' => $journal->id]);
}
}
diff --git a/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php b/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php
index f8abd109b7..2c99c3df51 100644
--- a/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php
+++ b/tests/Unit/TransactionRules/Actions/AppendDescriptionTest.php
@@ -41,13 +41,13 @@ class AppendDescriptionTest extends TestCase
$ruleAction = new RuleAction;
$ruleAction->action_value = 'APPEND';
- $journal = TransactionJournal::find(1);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$oldDescription = $journal->description;
$action = new AppendDescription($ruleAction);
$result = $action->act($journal);
$this->assertTrue($result);
- $journal = TransactionJournal::find(1);
+ $journal = TransactionJournal::find($journal->id);
$this->assertEquals($oldDescription . 'APPEND', $journal->description);
}
}
diff --git a/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php b/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
index 835fa4378b..ddf93eb788 100644
--- a/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
+++ b/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
@@ -39,7 +39,7 @@ class ClearBudgetTest extends TestCase
public function testAct()
{
// associate budget with journal:
- $journal = TransactionJournal::find(5);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$journal->budgets()->save($budget);
$this->assertGreaterThan(0, $journal->budgets()->count());
diff --git a/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php b/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
index 247b746b24..b72082b181 100644
--- a/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
+++ b/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
@@ -39,7 +39,7 @@ class ClearCategoryTest extends TestCase
public function testAct()
{
// associate budget with journal:
- $journal = TransactionJournal::find(5);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->budgets()->save($category);
$this->assertGreaterThan(0, $journal->categories()->count());
diff --git a/tests/Unit/TransactionRules/Actions/ClearNotesTest.php b/tests/Unit/TransactionRules/Actions/ClearNotesTest.php
index c1b11309e3..4670eca624 100644
--- a/tests/Unit/TransactionRules/Actions/ClearNotesTest.php
+++ b/tests/Unit/TransactionRules/Actions/ClearNotesTest.php
@@ -40,7 +40,7 @@ class ClearNotesTest extends TestCase
public function testAct()
{
// give journal a note:
- $journal = TransactionJournal::find(6);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first();
if (is_null($note)) {
$note = new Note;
diff --git a/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php b/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php
index ede107c04b..472697d372 100644
--- a/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php
+++ b/tests/Unit/TransactionRules/Actions/PrependDescriptionTest.php
@@ -41,7 +41,7 @@ class PrependDescriptionTest extends TestCase
// get journal, give fixed description
$description = 'text' . rand(1, 1000);
$prepend = 'prepend' . rand(1, 1234);
- $journal = TransactionJournal::find(7);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->description = $description;
$journal->save();
@@ -51,7 +51,7 @@ class PrependDescriptionTest extends TestCase
$action = new PrependDescription($ruleAction);
$result = $action->act($journal);
$this->assertTrue($result);
- $journal = TransactionJournal::find(7);
+ $journal = TransactionJournal::find($journal->id);
// assert result
$this->assertEquals($prepend . $description, $journal->description);
diff --git a/tests/Unit/TransactionRules/Actions/PrependNotesTest.php b/tests/Unit/TransactionRules/Actions/PrependNotesTest.php
index 9d94a8bd25..25f7bf0e4e 100644
--- a/tests/Unit/TransactionRules/Actions/PrependNotesTest.php
+++ b/tests/Unit/TransactionRules/Actions/PrependNotesTest.php
@@ -40,7 +40,7 @@ class PrependNotesTest extends TestCase
public function testAct()
{
// give journal some notes.
- $journal = TransactionJournal::find(8);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first();
$start = 'Default note text';
$toPrepend = 'This is prepended';
@@ -69,7 +69,7 @@ class PrependNotesTest extends TestCase
public function testActNewNote()
{
// give journal some notes.
- $journal = TransactionJournal::find(4);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first();
if (!is_null($note)) {
$note->forceDelete();
diff --git a/tests/Unit/TransactionRules/Actions/RemoveTagTest.php b/tests/Unit/TransactionRules/Actions/RemoveTagTest.php
index 0de1b55367..2a0ea6ccff 100644
--- a/tests/Unit/TransactionRules/Actions/RemoveTagTest.php
+++ b/tests/Unit/TransactionRules/Actions/RemoveTagTest.php
@@ -68,7 +68,7 @@ class RemoveTagTest extends TestCase
{
// get journal, link al tags:
/** @var TransactionJournal $journal */
- $journal = TransactionJournal::find(11);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$tags = $journal->user->tags()->get();
$journal->tags()->sync($tags->pluck('id')->toArray());
$this->assertEquals($tags->count(), $journal->tags()->get()->count());
diff --git a/tests/Unit/TransactionRules/Actions/SetBudgetTest.php b/tests/Unit/TransactionRules/Actions/SetBudgetTest.php
index baa196297b..2483de4d1a 100644
--- a/tests/Unit/TransactionRules/Actions/SetBudgetTest.php
+++ b/tests/Unit/TransactionRules/Actions/SetBudgetTest.php
@@ -41,7 +41,7 @@ class SetBudgetTest extends TestCase
public function testAct()
{
// get journal, remove all budgets
- $journal = TransactionJournal::find(12);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$budgetRepos->shouldReceive('setUser');
diff --git a/tests/Unit/TransactionRules/Actions/SetCategoryTest.php b/tests/Unit/TransactionRules/Actions/SetCategoryTest.php
index dd1f89c3ad..b9180f91f6 100644
--- a/tests/Unit/TransactionRules/Actions/SetCategoryTest.php
+++ b/tests/Unit/TransactionRules/Actions/SetCategoryTest.php
@@ -24,7 +24,6 @@ namespace Tests\Unit\TransactionRules\Actions;
use FireflyIII\Models\RuleAction;
use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\TransactionRules\Actions\SetCategory;
use Tests\TestCase;
@@ -40,7 +39,7 @@ class SetCategoryTest extends TestCase
public function testAct()
{
// get journal, remove all budgets
- $journal = TransactionJournal::find(13);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
$this->assertEquals(0, $journal->categories()->count());
diff --git a/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php b/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php
index 3e3cf5a0fc..4f329f772c 100644
--- a/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php
+++ b/tests/Unit/TransactionRules/Actions/SetDescriptionTest.php
@@ -41,7 +41,7 @@ class SetDescriptionTest extends TestCase
// get journal, give fixed description
$description = 'text' . rand(1, 1000);
$newDescription = 'new description' . rand(1, 1234);
- $journal = TransactionJournal::find(14);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->description = $description;
$journal->save();
@@ -51,7 +51,7 @@ class SetDescriptionTest extends TestCase
$action = new SetDescription($ruleAction);
$result = $action->act($journal);
$this->assertTrue($result);
- $journal = TransactionJournal::find(14);
+ $journal = TransactionJournal::find($journal->id);
// assert result
$this->assertEquals($newDescription, $journal->description);
diff --git a/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php b/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php
index bad202d8f9..7662bbb64b 100644
--- a/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php
+++ b/tests/Unit/TransactionRules/Actions/SetDestinationAccountTest.php
@@ -95,8 +95,8 @@ class SetDestinationAccountTest extends TestCase
*/
public function testActWithdrawalExisting()
{
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $type = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $type = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
// select split transactions to exclude them later:
$set = TransactionJournal::where('transaction_type_id', $type->id)->get(['transaction_journals.*']);
diff --git a/tests/Unit/TransactionRules/Actions/SetNotesTest.php b/tests/Unit/TransactionRules/Actions/SetNotesTest.php
index 645efd87b3..089bcf9b35 100644
--- a/tests/Unit/TransactionRules/Actions/SetNotesTest.php
+++ b/tests/Unit/TransactionRules/Actions/SetNotesTest.php
@@ -40,7 +40,7 @@ class SetNotesTest extends TestCase
public function testAct()
{
// give journal a note:
- $journal = TransactionJournal::find(15);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$note = $journal->notes()->first();
if (is_null($note)) {
$note = new Note;
@@ -69,7 +69,7 @@ class SetNotesTest extends TestCase
public function testActNoNotes()
{
// give journal a note:
- $journal = TransactionJournal::find(16);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->forceDelete();
$this->assertEquals(0, $journal->notes()->count());
diff --git a/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php b/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php
index 7ba1f2bb11..ecb6099d79 100644
--- a/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php
+++ b/tests/Unit/TransactionRules/Actions/SetSourceAccountTest.php
@@ -49,7 +49,7 @@ class SetSourceAccountTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $type = TransactionType::whereType(TransactionType::DEPOSIT)->first();
+ $type = TransactionType::whereType(TransactionType::DEPOSIT)->first();
// select split transactions to exclude them later:
$set = TransactionJournal::where('transaction_type_id', $type->id)->get(['transaction_journals.*']);
@@ -107,11 +107,11 @@ class SetSourceAccountTest extends TestCase
}
}
- $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
- $source = $sourceTr->account;
- $user = $journal->user;
- $accountType = AccountType::whereType(AccountType::ASSET)->first();
- $account = $user->accounts()->where('account_type_id', $accountType->id)->where('id', '!=', $source->id)->first();
+ $sourceTr = $journal->transactions()->where('amount', '<', 0)->first();
+ $source = $sourceTr->account;
+ $user = $journal->user;
+ $accountType = AccountType::whereType(AccountType::ASSET)->first();
+ $account = $user->accounts()->where('account_type_id', $accountType->id)->where('id', '!=', $source->id)->first();
$this->assertNotEquals($source->id, $account->id);
diff --git a/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php b/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
index 894ff2c56c..326d8912a1 100644
--- a/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
@@ -36,7 +36,7 @@ class BudgetIsTest extends TestCase
*/
public function testTriggeredJournal()
{
- $journal = TransactionJournal::find(17);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$journal->budgets()->detach();
$journal->budgets()->save($budget);
@@ -52,7 +52,7 @@ class BudgetIsTest extends TestCase
*/
public function testTriggeredNotJournal()
{
- $journal = TransactionJournal::find(18);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$otherBudget = $journal->user->budgets()->where('id', '!=', $budget->id)->first();
$journal->budgets()->detach();
@@ -69,7 +69,7 @@ class BudgetIsTest extends TestCase
*/
public function testTriggeredTransaction()
{
- $journal = TransactionJournal::find(19);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->first();
$budget = $journal->user->budgets()->first();
diff --git a/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php b/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
index cdf5a91fed..380cc1a6d3 100644
--- a/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/CategoryIsTest.php
@@ -36,7 +36,7 @@ class CategoryIsTest extends TestCase
*/
public function testTriggeredJournal()
{
- $journal = TransactionJournal::find(17);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
$journal->categories()->save($category);
@@ -52,7 +52,7 @@ class CategoryIsTest extends TestCase
*/
public function testTriggeredNotJournal()
{
- $journal = TransactionJournal::find(18);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$otherCategory = $journal->user->categories()->where('id', '!=', $category->id)->first();
$journal->categories()->detach();
@@ -69,11 +69,12 @@ class CategoryIsTest extends TestCase
*/
public function testTriggeredTransaction()
{
- $journal = TransactionJournal::find(19);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
+ $transaction->categories()->detach();
$transaction->categories()->save($category);
$this->assertEquals(0, $journal->categories()->count());
$this->assertEquals(1, $transaction->categories()->count());
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
index d26de68136..042550bb3c 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountContainsTest.php
@@ -36,8 +36,12 @@ class FromAccountContainsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(20);
- $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $count = 0;
+ while ($count === 0) {
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->transactions()->where('amount', '<', 0)->count();
+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ }
$account = $transaction->account;
$trigger = FromAccountContains::makeFromStrings($account->name, false);
@@ -50,7 +54,7 @@ class FromAccountContainsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(21);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountContains::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
index 002d58fc81..1ca1ee2b14 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
@@ -36,8 +36,12 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(22);
- $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ $count = 0;
+ while ($count === 0) {
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->transactions()->where('amount', '<', 0)->count();
+ $transaction = $journal->transactions()->where('amount', '<', 0)->first();
+ }
$account = $transaction->account;
$trigger = FromAccountEnds::makeFromStrings(substr($account->name, -3), false);
@@ -50,7 +54,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::find(22);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
$account = $transaction->account;
@@ -64,7 +68,7 @@ class FromAccountEndsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(23);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountEnds::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
index 0406d3dade..29d735ed10 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
@@ -36,7 +36,7 @@ class FromAccountIsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(22);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
$account = $transaction->account;
@@ -50,7 +50,7 @@ class FromAccountIsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(23);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountIs::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
index 8e9fc06a35..fc0e1810a8 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
@@ -36,7 +36,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(22);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
$account = $transaction->account;
@@ -50,7 +50,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::find(22);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '<', 0)->first();
$account = $transaction->account;
@@ -64,7 +64,7 @@ class FromAccountStartsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(23);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = FromAccountStarts::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php b/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
index 2893965335..6ad4a71235 100644
--- a/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasAnyBudgetTest.php
@@ -36,7 +36,7 @@ class HasAnyBudgetTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(25);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$journal->budgets()->detach();
$journal->budgets()->save($budget);
@@ -52,7 +52,7 @@ class HasAnyBudgetTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(24);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->budgets()->detach();
$this->assertEquals(0, $journal->budgets()->count());
$trigger = HasAnyBudget::makeFromStrings('', false);
@@ -65,7 +65,7 @@ class HasAnyBudgetTest extends TestCase
*/
public function testTriggeredTransactions()
{
- $journal = TransactionJournal::find(26);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$journal->budgets()->detach();
$this->assertEquals(0, $journal->budgets()->count());
diff --git a/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php b/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
index a159030f86..e8e38e08e4 100644
--- a/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasAnyCategoryTest.php
@@ -36,7 +36,7 @@ class HasAnyCategoryTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(25);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
$journal->categories()->save($category);
@@ -52,7 +52,7 @@ class HasAnyCategoryTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(24);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->categories()->detach();
$this->assertEquals(0, $journal->categories()->count());
$trigger = HasAnyCategory::makeFromStrings('', false);
@@ -65,7 +65,7 @@ class HasAnyCategoryTest extends TestCase
*/
public function testTriggeredTransactions()
{
- $journal = TransactionJournal::find(26);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
$this->assertEquals(0, $journal->categories()->count());
diff --git a/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php b/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
index caae916e60..1f0a928e88 100644
--- a/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasAnyTagTest.php
@@ -36,7 +36,7 @@ class HasAnyTagTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(25);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$tag = $journal->user->tags()->first();
$journal->tags()->detach();
$journal->tags()->save($tag);
@@ -52,7 +52,7 @@ class HasAnyTagTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(24);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->tags()->detach();
$this->assertEquals(0, $journal->tags()->count());
$trigger = HasAnyTag::makeFromStrings('', false);
diff --git a/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php b/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
index bd77be8975..dff4206d7c 100644
--- a/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
@@ -36,7 +36,13 @@ class HasAttachmentTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(26);
+ $count = 0;
+ while($count === 0) {
+ // this is kind of cheating but OK.
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->attachments()->count();
+ }
+
$attachment = $journal->user->attachments()->first();
$journal->attachments()->save($attachment);
$this->assertEquals(1, $journal->attachments()->count());
@@ -51,7 +57,13 @@ class HasAttachmentTest extends TestCase
*/
public function testTriggeredFalse()
{
- $journal = TransactionJournal::find(27);
+ $count = 0;
+ while ($count === 0) {
+ // this is kind of cheating but OK.
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->attachments()->count();
+ }
+
$this->assertEquals(0, $journal->attachments()->count());
$trigger = HasAttachment::makeFromStrings('1', false);
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php b/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
index cbc6c93291..d1d516094b 100644
--- a/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
@@ -36,7 +36,7 @@ class HasNoBudgetTest extends TestCase
*/
public function testTriggeredBudget()
{
- $journal = TransactionJournal::find(28);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$budget = $journal->user->budgets()->first();
$journal->budgets()->detach();
$journal->budgets()->save($budget);
@@ -52,7 +52,7 @@ class HasNoBudgetTest extends TestCase
*/
public function testTriggeredNoBudget()
{
- $journal = TransactionJournal::find(29);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->budgets()->detach();
$this->assertEquals(0, $journal->budgets()->count());
@@ -66,7 +66,7 @@ class HasNoBudgetTest extends TestCase
*/
public function testTriggeredTransaction()
{
- $journal = TransactionJournal::find(30);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->first();
$budget = $journal->user->budgets()->first();
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php b/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
index 55583428cc..1d54060af2 100644
--- a/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasNoCategoryTest.php
@@ -36,7 +36,7 @@ class HasNoCategoryTest extends TestCase
*/
public function testTriggeredCategory()
{
- $journal = TransactionJournal::find(31);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
$journal->categories()->save($category);
@@ -52,7 +52,7 @@ class HasNoCategoryTest extends TestCase
*/
public function testTriggeredNoCategory()
{
- $journal = TransactionJournal::find(32);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->categories()->detach();
$this->assertEquals(0, $journal->categories()->count());
@@ -66,7 +66,7 @@ class HasNoCategoryTest extends TestCase
*/
public function testTriggeredTransaction()
{
- $journal = TransactionJournal::find(33);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->first();
$category = $journal->user->categories()->first();
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php b/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
index da63e1db2a..027176dce7 100644
--- a/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasNoTagTest.php
@@ -36,7 +36,7 @@ class HasNoTagTest extends TestCase
*/
public function testTriggeredNoTag()
{
- $journal = TransactionJournal::find(34);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->tags()->detach();
$this->assertEquals(0, $journal->tags()->count());
@@ -50,7 +50,7 @@ class HasNoTagTest extends TestCase
*/
public function testTriggeredTag()
{
- $journal = TransactionJournal::find(35);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$tag = $journal->user->tags()->first();
$journal->tags()->detach();
$journal->tags()->save($tag);
diff --git a/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php b/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
index 7e86d48639..556eb42664 100644
--- a/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
+++ b/tests/Unit/TransactionRules/Triggers/NotesAnyTest.php
@@ -37,7 +37,7 @@ class NotesAnyTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(36);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -53,7 +53,7 @@ class NotesAnyTest extends TestCase
*/
public function testTriggeredEmpty()
{
- $journal = TransactionJournal::find(37);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -69,7 +69,7 @@ class NotesAnyTest extends TestCase
*/
public function testTriggeredNone()
{
- $journal = TransactionJournal::find(38);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$trigger = NotesAny::makeFromStrings('', false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/NotesAreTest.php b/tests/Unit/TransactionRules/Triggers/NotesAreTest.php
index beaf485130..1bb3ea917f 100644
--- a/tests/Unit/TransactionRules/Triggers/NotesAreTest.php
+++ b/tests/Unit/TransactionRules/Triggers/NotesAreTest.php
@@ -37,7 +37,7 @@ class NotesAreTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(39);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -53,7 +53,7 @@ class NotesAreTest extends TestCase
*/
public function testTriggeredDifferent()
{
- $journal = TransactionJournal::find(41);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -69,7 +69,7 @@ class NotesAreTest extends TestCase
*/
public function testTriggeredEmpty()
{
- $journal = TransactionJournal::find(40);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -85,7 +85,7 @@ class NotesAreTest extends TestCase
*/
public function testTriggeredNone()
{
- $journal = TransactionJournal::find(42);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$trigger = NotesAre::makeFromStrings('Bla bla', false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/NotesContainTest.php b/tests/Unit/TransactionRules/Triggers/NotesContainTest.php
index c7a33a0392..2ca2b43161 100644
--- a/tests/Unit/TransactionRules/Triggers/NotesContainTest.php
+++ b/tests/Unit/TransactionRules/Triggers/NotesContainTest.php
@@ -37,7 +37,7 @@ class NotesContainTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(43);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -53,7 +53,7 @@ class NotesContainTest extends TestCase
*/
public function testTriggeredDifferent()
{
- $journal = TransactionJournal::find(46);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -69,7 +69,7 @@ class NotesContainTest extends TestCase
*/
public function testTriggeredEmpty()
{
- $journal = TransactionJournal::find(44);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -85,7 +85,7 @@ class NotesContainTest extends TestCase
*/
public function testTriggeredNone()
{
- $journal = TransactionJournal::find(47);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$trigger = NotesContain::makeFromStrings('Bla bla', false);
$result = $trigger->triggered($journal);
@@ -97,7 +97,7 @@ class NotesContainTest extends TestCase
*/
public function testTriggeredPartial()
{
- $journal = TransactionJournal::find(45);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php b/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
index 1749aaa19b..12910fd587 100644
--- a/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
+++ b/tests/Unit/TransactionRules/Triggers/NotesEmptyTest.php
@@ -37,7 +37,7 @@ class NotesEmptyTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(48);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$trigger = NotesEmpty::makeFromStrings('', false);
$result = $trigger->triggered($journal);
@@ -49,7 +49,7 @@ class NotesEmptyTest extends TestCase
*/
public function testTriggeredEmpty()
{
- $journal = TransactionJournal::find(49);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -65,7 +65,7 @@ class NotesEmptyTest extends TestCase
*/
public function testTriggeredPartial()
{
- $journal = TransactionJournal::find(50);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/NotesEndTest.php b/tests/Unit/TransactionRules/Triggers/NotesEndTest.php
index a358e2fbe8..e410264174 100644
--- a/tests/Unit/TransactionRules/Triggers/NotesEndTest.php
+++ b/tests/Unit/TransactionRules/Triggers/NotesEndTest.php
@@ -37,7 +37,7 @@ class NotesEndTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(51);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -53,7 +53,7 @@ class NotesEndTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::find(53);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -69,7 +69,7 @@ class NotesEndTest extends TestCase
*/
public function testTriggeredNoMatch()
{
- $journal = TransactionJournal::find(52);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/NotesStartTest.php b/tests/Unit/TransactionRules/Triggers/NotesStartTest.php
index 34c325e9bb..7a795bc2be 100644
--- a/tests/Unit/TransactionRules/Triggers/NotesStartTest.php
+++ b/tests/Unit/TransactionRules/Triggers/NotesStartTest.php
@@ -37,7 +37,7 @@ class NotesStartTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(54);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -53,7 +53,7 @@ class NotesStartTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::find(55);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
@@ -69,7 +69,7 @@ class NotesStartTest extends TestCase
*/
public function testTriggeredNoMatch()
{
- $journal = TransactionJournal::find(56);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->notes()->delete();
$note = new Note();
$note->noteable()->associate($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/TagIsTest.php b/tests/Unit/TransactionRules/Triggers/TagIsTest.php
index 40ad9fc60a..8abe809705 100644
--- a/tests/Unit/TransactionRules/Triggers/TagIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/TagIsTest.php
@@ -36,7 +36,7 @@ class TagIsTest extends TestCase
*/
public function testNotTriggered()
{
- $journal = TransactionJournal::find(58);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->tags()->detach();
$this->assertEquals(0, $journal->tags()->count());
@@ -50,7 +50,7 @@ class TagIsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(57);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$journal->tags()->detach();
$tags = $journal->user->tags()->take(3)->get();
$search = '';
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
index 9856b6e47a..405bec7e14 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
@@ -36,7 +36,7 @@ class ToAccountContainsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(59);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
$account = $transaction->account;
$trigger = ToAccountContains::makeFromStrings($account->name, false);
@@ -49,7 +49,7 @@ class ToAccountContainsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(60);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = ToAccountContains::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
$this->assertFalse($result);
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
index aacbbaa888..a9667d30ff 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
@@ -36,10 +36,14 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(61);
- $transaction = $journal->transactions()->where('amount', '>', 0)->first();
- $account = $transaction->account;
+ $count = 0;
+ while ($count === 0) {
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->transactions()->where('amount', '>', 0)->count();
+ $transaction = $journal->transactions()->where('amount', '>', 0)->first();
+ }
+ $account = $transaction->account;
$trigger = ToAccountEnds::makeFromStrings(substr($account->name, -3), false);
$result = $trigger->triggered($journal);
$this->assertTrue($result);
@@ -50,8 +54,12 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::find(62);
- $transaction = $journal->transactions()->where('amount', '>', 0)->first();
+ $count = 0;
+ while ($count === 0) {
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->transactions()->where('amount', '>', 0)->count();
+ $transaction = $journal->transactions()->where('amount', '>', 0)->first();
+ }
$account = $transaction->account;
$trigger = ToAccountEnds::makeFromStrings('bla-bla-bla' . $account->name, false);
@@ -64,7 +72,7 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(63);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = ToAccountEnds::makeFromStrings(strval(rand(1, 234)), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
index 7d192f2dd5..c2c8360163 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
@@ -36,7 +36,7 @@ class ToAccountIsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(64);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
$account = $transaction->account;
@@ -50,7 +50,7 @@ class ToAccountIsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(65);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = ToAccountIs::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
index a63bec9d54..50d26f4b4e 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
@@ -36,7 +36,7 @@ class ToAccountStartsTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(66);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
$account = $transaction->account;
@@ -50,7 +50,7 @@ class ToAccountStartsTest extends TestCase
*/
public function testTriggeredLonger()
{
- $journal = TransactionJournal::find(67);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
$account = $transaction->account;
@@ -64,7 +64,7 @@ class ToAccountStartsTest extends TestCase
*/
public function testTriggeredNot()
{
- $journal = TransactionJournal::find(68);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = ToAccountStarts::makeFromStrings('some name' . rand(1, 234), false);
$result = $trigger->triggered($journal);
diff --git a/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php b/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
index 4c31ade984..f359da8e4f 100644
--- a/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
+++ b/tests/Unit/TransactionRules/Triggers/TransactionTypeTest.php
@@ -36,7 +36,7 @@ class TransactionTypeTest extends TestCase
*/
public function testTriggered()
{
- $journal = TransactionJournal::find(69);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$type = $journal->transactionType->type;
$trigger = TransactionType::makeFromStrings($type, false);
$result = $trigger->triggered($journal);
@@ -48,7 +48,7 @@ class TransactionTypeTest extends TestCase
*/
public function testTriggeredFalse()
{
- $journal = TransactionJournal::find(70);
+ $journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$trigger = TransactionType::makeFromStrings('NonExisting', false);
$result = $trigger->triggered($journal);
$this->assertFalse($result);
diff --git a/tests/Unit/Transformers/PiggyBankEventTransformerTest.php b/tests/Unit/Transformers/PiggyBankEventTransformerTest.php
index aa9688b0c3..a2aa4fdfb5 100644
--- a/tests/Unit/Transformers/PiggyBankEventTransformerTest.php
+++ b/tests/Unit/Transformers/PiggyBankEventTransformerTest.php
@@ -111,8 +111,8 @@ class PiggyBankEventTransformerTest extends TestCase
$accountMeta = AccountMeta::create(
[
'account_id' => $account->id,
- 'name' => 'currency_id',
- 'data' => 1,
+ 'name' => 'currency_id',
+ 'data' => 1,
]
);