diff --git a/app/Repositories/Journal/JournalTasker.php b/app/Repositories/Journal/JournalTasker.php index 5958b0ff1c..5aacaa94ac 100644 --- a/app/Repositories/Journal/JournalTasker.php +++ b/app/Repositories/Journal/JournalTasker.php @@ -144,11 +144,11 @@ class JournalTasker implements JournalTaskerInterface 'transaction_currency_id' => $entry->transaction_currency_id, 'transaction_currency_code' => $entry->transaction_currency_code, 'transaction_currency_symbol' => $entry->transaction_currency_symbol, - 'transaction_currency_dp' => $entry->transaction_currency_dp, + 'transaction_currency_dp' => $entry->transaction_currency_dp, 'foreign_currency_id' => $entry->foreign_currency_id, 'foreign_currency_code' => $entry->foreign_currency_code, 'foreign_currency_symbol' => $entry->foreign_currency_symbol, - 'foreign_currency_dp' => $entry->foreign_currency_dp, + 'foreign_currency_dp' => $entry->foreign_currency_dp, ]; if ($entry->destination_account_type === AccountType::CASH) { $transaction['destination_account_name'] = ''; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index bd8d30b2a9..2727d4d86c 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -217,25 +217,31 @@ $factory->define( $factory->define( FireflyIII\Models\Transaction::class, function (Faker\Generator $faker) { return [ - 'transaction_amount' => strval($faker->randomFloat(2, -100, 100)), - 'destination_amount' => strval($faker->randomFloat(2, -100, 100)), - 'opposing_account_id' => $faker->numberBetween(1, 10), - 'source_account_id' => $faker->numberBetween(1, 10), - 'opposing_account_name' => $faker->words(3, true), - 'description' => $faker->words(3, true), - 'source_account_name' => $faker->words(3, true), - 'destination_account_id' => $faker->numberBetween(1, 10), - 'date' => new Carbon, - 'destination_account_name' => $faker->words(3, true), - 'amount' => strval($faker->randomFloat(2, -100, 100)), - 'budget_id' => 0, - 'category' => $faker->words(3, true), - 'transaction_journal_id' => $faker->numberBetween(1, 10), - 'journal_id' => $faker->numberBetween(1, 10), - 'transaction_currency_code' => 'EUR', - 'transaction_type_type' => 'Withdrawal', - 'account_encrypted' => 0, - 'account_name' => 'Some name', + 'transaction_amount' => strval($faker->randomFloat(2, -100, 100)), + 'destination_amount' => strval($faker->randomFloat(2, -100, 100)), + 'opposing_account_id' => $faker->numberBetween(1, 10), + 'source_account_id' => $faker->numberBetween(1, 10), + 'opposing_account_name' => $faker->words(3, true), + 'description' => $faker->words(3, true), + 'source_account_name' => $faker->words(3, true), + 'destination_account_id' => $faker->numberBetween(1, 10), + 'date' => new Carbon, + 'destination_account_name' => $faker->words(3, true), + 'amount' => strval($faker->randomFloat(2, -100, 100)), + 'budget_id' => 0, + 'category' => $faker->words(3, true), + 'transaction_journal_id' => $faker->numberBetween(1, 10), + 'journal_id' => $faker->numberBetween(1, 10), + 'transaction_currency_code' => 'EUR', + 'transaction_type_type' => 'Withdrawal', + 'account_encrypted' => 0, + 'account_name' => 'Some name', + 'transaction_currency_id' => 1, + 'transaction_currency_symbol' => '€', + 'foreign_destination_amount' => null, + 'foreign_currency_id' => null, + 'foreign_currency_code' => null, + 'foreign_currency_symbol' => null, ]; } ); \ No newline at end of file diff --git a/tests/Feature/Controllers/JsonControllerTest.php b/tests/Feature/Controllers/JsonControllerTest.php index 798575bbef..22c4152d77 100644 --- a/tests/Feature/Controllers/JsonControllerTest.php +++ b/tests/Feature/Controllers/JsonControllerTest.php @@ -21,7 +21,6 @@ use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Account\AccountTaskerInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; @@ -88,15 +87,17 @@ class JsonControllerTest extends TestCase public function testBoxBillsPaid() { // mock stuff + $billRepos = $this->mock(BillRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $billRepos->shouldReceive('getBillsPaidInRange')->andReturn('-100'); $this->be($this->user()); + $currency = Amount::getDefaultCurrency(); $response = $this->get(route('json.box.paid')); $response->assertStatus(200); - $response->assertExactJson(['amount' => Amount::format('100', false), 'amount_raw' => '100', 'box' => 'bills-paid']); + $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'bills-paid']); } /** @@ -105,6 +106,7 @@ class JsonControllerTest extends TestCase public function testBoxBillsUnpaid() { // mock stuff + $billRepos = $this->mock(BillRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); @@ -112,9 +114,10 @@ class JsonControllerTest extends TestCase $this->be($this->user()); + $currency = Amount::getDefaultCurrency(); $response = $this->get(route('json.box.unpaid')); $response->assertStatus(200); - $response->assertExactJson(['amount' => Amount::format('100', false), 'amount_raw' => '100', 'box' => 'bills-unpaid']); + $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'bills-unpaid']); } /** @@ -123,8 +126,7 @@ class JsonControllerTest extends TestCase public function testBoxIn() { // mock stuff - $accountRepos = $this->mock(AccountRepositoryInterface::class); - $tasker = $this->mock(AccountTaskerInterface::class); + $collector = $this->mock(JournalCollectorInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); @@ -139,9 +141,10 @@ class JsonControllerTest extends TestCase $this->be($this->user()); + $currency = Amount::getDefaultCurrency(); $response = $this->get(route('json.box.in')); $response->assertStatus(200); - $response->assertExactJson(['amount' => Amount::format('100', false), 'amount_raw' => '100', 'box' => 'in']); + $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'in']); } /** @@ -150,8 +153,7 @@ class JsonControllerTest extends TestCase public function testBoxOut() { // mock stuff - $accountRepos = $this->mock(AccountRepositoryInterface::class); - $tasker = $this->mock(AccountTaskerInterface::class); + $collector = $this->mock(JournalCollectorInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); @@ -165,9 +167,10 @@ class JsonControllerTest extends TestCase $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once(); $this->be($this->user()); + $currency = Amount::getDefaultCurrency(); $response = $this->get(route('json.box.out')); $response->assertStatus(200); - $response->assertExactJson(['amount' => Amount::format('100', false), 'amount_raw' => '100', 'box' => 'out']); + $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'out']); } /** diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.php index 00c5a5b3c6..578802bc8c 100644 --- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php +++ b/tests/Feature/Controllers/Transaction/SplitControllerTest.php @@ -7,7 +7,7 @@ * See the LICENSE file for details. */ -declare(strict_types = 1); +declare(strict_types=1); namespace Tests\Feature\Controllers\Transaction; @@ -32,37 +32,6 @@ use Tests\TestCase; */ class SplitControllerTest extends TestCase { - /** - * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::edit - * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::__construct - * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::arrayFromJournal - * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::getTransactionDataFromJournal - */ - public function testEditSingle() - { - - $currencyRepository = $this->mock(CurrencyRepositoryInterface::class); - $accountRepository = $this->mock(AccountRepositoryInterface::class); - $budgetRepository = $this->mock(BudgetRepositoryInterface::class); - $transactions = factory(Transaction::class, 1)->make(); - $tasker = $this->mock(JournalTaskerInterface::class); - - $currencyRepository->shouldReceive('get')->once()->andReturn(new Collection); - $accountRepository->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]]) - ->andReturn(new Collection)->once(); - $budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection); - $tasker->shouldReceive('getTransactionsOverview')->andReturn($transactions->toArray()); - - - $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); - $this->be($this->user()); - $response = $this->get(route('transactions.split.edit', [$deposit->id])); - $response->assertStatus(200); - // has bread crumb - $response->assertSee('