mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	These changes fix the tests.
This commit is contained in:
		| @@ -144,11 +144,11 @@ class JournalTasker implements JournalTaskerInterface | |||||||
|                 'transaction_currency_id'     => $entry->transaction_currency_id, |                 'transaction_currency_id'     => $entry->transaction_currency_id, | ||||||
|                 'transaction_currency_code'   => $entry->transaction_currency_code, |                 'transaction_currency_code'   => $entry->transaction_currency_code, | ||||||
|                 'transaction_currency_symbol' => $entry->transaction_currency_symbol, |                 '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_id'         => $entry->foreign_currency_id, | ||||||
|                 'foreign_currency_code'       => $entry->foreign_currency_code, |                 'foreign_currency_code'       => $entry->foreign_currency_code, | ||||||
|                 'foreign_currency_symbol'     => $entry->foreign_currency_symbol, |                 '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) { |             if ($entry->destination_account_type === AccountType::CASH) { | ||||||
|                 $transaction['destination_account_name'] = ''; |                 $transaction['destination_account_name'] = ''; | ||||||
|   | |||||||
| @@ -217,25 +217,31 @@ $factory->define( | |||||||
| $factory->define( | $factory->define( | ||||||
|     FireflyIII\Models\Transaction::class, function (Faker\Generator $faker) { |     FireflyIII\Models\Transaction::class, function (Faker\Generator $faker) { | ||||||
|     return [ |     return [ | ||||||
|         'transaction_amount'        => strval($faker->randomFloat(2, -100, 100)), |         'transaction_amount'          => strval($faker->randomFloat(2, -100, 100)), | ||||||
|         'destination_amount'        => strval($faker->randomFloat(2, -100, 100)), |         'destination_amount'          => strval($faker->randomFloat(2, -100, 100)), | ||||||
|         'opposing_account_id'       => $faker->numberBetween(1, 10), |         'opposing_account_id'         => $faker->numberBetween(1, 10), | ||||||
|         'source_account_id'         => $faker->numberBetween(1, 10), |         'source_account_id'           => $faker->numberBetween(1, 10), | ||||||
|         'opposing_account_name'     => $faker->words(3, true), |         'opposing_account_name'       => $faker->words(3, true), | ||||||
|         'description'               => $faker->words(3, true), |         'description'                 => $faker->words(3, true), | ||||||
|         'source_account_name'       => $faker->words(3, true), |         'source_account_name'         => $faker->words(3, true), | ||||||
|         'destination_account_id'    => $faker->numberBetween(1, 10), |         'destination_account_id'      => $faker->numberBetween(1, 10), | ||||||
|         'date'                      => new Carbon, |         'date'                        => new Carbon, | ||||||
|         'destination_account_name'  => $faker->words(3, true), |         'destination_account_name'    => $faker->words(3, true), | ||||||
|         'amount'                    => strval($faker->randomFloat(2, -100, 100)), |         'amount'                      => strval($faker->randomFloat(2, -100, 100)), | ||||||
|         'budget_id'                 => 0, |         'budget_id'                   => 0, | ||||||
|         'category'                  => $faker->words(3, true), |         'category'                    => $faker->words(3, true), | ||||||
|         'transaction_journal_id'    => $faker->numberBetween(1, 10), |         'transaction_journal_id'      => $faker->numberBetween(1, 10), | ||||||
|         'journal_id'                => $faker->numberBetween(1, 10), |         'journal_id'                  => $faker->numberBetween(1, 10), | ||||||
|         'transaction_currency_code' => 'EUR', |         'transaction_currency_code'   => 'EUR', | ||||||
|         'transaction_type_type'     => 'Withdrawal', |         'transaction_type_type'       => 'Withdrawal', | ||||||
|         'account_encrypted'         => 0, |         'account_encrypted'           => 0, | ||||||
|         'account_name'              => 'Some name', |         '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, | ||||||
|     ]; |     ]; | ||||||
| } | } | ||||||
| ); | ); | ||||||
| @@ -21,7 +21,6 @@ use FireflyIII\Models\Transaction; | |||||||
| use FireflyIII\Models\TransactionJournal; | use FireflyIII\Models\TransactionJournal; | ||||||
| use FireflyIII\Models\TransactionType; | use FireflyIII\Models\TransactionType; | ||||||
| use FireflyIII\Repositories\Account\AccountRepositoryInterface; | use FireflyIII\Repositories\Account\AccountRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Account\AccountTaskerInterface; |  | ||||||
| use FireflyIII\Repositories\Bill\BillRepositoryInterface; | use FireflyIII\Repositories\Bill\BillRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; | ||||||
| use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | use FireflyIII\Repositories\Category\CategoryRepositoryInterface; | ||||||
| @@ -88,15 +87,17 @@ class JsonControllerTest extends TestCase | |||||||
|     public function testBoxBillsPaid() |     public function testBoxBillsPaid() | ||||||
|     { |     { | ||||||
|         // mock stuff |         // mock stuff | ||||||
|  |  | ||||||
|         $billRepos    = $this->mock(BillRepositoryInterface::class); |         $billRepos    = $this->mock(BillRepositoryInterface::class); | ||||||
|         $journalRepos = $this->mock(JournalRepositoryInterface::class); |         $journalRepos = $this->mock(JournalRepositoryInterface::class); | ||||||
|         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); |         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); | ||||||
|         $billRepos->shouldReceive('getBillsPaidInRange')->andReturn('-100'); |         $billRepos->shouldReceive('getBillsPaidInRange')->andReturn('-100'); | ||||||
|  |  | ||||||
|         $this->be($this->user()); |         $this->be($this->user()); | ||||||
|  |         $currency     = Amount::getDefaultCurrency(); | ||||||
|         $response = $this->get(route('json.box.paid')); |         $response = $this->get(route('json.box.paid')); | ||||||
|         $response->assertStatus(200); |         $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() |     public function testBoxBillsUnpaid() | ||||||
|     { |     { | ||||||
|         // mock stuff |         // mock stuff | ||||||
|  |  | ||||||
|         $billRepos    = $this->mock(BillRepositoryInterface::class); |         $billRepos    = $this->mock(BillRepositoryInterface::class); | ||||||
|         $journalRepos = $this->mock(JournalRepositoryInterface::class); |         $journalRepos = $this->mock(JournalRepositoryInterface::class); | ||||||
|         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); |         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); | ||||||
| @@ -112,9 +114,10 @@ class JsonControllerTest extends TestCase | |||||||
|  |  | ||||||
|  |  | ||||||
|         $this->be($this->user()); |         $this->be($this->user()); | ||||||
|  |         $currency     = Amount::getDefaultCurrency(); | ||||||
|         $response = $this->get(route('json.box.unpaid')); |         $response = $this->get(route('json.box.unpaid')); | ||||||
|         $response->assertStatus(200); |         $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() |     public function testBoxIn() | ||||||
|     { |     { | ||||||
|         // mock stuff |         // mock stuff | ||||||
|         $accountRepos = $this->mock(AccountRepositoryInterface::class); |  | ||||||
|         $tasker       = $this->mock(AccountTaskerInterface::class); |  | ||||||
|         $collector    = $this->mock(JournalCollectorInterface::class); |         $collector    = $this->mock(JournalCollectorInterface::class); | ||||||
|         $journalRepos = $this->mock(JournalRepositoryInterface::class); |         $journalRepos = $this->mock(JournalRepositoryInterface::class); | ||||||
|         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); |         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); | ||||||
| @@ -139,9 +141,10 @@ class JsonControllerTest extends TestCase | |||||||
|  |  | ||||||
|  |  | ||||||
|         $this->be($this->user()); |         $this->be($this->user()); | ||||||
|  |         $currency     = Amount::getDefaultCurrency(); | ||||||
|         $response = $this->get(route('json.box.in')); |         $response = $this->get(route('json.box.in')); | ||||||
|         $response->assertStatus(200); |         $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() |     public function testBoxOut() | ||||||
|     { |     { | ||||||
|         // mock stuff |         // mock stuff | ||||||
|         $accountRepos = $this->mock(AccountRepositoryInterface::class); |  | ||||||
|         $tasker       = $this->mock(AccountTaskerInterface::class); |  | ||||||
|         $collector    = $this->mock(JournalCollectorInterface::class); |         $collector    = $this->mock(JournalCollectorInterface::class); | ||||||
|         $journalRepos = $this->mock(JournalRepositoryInterface::class); |         $journalRepos = $this->mock(JournalRepositoryInterface::class); | ||||||
|         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); |         $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); | ||||||
| @@ -165,9 +167,10 @@ class JsonControllerTest extends TestCase | |||||||
|         $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once(); |         $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once(); | ||||||
|  |  | ||||||
|         $this->be($this->user()); |         $this->be($this->user()); | ||||||
|  |         $currency     = Amount::getDefaultCurrency(); | ||||||
|         $response = $this->get(route('json.box.out')); |         $response = $this->get(route('json.box.out')); | ||||||
|         $response->assertStatus(200); |         $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']); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  * See the LICENSE file for details. |  * See the LICENSE file for details. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| declare(strict_types = 1); | declare(strict_types=1); | ||||||
|  |  | ||||||
| namespace Tests\Feature\Controllers\Transaction; | namespace Tests\Feature\Controllers\Transaction; | ||||||
|  |  | ||||||
| @@ -32,37 +32,6 @@ use Tests\TestCase; | |||||||
|  */ |  */ | ||||||
| class SplitControllerTest extends 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('<ol class="breadcrumb">'); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::edit |      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::edit | ||||||
|      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::__construct |      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::__construct | ||||||
| @@ -104,6 +73,36 @@ class SplitControllerTest extends TestCase | |||||||
|         $response->assertStatus(302); |         $response->assertStatus(302); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @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('<ol class="breadcrumb">'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update |      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::update | ||||||
|      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::arrayFromInput |      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::arrayFromInput | ||||||
| @@ -124,10 +123,11 @@ class SplitControllerTest extends TestCase | |||||||
|             'tags'                           => '', |             'tags'                           => '', | ||||||
|             'transactions'                   => [ |             'transactions'                   => [ | ||||||
|                 [ |                 [ | ||||||
|                     'description'         => 'Split #1', |                     'description'             => 'Split #1', | ||||||
|                     'source_account_name' => 'Job', |                     'source_account_name'     => 'Job', | ||||||
|                     'amount'              => 1591, |                     'transaction_currency_id' => 1, | ||||||
|                     'category'            => '', |                     'amount'                  => 1591, | ||||||
|  |                     'category'                => '', | ||||||
|                 ], |                 ], | ||||||
|             ], |             ], | ||||||
|         ]; |         ]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user