Files
firefly-iii/tests/Feature/Controllers/TransactionControllerTest.php

488 lines
23 KiB
PHP
Raw Normal View History

2017-02-12 12:00:11 +01:00
<?php
/**
* TransactionControllerTest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
2017-10-21 08:40:00 +02:00
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 14:42:21 +01:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2017-02-12 12:00:11 +01:00
*/
2017-03-24 15:01:53 +01:00
declare(strict_types=1);
2017-02-12 12:00:11 +01:00
namespace Tests\Feature\Controllers;
2017-03-24 15:01:53 +01:00
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
2017-04-28 20:17:10 +02:00
use FireflyIII\Helpers\Filter\InternalTransferFilter;
2019-06-23 10:40:46 +02:00
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
2018-12-18 06:57:42 +01:00
use FireflyIII\Models\Attachment;
2017-12-17 14:30:53 +01:00
use FireflyIII\Models\Transaction;
2017-03-05 18:15:38 +01:00
use FireflyIII\Models\TransactionJournal;
2018-11-11 08:34:38 +01:00
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
2017-03-05 18:15:38 +01:00
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
2018-02-28 20:18:47 +01:00
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
2018-12-17 07:09:44 +01:00
use FireflyIII\Transformers\TransactionTransformer;
2017-03-05 18:15:38 +01:00
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
2018-03-24 06:08:50 +01:00
use Log;
use Mockery;
2017-02-12 12:00:11 +01:00
use Tests\TestCase;
2017-08-12 10:27:45 +02:00
/**
* Class TransactionControllerTest
*
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
2017-02-12 12:00:11 +01:00
class TransactionControllerTest extends TestCase
{
2018-03-24 06:08:50 +01:00
/**
*
*/
2018-09-02 20:27:26 +02:00
public function setUp(): void
2018-03-24 06:08:50 +01:00
{
parent::setUp();
2019-04-09 20:05:20 +02:00
Log::info(sprintf('Now in %s.', get_class($this)));
2018-03-24 06:08:50 +01:00
}
2017-12-17 14:30:53 +01:00
2017-02-12 12:21:44 +01:00
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-02-12 12:21:44 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testIndex(): void
2017-02-12 12:21:44 +01:00
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2018-03-28 19:38:20 +02:00
$date = new Carbon;
$this->session(['start' => $date, 'end' => clone $date]);
2017-03-05 18:15:38 +01:00
// mock stuff
2018-12-17 07:09:44 +01:00
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
2017-03-05 18:15:38 +01:00
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
2017-03-05 18:15:38 +01:00
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
2018-03-28 19:38:20 +02:00
$collector->shouldReceive('addFilter')->andReturnSelf();
2017-03-05 18:15:38 +01:00
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
2017-04-28 20:17:10 +02:00
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('getTransactions')->andReturn(new Collection);
2017-02-12 12:21:44 +01:00
$this->be($this->user());
$response = $this->get(route('transactions.index', ['transfer']));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-02-12 12:21:44 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testIndexAll(): void
2017-02-12 12:21:44 +01:00
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2018-03-28 19:38:20 +02:00
$date = new Carbon;
$this->session(['start' => $date, 'end' => clone $date]);
2017-03-05 18:15:38 +01:00
// mock stuff
2018-12-17 07:09:44 +01:00
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
2017-03-05 18:15:38 +01:00
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
2017-03-05 18:15:38 +01:00
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
2018-03-28 19:38:20 +02:00
$collector->shouldReceive('addFilter')->andReturnSelf();
2017-03-05 18:15:38 +01:00
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
2017-04-28 20:17:10 +02:00
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('getTransactions')->andReturn(new Collection);
2017-03-05 18:15:38 +01:00
2017-02-12 12:21:44 +01:00
$this->be($this->user());
2018-03-28 19:38:20 +02:00
$response = $this->get(route('transactions.index.all', ['transfer']));
2017-02-12 12:21:44 +01:00
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-02-12 12:21:44 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testIndexByDate(): void
2017-02-12 12:21:44 +01:00
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2017-12-17 14:30:53 +01:00
$transaction = new Transaction;
$transaction->transaction_currency_id = 1;
$transaction->transaction_currency_symbol = 'x';
$transaction->transaction_currency_code = 'ABC';
$transaction->transaction_currency_dp = 2;
$transaction->transaction_amount = '5';
$collection = new Collection([$transaction]);
2017-03-05 18:15:38 +01:00
// mock stuff
2018-12-17 07:09:44 +01:00
$transfer = $this->getRandomTransfer();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
2018-12-12 20:30:25 +01:00
2018-12-17 07:09:44 +01:00
$date = new Carbon;
2018-12-12 20:30:25 +01:00
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
2018-04-02 15:40:43 +02:00
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
2017-03-05 18:15:38 +01:00
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
2018-03-28 19:38:20 +02:00
$collector->shouldReceive('addFilter')->andReturnSelf();
2017-03-05 18:15:38 +01:00
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
2017-04-28 20:17:10 +02:00
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('getTransactions')->andReturn($collection);
2017-03-11 07:41:26 +01:00
2017-02-12 12:21:44 +01:00
$this->be($this->user());
2017-03-11 07:41:26 +01:00
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01']));
2017-02-12 12:21:44 +01:00
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
2017-03-24 15:01:53 +01:00
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
*/
public function testIndexByDateReversed(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2018-06-01 22:04:52 +02:00
$transaction = new Transaction;
$transaction->transaction_currency_id = 1;
$transaction->transaction_currency_symbol = 'x';
$transaction->transaction_currency_code = 'ABC';
$transaction->transaction_currency_dp = 2;
$transaction->transaction_amount = '5';
$collection = new Collection([$transaction]);
// mock stuff
2018-12-17 07:09:44 +01:00
$transfer = $this->getRandomTransfer();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
2018-06-01 22:04:52 +02:00
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
2018-12-17 07:09:44 +01:00
$date = new Carbon;
2018-12-12 20:30:25 +01:00
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
2018-06-01 22:04:52 +02:00
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('addFilter')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('getTransactions')->andReturn($collection);
2018-06-01 22:04:52 +02:00
$this->be($this->user());
2018-08-06 19:14:30 +02:00
$response = $this->get(route('transactions.index', ['transfer', '2016-01-01', '2015-12-31']));
2018-06-01 22:04:52 +02:00
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-03-24 15:01:53 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testIndexDeposit(): void
2017-03-24 15:01:53 +01:00
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2017-12-17 14:30:53 +01:00
$transaction = new Transaction;
$transaction->transaction_currency_id = 1;
$transaction->transaction_currency_symbol = 'x';
$transaction->transaction_currency_code = 'ABC';
$transaction->transaction_currency_dp = 2;
$transaction->transaction_amount = '5';
$collection = new Collection([$transaction]);
2017-03-24 15:01:53 +01:00
// mock stuff
2018-12-17 07:09:44 +01:00
$transfer = $this->getRandomTransfer();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
2018-04-02 15:40:43 +02:00
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
2017-03-24 15:01:53 +01:00
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
2018-03-28 19:38:20 +02:00
$collector->shouldReceive('addFilter')->andReturnSelf();
2017-03-24 15:01:53 +01:00
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
2017-04-28 20:17:10 +02:00
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('getTransactions')->andReturn($collection);
2017-03-24 15:01:53 +01:00
$this->be($this->user());
$response = $this->get(route('transactions.index', ['deposit']));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-03-24 15:01:53 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testIndexWithdrawal(): void
2017-03-24 15:01:53 +01:00
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2017-12-17 14:30:53 +01:00
$transaction = new Transaction;
$transaction->transaction_currency_id = 1;
$transaction->transaction_currency_symbol = 'x';
$transaction->transaction_currency_code = 'ABC';
$transaction->transaction_currency_dp = 2;
$transaction->transaction_amount = '5';
$collection = new Collection([$transaction]);
2017-03-24 15:01:53 +01:00
// mock stuff
2018-12-17 07:09:44 +01:00
$transfer = $this->getRandomTransfer();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
2018-04-02 15:40:43 +02:00
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
2017-03-24 15:01:53 +01:00
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setLimit')->andReturnSelf();
$collector->shouldReceive('setPage')->andReturnSelf();
2018-03-28 19:38:20 +02:00
$collector->shouldReceive('addFilter')->andReturnSelf();
2017-03-24 15:01:53 +01:00
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
2017-04-28 20:17:10 +02:00
$collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf();
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
$collector->shouldReceive('getTransactions')->andReturn($collection);
2017-03-24 15:01:53 +01:00
$this->be($this->user());
$response = $this->get(route('transactions.index', ['withdrawal']));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
2017-12-17 14:30:53 +01:00
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-12-17 14:30:53 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testReconcile(): void
2017-12-17 14:30:53 +01:00
{
2019-04-09 20:05:20 +02:00
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2018-12-17 07:09:44 +01:00
$data = ['transactions' => [1, 2]];
$repository = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
2017-12-17 14:30:53 +01:00
$repository->shouldReceive('firstNull')->times(1)->andReturn(new TransactionJournal);
2017-12-17 14:30:53 +01:00
$repository->shouldReceive('findTransaction')->andReturn(new Transaction)->twice();
$repository->shouldReceive('reconcile')->twice();
$this->be($this->user());
$response = $this->post(route('transactions.reconcile'), $data);
$response->assertStatus(200);
}
2017-02-12 12:21:44 +01:00
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-02-12 12:21:44 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testReorder(): void
2017-02-12 12:21:44 +01:00
{
2019-04-09 20:05:20 +02:00
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2017-03-05 18:15:38 +01:00
// mock stuff
2017-03-24 15:01:53 +01:00
$journal = factory(TransactionJournal::class)->make();
$journal->date = new Carbon('2016-01-01');
$repository = $this->mock(JournalRepositoryInterface::class);
2018-11-11 08:34:38 +01:00
$userRepos = $this->mock(UserRepositoryInterface::class);
2018-12-17 07:09:44 +01:00
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
2018-12-12 20:30:25 +01:00
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('findNull')->once()->andReturn($journal);
2017-03-24 15:01:53 +01:00
$repository->shouldReceive('setOrder')->once()->andReturn(true);
2017-03-05 18:15:38 +01:00
2017-02-12 12:21:44 +01:00
$data = [
2017-03-24 15:01:53 +01:00
'date' => '2016-01-01',
'items' => [1],
2017-02-12 12:21:44 +01:00
];
$this->be($this->user());
$response = $this->post(route('transactions.reorder'), $data);
$response->assertStatus(200);
}
2017-02-24 21:01:33 +01:00
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\TransactionController
* @covers \FireflyIII\Http\Controllers\Controller
2017-02-24 21:01:33 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testShow(): void
2017-02-24 21:01:33 +01:00
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2017-03-05 18:15:38 +01:00
// mock stuff
2018-12-17 07:09:44 +01:00
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
$transformer = $this->mock(TransactionTransformer::class);
2018-12-18 06:57:42 +01:00
$attachment = new Attachment;
$transaction = new Transaction;
2018-12-17 07:09:44 +01:00
$transformer->shouldReceive('setParameters')->atLeast()->once();
2018-12-18 06:57:42 +01:00
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
[
'id' => 5,
]
);
2018-12-17 07:09:44 +01:00
$collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();
$collector->shouldReceive('setJournals')->atLeast()->once()->andReturnSelf();
2018-12-18 06:57:42 +01:00
$collector->shouldReceive('getTransactions')->atLeast()->once()->andReturn(new Collection([$transaction, $transaction]));
2018-02-28 20:18:47 +01:00
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
2018-03-11 21:19:35 +01:00
$journalRepos = $this->mock(JournalRepositoryInterface::class);
2018-12-17 07:09:44 +01:00
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal)->atLeast()->once();
2018-12-18 06:57:42 +01:00
$journalRepos->shouldReceive('getAttachments')->andReturn(new Collection([$attachment]))->atLeast()->once();
2018-12-17 07:09:44 +01:00
$journalRepos->shouldReceive('getPiggyBankEvents')->andReturn(new Collection)->atLeast()->once();
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->atLeast()->once();
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->atLeast()->once();
$journalRepos->shouldReceive('getMetaField')->andReturn('')->atLeast()->once();
2018-12-18 06:57:42 +01:00
$attRepos->shouldReceive('exists')->atLeast()->once()->andReturn(false);
2018-03-11 21:19:35 +01:00
2017-02-24 21:01:33 +01:00
$this->be($this->user());
2017-03-05 11:19:06 +01:00
$response = $this->get(route('transactions.show', [1]));
$response->assertStatus(200);
$response->assertSee('<ol class="breadcrumb">');
2017-02-24 21:01:33 +01:00
}
2018-12-12 20:30:25 +01:00
2017-02-12 12:21:44 +01:00
/**
2018-06-01 22:04:52 +02:00
* @covers \FireflyIII\Http\Controllers\Controller
* @covers \FireflyIII\Http\Controllers\TransactionController
2017-02-12 12:21:44 +01:00
*/
2018-05-11 19:58:10 +02:00
public function testShowOpeningBalance(): void
2017-02-12 12:21:44 +01:00
{
2019-04-09 20:05:20 +02:00
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
2018-12-17 07:09:44 +01:00
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
2018-12-12 20:30:25 +01:00
2018-02-28 20:18:47 +01:00
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
2017-03-05 18:15:38 +01:00
2017-02-12 12:21:44 +01:00
$this->be($this->user());
2017-03-05 11:19:06 +01:00
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 4)->first();
$response = $this->get(route('transactions.show', [$journal->id]));
$response->assertStatus(302);
2017-02-12 12:21:44 +01:00
}
2017-02-16 22:33:32 +01:00
}