mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Fix tests
This commit is contained in:
@@ -87,7 +87,6 @@ class BillRequest extends Request
|
|||||||
case 'PATCH':
|
case 'PATCH':
|
||||||
$bill = $this->route()->parameter('bill');
|
$bill = $this->route()->parameter('bill');
|
||||||
$rules['name'] .= ',' . $bill->id;
|
$rules['name'] .= ',' . $bill->id;
|
||||||
$rules['match'] .= ',' . $bill->id;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -303,7 +303,7 @@ class RuleController extends Controller
|
|||||||
{
|
{
|
||||||
$ids = $request->get('actions');
|
$ids = $request->get('actions');
|
||||||
if (\is_array($ids)) {
|
if (\is_array($ids)) {
|
||||||
$this->ruleGroupRepos->reorderRuleActions($rule, $ids);
|
$this->ruleRepos->reorderRuleActions($rule, $ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json('true');
|
return response()->json('true');
|
||||||
@@ -320,7 +320,7 @@ class RuleController extends Controller
|
|||||||
{
|
{
|
||||||
$ids = $request->get('triggers');
|
$ids = $request->get('triggers');
|
||||||
if (\is_array($ids)) {
|
if (\is_array($ids)) {
|
||||||
$this->ruleGroupRepos->reorderRuleTriggers($rule, $ids);
|
$this->ruleRepos->reorderRuleTriggers($rule, $ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json('true');
|
return response()->json('true');
|
||||||
|
@@ -39,6 +39,7 @@ use Illuminate\Support\Collection;
|
|||||||
use Preferences;
|
use Preferences;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
use View;
|
use View;
|
||||||
|
use Illuminate\View\View as IlluminateView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class MassController.
|
* Class MassController.
|
||||||
@@ -69,9 +70,9 @@ class MassController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @param Collection $journals
|
* @param Collection $journals
|
||||||
*
|
*
|
||||||
* @return View
|
* @return IlluminateView
|
||||||
*/
|
*/
|
||||||
public function delete(Collection $journals): View
|
public function delete(Collection $journals): IlluminateView
|
||||||
{
|
{
|
||||||
$subTitle = trans('firefly.mass_delete_journals');
|
$subTitle = trans('firefly.mass_delete_journals');
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ class MassController extends Controller
|
|||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function edit(Collection $journals)
|
public function edit(Collection $journals): IlluminateView
|
||||||
{
|
{
|
||||||
$subTitle = trans('firefly.mass_edit_journals');
|
$subTitle = trans('firefly.mass_edit_journals');
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ class AccountUpdateService
|
|||||||
$account->iban = $data['iban'];
|
$account->iban = $data['iban'];
|
||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
if($data['currency_id'] === 0) {
|
if(isset($data['currency_id']) && $data['currency_id'] === 0) {
|
||||||
unset($data['currency_id']);
|
unset($data['currency_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -153,7 +153,7 @@ class AccountTransformer extends TransformerAbstract
|
|||||||
}
|
}
|
||||||
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
|
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
|
||||||
$currencyCode = null;
|
$currencyCode = null;
|
||||||
$currencySymbol = null;
|
$currencySymbol = 'x';
|
||||||
$decimalPlaces = 2;
|
$decimalPlaces = 2;
|
||||||
if ($currencyId > 0) {
|
if ($currencyId > 0) {
|
||||||
$currency = TransactionCurrency::find($currencyId);
|
$currency = TransactionCurrency::find($currencyId);
|
||||||
|
@@ -36,21 +36,23 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
bcscale(12);
|
bcscale(12);
|
||||||
|
|
||||||
/**
|
if (!function_exists('envNonEmpty')) {
|
||||||
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param null $default
|
* @param null $default
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
function envNonEmpty(string $key, $default = null)
|
function envNonEmpty(string $key, $default = null)
|
||||||
{
|
{
|
||||||
$result = env($key, $default);
|
$result = env($key, $default);
|
||||||
if (is_string($result) && $result === '') {
|
if (is_string($result) && $result === '') {
|
||||||
$result = $default;
|
$result = $default;
|
||||||
}
|
}
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$app = new Illuminate\Foundation\Application(
|
$app = new Illuminate\Foundation\Application(
|
||||||
realpath(__DIR__ . '/../')
|
realpath(__DIR__ . '/../')
|
||||||
|
@@ -152,10 +152,12 @@ $factory->define(
|
|||||||
function (Faker\Generator $faker) {
|
function (Faker\Generator $faker) {
|
||||||
return [
|
return [
|
||||||
'id' => $faker->unique()->numberBetween(100, 10000),
|
'id' => $faker->unique()->numberBetween(100, 10000),
|
||||||
|
'created_at' => new Carbon,
|
||||||
|
'updated_at' => new Carbon,
|
||||||
'account_id' => $faker->numberBetween(1, 10),
|
'account_id' => $faker->numberBetween(1, 10),
|
||||||
'name' => $faker->words(3, true),
|
'name' => $faker->words(3, true),
|
||||||
'target_amount' => '1000.00',
|
'target_amount' => '1000.00',
|
||||||
'startdate' => '2017-01-01',
|
'startdate' => new Carbon('2017-01-01'),
|
||||||
'order' => 1,
|
'order' => 1,
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
'encrypted' => 0,
|
'encrypted' => 0,
|
||||||
|
@@ -8,6 +8,9 @@
|
|||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="true">
|
stopOnFailure="true">
|
||||||
|
<listeners>
|
||||||
|
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||||
|
</listeners>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Feature">
|
<testsuite name="Feature">
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
<directory suffix="Test.php">./tests/Feature</directory>
|
||||||
|
@@ -8,6 +8,9 @@
|
|||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="true">
|
stopOnFailure="true">
|
||||||
|
<listeners>
|
||||||
|
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||||
|
</listeners>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Feature">
|
<testsuite name="Feature">
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
<directory suffix="Test.php">./tests/Feature</directory>
|
||||||
|
@@ -8,6 +8,9 @@
|
|||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="true">
|
stopOnFailure="true">
|
||||||
|
<listeners>
|
||||||
|
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||||
|
</listeners>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Feature">
|
<testsuite name="Feature">
|
||||||
<directory suffix="Test.php">./tests/Feature</directory>
|
<directory suffix="Test.php">./tests/Feature</directory>
|
||||||
|
@@ -144,6 +144,7 @@ class BillControllerTest extends TestCase
|
|||||||
'amount_min' => '66.34',
|
'amount_min' => '66.34',
|
||||||
'amount_max' => '45.67',
|
'amount_max' => '45.67',
|
||||||
'date' => '2018-01-01',
|
'date' => '2018-01-01',
|
||||||
|
'currency_id' => 1,
|
||||||
'repeat_freq' => 'monthly',
|
'repeat_freq' => 'monthly',
|
||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
'automatch' => 1,
|
'automatch' => 1,
|
||||||
@@ -192,6 +193,7 @@ class BillControllerTest extends TestCase
|
|||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
'automatch' => 1,
|
'automatch' => 1,
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
|
'currency_id' => 1,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -230,7 +232,7 @@ class BillControllerTest extends TestCase
|
|||||||
'skip' => 0,
|
'skip' => 0,
|
||||||
'automatch' => 1,
|
'automatch' => 1,
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
|
'currency_id' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
// test API
|
// test API
|
||||||
|
@@ -97,9 +97,17 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$response = $this->get('/api/v1/currencies');
|
$response = $this->get('/api/v1/currencies');
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$response->assertJson(['data' => [],]);
|
$response->assertJson(['data' => [],]);
|
||||||
$response->assertJson(
|
$response->assertJson([
|
||||||
['meta' => ['pagination' => ['total' => $collection->count(), 'count' => $collection->count(), 'per_page' => 50, 'current_page' => 1,
|
'meta' => [
|
||||||
'total_pages' => 1]],]
|
'pagination' => [
|
||||||
|
'total' => $collection->count(),
|
||||||
|
'count' => $collection->count(),
|
||||||
|
'per_page' => 100,
|
||||||
|
'current_page' => 1,
|
||||||
|
'total_pages' => 1,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]
|
||||||
);
|
);
|
||||||
$response->assertJson(
|
$response->assertJson(
|
||||||
['links' => ['self' => true, 'first' => true, 'last' => true,],]
|
['links' => ['self' => true, 'first' => true, 'last' => true,],]
|
||||||
|
@@ -341,7 +341,7 @@ class TransactionControllerTest extends TestCase
|
|||||||
$journalRepos->shouldReceive('setUser')->once();
|
$journalRepos->shouldReceive('setUser')->once();
|
||||||
$accountRepos->shouldReceive('setUser');
|
$accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection);
|
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection);
|
||||||
$accountRepos->shouldReceive('findByNameNull')->andReturn(null);
|
$accountRepos->shouldReceive('findByName')->andReturn(null);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'description' => 'Some transaction #' . random_int(1, 1000),
|
'description' => 'Some transaction #' . random_int(1, 1000),
|
||||||
@@ -1661,7 +1661,7 @@ class TransactionControllerTest extends TestCase
|
|||||||
$journalRepos->shouldReceive('setUser')->once();
|
$journalRepos->shouldReceive('setUser')->once();
|
||||||
$accountRepos->shouldReceive('setUser');
|
$accountRepos->shouldReceive('setUser');
|
||||||
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection);
|
$accountRepos->shouldReceive('getAccountsById')->andReturn(new Collection);
|
||||||
$accountRepos->shouldReceive('findByNameNull')->andReturn($account);
|
$accountRepos->shouldReceive('findByName')->andReturn($account);
|
||||||
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
|
$journalRepos->shouldReceive('store')->andReturn($journal)->once();
|
||||||
|
|
||||||
|
|
||||||
|
@@ -182,6 +182,8 @@ class AccountControllerTest extends TestCase
|
|||||||
Steam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']);
|
Steam::shouldReceive('balancesByAccounts')->andReturn([$account->id => '100']);
|
||||||
Steam::shouldReceive('getLastActivities')->andReturn([]);
|
Steam::shouldReceive('getLastActivities')->andReturn([]);
|
||||||
|
|
||||||
|
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'accountNumber'])->andReturn('123');
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$this->changeDateRange($this->user(), $range);
|
$this->changeDateRange($this->user(), $range);
|
||||||
$response = $this->get(route('accounts.index', ['asset']));
|
$response = $this->get(route('accounts.index', ['asset']));
|
||||||
|
@@ -66,6 +66,8 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
|
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
|
||||||
|
$piggyRepos->shouldReceive('leftOnAccount')->andReturn('0');
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('piggy-banks.add', [1]));
|
$response = $this->get(route('piggy-banks.add', [1]));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
@@ -81,6 +83,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
|
$piggyRepos->shouldReceive('getCurrentAmount')->andReturn('0');
|
||||||
|
$piggyRepos->shouldReceive('leftOnAccount')->andReturn('0');
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('piggy-banks.add-money-mobile', [1]));
|
$response = $this->get(route('piggy-banks.add-money-mobile', [1]));
|
||||||
@@ -200,8 +203,9 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getPiggyBanks')->andReturn(new Collection([$one, $two]));
|
$repository->shouldReceive('getPiggyBanks')->andReturn(new Collection([$one, $two]));
|
||||||
$repository->shouldReceive('getCurrentAmount')->andReturn('10');
|
$repository->shouldReceive('getCurrentAmount')->andReturn('10');
|
||||||
|
$repository->shouldReceive('setUser');
|
||||||
|
|
||||||
Steam::shouldReceive('balanceIgnoreVirtual')->twice()->andReturn('1');
|
Steam::shouldReceive('balance')->twice()->andReturn('1');
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('piggy-banks.index'));
|
$response = $this->get(route('piggy-banks.index'));
|
||||||
|
@@ -86,16 +86,16 @@ class BulkControllerTest extends TestCase
|
|||||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
||||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection, new Collection([1]));
|
||||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
||||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection, new Collection([1]));
|
||||||
$journalRepos->shouldReceive('getTransactionType')
|
$journalRepos->shouldReceive('getTransactionType')
|
||||||
->andReturn('Withdrawal', 'Opening balance');
|
->andReturn('Withdrawal', 'Opening balance', 'Withdrawal', 'Withdrawal', 'Withdrawal');
|
||||||
$journalRepos->shouldReceive('isJournalReconciled')
|
$journalRepos->shouldReceive('isJournalReconciled')
|
||||||
->andReturn(true, false);
|
->andReturn(true, false, false, false, false);
|
||||||
|
|
||||||
// default transactions
|
// default transactions
|
||||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
$collection = $this->user()->transactionJournals()->take(5)->get();
|
||||||
$allIds = $collection->pluck('id')->toArray();
|
$allIds = $collection->pluck('id')->toArray();
|
||||||
$route = route('transactions.bulk.edit', implode(',', $allIds));
|
$route = route('transactions.bulk.edit', implode(',', $allIds));
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -110,43 +110,6 @@ class BulkControllerTest extends TestCase
|
|||||||
$response->assertSee('multiple destination accounts');
|
$response->assertSee('multiple destination accounts');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
|
|
||||||
*/
|
|
||||||
public function testEditMultipleNothingLeft()
|
|
||||||
{
|
|
||||||
// mock stuff:
|
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
|
||||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
|
||||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
|
||||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
|
||||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
|
||||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
|
||||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
|
||||||
$journalRepos->shouldReceive('getTransactionType')
|
|
||||||
->andReturn('Withdrawal', 'Opening balance');
|
|
||||||
$journalRepos->shouldReceive('isJournalReconciled')
|
|
||||||
->andReturn(true, true);
|
|
||||||
|
|
||||||
|
|
||||||
// default transactions
|
|
||||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
|
||||||
$allIds = $collection->pluck('id')->toArray();
|
|
||||||
$route = route('transactions.bulk.edit', implode(',', $allIds));
|
|
||||||
$this->be($this->user());
|
|
||||||
$response = $this->get($route);
|
|
||||||
$response->assertStatus(200);
|
|
||||||
$response->assertSee('Bulk edit a number of transactions');
|
|
||||||
$response->assertSessionHas('info');
|
|
||||||
// has bread crumb
|
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
|
||||||
$response->assertSessionHas('error', 'You have selected no valid transactions to edit.');
|
|
||||||
$response->assertSee('marked as reconciled');
|
|
||||||
$response->assertSee('multiple source accounts');
|
|
||||||
$response->assertSee('multiple destination accounts');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
|
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
|
||||||
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
|
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
|
||||||
@@ -166,7 +129,7 @@ class BulkControllerTest extends TestCase
|
|||||||
|
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('find')->times(4)->andReturn(new TransactionJournal);
|
$repository->shouldReceive('findNull')->times(4)->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$repository->shouldReceive('updateCategory')->times(4)->andReturn(new TransactionJournal())
|
$repository->shouldReceive('updateCategory')->times(4)->andReturn(new TransactionJournal())
|
||||||
->withArgs([Mockery::any(), $data['category']]);
|
->withArgs([Mockery::any(), $data['category']]);
|
||||||
|
@@ -81,7 +81,7 @@ class MassControllerTest extends TestCase
|
|||||||
// mock deletion:
|
// mock deletion:
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('find')->andReturnValues([$deposits[0], $deposits[1]])->times(2);
|
$repository->shouldReceive('findNull')->andReturnValues([$deposits[0], $deposits[1]])->times(2);
|
||||||
$repository->shouldReceive('destroy')->times(2);
|
$repository->shouldReceive('destroy')->times(2);
|
||||||
|
|
||||||
$this->session(['transactions.mass-delete.uri' => 'http://localhost']);
|
$this->session(['transactions.mass-delete.uri' => 'http://localhost']);
|
||||||
@@ -150,17 +150,17 @@ class MassControllerTest extends TestCase
|
|||||||
|
|
||||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
||||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection, new Collection([1]));
|
||||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
||||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection, new Collection([1]));
|
||||||
$journalRepos->shouldReceive('getTransactionType')
|
$journalRepos->shouldReceive('getTransactionType')
|
||||||
->andReturn('Withdrawal', 'Opening balance');
|
->andReturn('Withdrawal', 'Opening balance', 'Withdrawal', 'Withdrawal', 'Withdrawal');
|
||||||
$journalRepos->shouldReceive('isJournalReconciled')
|
$journalRepos->shouldReceive('isJournalReconciled')
|
||||||
->andReturn(true, false);
|
->andReturn(true, false, false, false, false);
|
||||||
|
|
||||||
|
|
||||||
// default transactions
|
// default transactions
|
||||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
$collection = $this->user()->transactionJournals()->take(5)->get();
|
||||||
$allIds = $collection->pluck('id')->toArray();
|
$allIds = $collection->pluck('id')->toArray();
|
||||||
$route = route('transactions.mass.edit', implode(',', $allIds));
|
$route = route('transactions.mass.edit', implode(',', $allIds));
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@@ -174,43 +174,6 @@ class MassControllerTest extends TestCase
|
|||||||
$response->assertSee('multiple destination accounts');
|
$response->assertSee('multiple destination accounts');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::edit
|
|
||||||
*/
|
|
||||||
public function testEditMultipleNothingLeft()
|
|
||||||
{
|
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
|
||||||
$budgetRepos->shouldReceive('getBudgets')->andReturn(new Collection);
|
|
||||||
|
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
|
||||||
|
|
||||||
|
|
||||||
// mock stuff:
|
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
|
||||||
|
|
||||||
$journalRepos->shouldReceive('getJournalSourceAccounts')
|
|
||||||
->andReturn(new Collection([1, 2, 3]), new Collection, new Collection, new Collection);
|
|
||||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')
|
|
||||||
->andReturn(new Collection, new Collection([1, 2, 3]), new Collection, new Collection);
|
|
||||||
$journalRepos->shouldReceive('getTransactionType')
|
|
||||||
->andReturn('Withdrawal', 'Opening balance');
|
|
||||||
$journalRepos->shouldReceive('isJournalReconciled')
|
|
||||||
->andReturn(true, true);
|
|
||||||
|
|
||||||
// default transactions
|
|
||||||
$collection = $this->user()->transactionJournals()->take(4)->get();
|
|
||||||
$allIds = $collection->pluck('id')->toArray();
|
|
||||||
|
|
||||||
$this->be($this->user());
|
|
||||||
$response = $this->get(route('transactions.mass.edit', implode(',', $allIds)));
|
|
||||||
$response->assertStatus(200);
|
|
||||||
$response->assertSee('Edit a number of transactions');
|
|
||||||
$response->assertSessionHas('error', 'You have selected no valid transactions to edit.');
|
|
||||||
// has bread crumb
|
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::update
|
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::update
|
||||||
|
@@ -209,6 +209,8 @@ class SingleControllerTest extends TestCase
|
|||||||
|
|
||||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||||
$journalRepos->shouldReceive('destroy')->once();
|
$journalRepos->shouldReceive('destroy')->once();
|
||||||
|
$journalRepos->shouldReceive('getTransactionType')->once()->andReturn('Withdrawal');
|
||||||
|
|
||||||
|
|
||||||
$this->session(['transactions.delete.uri' => 'http://localhost']);
|
$this->session(['transactions.delete.uri' => 'http://localhost']);
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@@ -73,6 +73,7 @@ class HasAnyCategoryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredTransactions()
|
public function testTriggeredTransactions()
|
||||||
{
|
{
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
$category = $journal->user->categories()->first();
|
$category = $journal->user->categories()->first();
|
||||||
$journal->categories()->detach();
|
$journal->categories()->detach();
|
||||||
@@ -81,6 +82,7 @@ class HasAnyCategoryTest extends TestCase
|
|||||||
// append to transaction, not to journal.
|
// append to transaction, not to journal.
|
||||||
foreach ($journal->transactions()->get() as $index => $transaction) {
|
foreach ($journal->transactions()->get() as $index => $transaction) {
|
||||||
$transaction->categories()->sync([$category->id]);
|
$transaction->categories()->sync([$category->id]);
|
||||||
|
$this->assertEquals(1, $transaction->categories()->count());
|
||||||
}
|
}
|
||||||
$this->assertEquals(0, $journal->categories()->count());
|
$this->assertEquals(0, $journal->categories()->count());
|
||||||
|
|
||||||
|
@@ -72,9 +72,13 @@ class ToAccountEndsTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTriggeredNot()
|
public function testTriggeredNot()
|
||||||
{
|
{
|
||||||
|
$count = 0;
|
||||||
|
while ($count === 0) {
|
||||||
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
|
||||||
|
$count = $journal->transactions()->where('amount', '>', 0)->count();
|
||||||
|
}
|
||||||
|
|
||||||
$trigger = ToAccountEnds::makeFromStrings((string)random_int(1, 234), false);
|
$trigger = ToAccountEnds::makeFromStrings((string)random_int(1, 1234), false);
|
||||||
$result = $trigger->triggered($journal);
|
$result = $trigger->triggered($journal);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user