mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
This fixes most of the tests.
This commit is contained in:
parent
3ef84dc1fc
commit
500243b0b3
@ -187,7 +187,7 @@ class Importer
|
|||||||
|
|
||||||
// some debug info:
|
// some debug info:
|
||||||
$journalId = $journal->id;
|
$journalId = $journal->id;
|
||||||
$type = $journal->getTransactionType();
|
$type = $journal->transaction_type_type ?? $journal->transactionType->type;
|
||||||
/** @var Account $asset */
|
/** @var Account $asset */
|
||||||
$asset = $this->importData['asset-account-object'];
|
$asset = $this->importData['asset-account-object'];
|
||||||
/** @var Account $opposing */
|
/** @var Account $opposing */
|
||||||
|
@ -99,7 +99,7 @@ class TransactionController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(TransactionJournal $journal)
|
public function delete(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$what = strtolower($journal->getTransactionType());
|
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
$subTitle = trans('firefly.delete_' . $what, ['description' => $journal->description]);
|
$subTitle = trans('firefly.delete_' . $what, ['description' => $journal->description]);
|
||||||
|
|
||||||
// put previous url in session
|
// put previous url in session
|
||||||
@ -141,6 +141,9 @@ class TransactionController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(ARI $repository, TransactionJournal $journal)
|
public function edit(ARI $repository, TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
|
// get journal again:
|
||||||
|
/** @var TransactionJournal $journal */
|
||||||
|
$journal = TransactionJournal::expanded()->where('transaction_journals.id', $journal->id)->first(TransactionJournal::QUERYFIELDS);
|
||||||
// cannot edit opening balance
|
// cannot edit opening balance
|
||||||
if ($journal->isOpeningBalance()) {
|
if ($journal->isOpeningBalance()) {
|
||||||
throw new FireflyException('Cannot edit this transaction (#' . $journal->id . '). Edit the account instead!');
|
throw new FireflyException('Cannot edit this transaction (#' . $journal->id . '). Edit the account instead!');
|
||||||
@ -150,7 +153,7 @@ class TransactionController extends Controller
|
|||||||
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
|
$maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize'));
|
||||||
$maxPostSize = Steam::phpBytes(ini_get('post_max_size'));
|
$maxPostSize = Steam::phpBytes(ini_get('post_max_size'));
|
||||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||||
$what = strtolower($journal->getTransactionType());
|
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
|
||||||
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
|
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
|
||||||
$budgets[0] = trans('form.noBudget');
|
$budgets[0] = trans('form.noBudget');
|
||||||
@ -183,15 +186,19 @@ class TransactionController extends Controller
|
|||||||
$preFilled['amount'] = $journal->amount_positive;
|
$preFilled['amount'] = $journal->amount_positive;
|
||||||
|
|
||||||
if ($journal->isWithdrawal()) {
|
if ($journal->isWithdrawal()) {
|
||||||
$preFilled['account_id'] = $journal->source_account->id;
|
$preFilled['account_id'] = $journal->source_account_id;
|
||||||
$preFilled['expense_account'] = $journal->destination_account->name_for_editform;
|
if ($journal->destination_account_type != 'Cash account') {
|
||||||
|
$preFilled['expense_account'] = $journal->destination_account_name;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$preFilled['account_id'] = $journal->destination_account->id;
|
$preFilled['account_id'] = $journal->destination_account_id;
|
||||||
$preFilled['revenue_account'] = $journal->source_account->name_for_editform;
|
if ($journal->source_account_type != 'Cash account') {
|
||||||
|
$preFilled['revenue_account'] = $journal->source_account_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$preFilled['account_from_id'] = $journal->source_account->id;
|
$preFilled['account_from_id'] = $journal->source_account_id;
|
||||||
$preFilled['account_to_id'] = $journal->destination_account->id;
|
$preFilled['account_to_id'] = $journal->destination_account_id;
|
||||||
|
|
||||||
Session::flash('preFilled', $preFilled);
|
Session::flash('preFilled', $preFilled);
|
||||||
Session::flash('gaEventCategory', 'transactions');
|
Session::flash('gaEventCategory', 'transactions');
|
||||||
@ -279,8 +286,8 @@ class TransactionController extends Controller
|
|||||||
$t->after = bcadd($t->before, $t->amount);
|
$t->after = bcadd($t->before, $t->amount);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$what = strtolower($journal->getTransactionType());
|
$what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||||
$subTitle = trans('firefly.' . $journal->getTransactionType()) . ' "' . e($journal->description) . '"';
|
$subTitle = trans('firefly.' . $journal->transaction_type_type ?? $journal->transactionType->type) . ' "' . e($journal->description) . '"';
|
||||||
|
|
||||||
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what'));
|
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what'));
|
||||||
}
|
}
|
||||||
@ -314,7 +321,6 @@ class TransactionController extends Controller
|
|||||||
if (count($att->getMessages()->get('attachments')) > 0) {
|
if (count($att->getMessages()->get('attachments')) > 0) {
|
||||||
Session::flash('info', $att->getMessages()->get('attachments'));
|
Session::flash('info', $att->getMessages()->get('attachments'));
|
||||||
}
|
}
|
||||||
Log::debug('Before event. From account name is: ' . $journal->source_account->name);
|
|
||||||
|
|
||||||
event(new TransactionJournalStored($journal, intval($request->get('piggy_bank_id'))));
|
event(new TransactionJournalStored($journal, intval($request->get('piggy_bank_id'))));
|
||||||
|
|
||||||
|
@ -44,6 +44,19 @@ use Watson\Validating\ValidatingTrait;
|
|||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal after($date)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal after($date)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal before($date)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal before($date)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal transactionTypes($types)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\TransactionJournal transactionTypes($types)
|
||||||
|
*
|
||||||
|
* @property-read string $transaction_type_type
|
||||||
|
* @property-read string $transaction_currency_code
|
||||||
|
* @property-read string $destination_amount
|
||||||
|
* @property-read string $destination_account_id
|
||||||
|
* @property-read string $destination_account_name
|
||||||
|
* @property-read string $destination_account_type
|
||||||
|
* @property-read string $source_amount
|
||||||
|
* @property-read string $source_account_id
|
||||||
|
* @property-read string $source_account_name
|
||||||
|
* @property-read string $source_account_type
|
||||||
|
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class TransactionJournal extends BaseModel
|
class TransactionJournal extends BaseModel
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,8 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
|
|||||||
*/
|
*/
|
||||||
public function triggered(TransactionJournal $journal)
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$fromAccountName = strtolower($journal->source_account->name);
|
$sourceAccount = $journal->transactions()->where('amount', '<', 0)->first()->account;
|
||||||
|
$fromAccountName = strtolower($sourceAccount->name);
|
||||||
$search = strtolower($this->triggerValue);
|
$search = strtolower($this->triggerValue);
|
||||||
|
|
||||||
if ($fromAccountName == $search) {
|
if ($fromAccountName == $search) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="false">
|
stopOnFailure="true">
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Application Test Suite">
|
<testsuite name="Application Test Suite">
|
||||||
<directory>./tests/</directory>
|
<directory>./tests/</directory>
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
* of the MIT license. See the LICENSE file for details.
|
* of the MIT license. See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
||||||
|
use FireflyIII\Helpers\Collection\Balance;
|
||||||
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
use FireflyIII\Helpers\Collection\Bill as BillCollection;
|
||||||
|
use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
|
||||||
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
use FireflyIII\Helpers\Collection\Category as CategoryCollection;
|
||||||
use FireflyIII\Helpers\Collection\Expense;
|
use FireflyIII\Helpers\Collection\Expense;
|
||||||
use FireflyIII\Helpers\Collection\Income;
|
use FireflyIII\Helpers\Collection\Income;
|
||||||
use FireflyIII\Helpers\Collection\Account as AccountCollection;
|
use Illuminate\Support\Collection;
|
||||||
use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
|
|
||||||
use FireflyIII\Helpers\Collection\Balance;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
|
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:28.
|
||||||
@ -48,12 +49,11 @@ class ReportControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock some stuff.
|
// mock some stuff.
|
||||||
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
|
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
|
||||||
$budgetHelper = $this->mock('FireflyIII\Helpers\Report\BudgetReportHelperInterface');
|
$budgetHelper = $this->mock('FireflyIII\Helpers\Report\BudgetReportHelperInterface');
|
||||||
$balanceHelper = $this->mock('FireflyIII\Helpers\Report\BalanceReportHelperInterface');
|
$balanceHelper = $this->mock('FireflyIII\Helpers\Report\BalanceReportHelperInterface');
|
||||||
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
|
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
|
||||||
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
|
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
|
||||||
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
|
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
|
||||||
@ -79,6 +79,22 @@ class ReportControllerTest extends TestCase
|
|||||||
public function testReportDefaultMultiYear($range)
|
public function testReportDefaultMultiYear($range)
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
|
||||||
|
// mock some stuff.
|
||||||
|
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
|
||||||
|
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||||
|
$budgetRepos = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||||
|
$categoryRepos = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||||
|
|
||||||
|
$budgetRepos->shouldReceive('getActiveBudgets')->once()->andReturn(new Collection);
|
||||||
|
$categoryRepos->shouldReceive('listCategories')->once()->andReturn(new Collection);
|
||||||
|
|
||||||
|
|
||||||
|
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
|
||||||
|
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
|
||||||
|
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
|
||||||
|
$defaultHelper->shouldReceive('tagReport')->once()->andReturn([]);
|
||||||
|
|
||||||
$this->changeDateRange($this->user(), $range);
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/reports/report/default/20160101/20171231/1,2');
|
$this->call('GET', '/reports/report/default/20160101/20171231/1,2');
|
||||||
$this->assertResponseStatus(200);
|
$this->assertResponseStatus(200);
|
||||||
@ -93,6 +109,18 @@ class ReportControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testReportDefaultYear($range)
|
public function testReportDefaultYear($range)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// mock some stuff.
|
||||||
|
$accountHelper = $this->mock('FireflyIII\Helpers\Report\AccountReportHelperInterface');
|
||||||
|
$defaultHelper = $this->mock('FireflyIII\Helpers\Report\ReportHelperInterface');
|
||||||
|
|
||||||
|
|
||||||
|
$accountHelper->shouldReceive('getAccountReport')->once()->andReturn(new AccountCollection);
|
||||||
|
$defaultHelper->shouldReceive('getIncomeReport')->once()->andReturn(new Income);
|
||||||
|
$defaultHelper->shouldReceive('getExpenseReport')->once()->andReturn(new Expense);
|
||||||
|
$defaultHelper->shouldReceive('tagReport')->once()->andReturn([]);
|
||||||
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$this->changeDateRange($this->user(), $range);
|
$this->changeDateRange($this->user(), $range);
|
||||||
$this->call('GET', '/reports/report/default/20160101/20161231/1,2');
|
$this->call('GET', '/reports/report/default/20160101/20161231/1,2');
|
||||||
|
Loading…
Reference in New Issue
Block a user