mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
These changes fix the tests.
This commit is contained in:
parent
f72f8b03df
commit
1dec270907
@ -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'] = '';
|
||||
|
@ -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,
|
||||
];
|
||||
}
|
||||
);
|
@ -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']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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('<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
|
||||
@ -124,10 +123,11 @@ class SplitControllerTest extends TestCase
|
||||
'tags' => '',
|
||||
'transactions' => [
|
||||
[
|
||||
'description' => 'Split #1',
|
||||
'source_account_name' => 'Job',
|
||||
'amount' => 1591,
|
||||
'category' => '',
|
||||
'description' => 'Split #1',
|
||||
'source_account_name' => 'Job',
|
||||
'transaction_currency_id' => 1,
|
||||
'amount' => 1591,
|
||||
'category' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user