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:
		| @@ -236,6 +236,12 @@ $factory->define( | ||||
|         '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, | ||||
|     ]; | ||||
| } | ||||
| ); | ||||
| @@ -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']); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -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('<ol class="breadcrumb">'); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::edit | ||||
|      * @covers \FireflyIII\Http\Controllers\Transaction\SplitController::__construct | ||||
| @@ -104,6 +73,36 @@ class SplitControllerTest extends TestCase | ||||
|         $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::arrayFromInput | ||||
| @@ -126,6 +125,7 @@ class SplitControllerTest extends TestCase | ||||
|                 [ | ||||
|                     'description'             => 'Split #1', | ||||
|                     'source_account_name'     => 'Job', | ||||
|                     'transaction_currency_id' => 1, | ||||
|                     'amount'                  => 1591, | ||||
|                     'category'                => '', | ||||
|                 ], | ||||
|   | ||||
		Reference in New Issue
	
	Block a user