diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.php
index 0d26804ada..466ba01f71 100644
--- a/app/Http/Controllers/Transaction/IndexController.php
+++ b/app/Http/Controllers/Transaction/IndexController.php
@@ -71,6 +71,7 @@ class IndexController extends Controller
* @param Carbon|null $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ * @throws \Exception
*/
public function index(Request $request, string $objectType, Carbon $start = null, Carbon $end = null)
{
@@ -83,7 +84,7 @@ class IndexController extends Controller
$end = session('end');
}
if (null === $end) {
- $end = session('end');
+ $end = session('end'); // @codeCoverageIgnore
}
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
@@ -141,8 +142,12 @@ class IndexController extends Controller
$collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end)
- ->setTypes($types)->setLimit($pageSize)->setPage($page)->withAccountInformation()
- ->withBudgetInformation()->withCategoryInformation();
+ ->setTypes($types)
+ ->setLimit($pageSize)
+ ->setPage($page)
+ ->withAccountInformation()
+ ->withBudgetInformation()
+ ->withCategoryInformation();
$groups = $collector->getPaginatedGroups();
$groups->setPath($path);
diff --git a/tests/Feature/Controllers/Transaction/CreateControllerTest.php b/tests/Feature/Controllers/Transaction/CreateControllerTest.php
index 28a3b16b91..0d2cbd92dc 100644
--- a/tests/Feature/Controllers/Transaction/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/CreateControllerTest.php
@@ -44,6 +44,9 @@ class CreateControllerTest extends TestCase
Log::info(sprintf('Now in %s.', get_class($this)));
}
+ /**
+ * @covers \FireflyIII\Http\Controllers\Transaction\CreateController
+ */
public function testCreate(): void
{
$this->mockDefaultSession();
diff --git a/tests/Feature/Controllers/Transaction/EditControllerTest.php b/tests/Feature/Controllers/Transaction/EditControllerTest.php
new file mode 100644
index 0000000000..46460247e7
--- /dev/null
+++ b/tests/Feature/Controllers/Transaction/EditControllerTest.php
@@ -0,0 +1,57 @@
+.
+ */
+
+namespace Tests\Feature\Controllers\Transaction;
+
+
+use FireflyIII\Repositories\Account\AccountRepositoryInterface;
+use Log;
+use Tests\TestCase;
+
+/**
+ * Class EditControllerTest
+ */
+class EditControllerTest extends TestCase
+{
+ /**
+ *
+ */
+ public function setUp(): void
+ {
+ parent::setUp();
+ Log::info(sprintf('Now in %s.', get_class($this)));
+ }
+
+ public function testEdit(): void
+ {
+ $group = $this->getRandomWithdrawalGroup();
+ $account = $this->getRandomAsset();
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $this->mockDefaultSession();
+
+ $accountRepos->shouldReceive('getCashAccount')->atLeast()->once()->andReturn($account);
+
+
+ $this->be($this->user());
+ $response = $this->get(route('transactions.edit', [$group->id]));
+ $response->assertStatus(200);
+ }
+}
\ No newline at end of file
diff --git a/tests/Feature/Controllers/Transaction/IndexControllerTest.php b/tests/Feature/Controllers/Transaction/IndexControllerTest.php
new file mode 100644
index 0000000000..634b4881bd
--- /dev/null
+++ b/tests/Feature/Controllers/Transaction/IndexControllerTest.php
@@ -0,0 +1,133 @@
+.
+ */
+
+namespace Tests\Feature\Controllers\Transaction;
+
+
+use Amount;
+use FireflyIII\Helpers\Collector\GroupCollectorInterface;
+use FireflyIII\Models\Preference;
+use FireflyIII\Repositories\User\UserRepositoryInterface;
+use Illuminate\Pagination\LengthAwarePaginator;
+use Log;
+use Mockery;
+use Preferences;
+use Tests\TestCase;
+
+/**
+ * Class IndexControllerTest
+ */
+class IndexControllerTest extends TestCase
+{
+
+ /**
+ *
+ */
+ public function setUp(): void
+ {
+ parent::setUp();
+ Log::info(sprintf('Now in %s.', get_class($this)));
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Controllers\Transaction\IndexController
+ */
+ public function testIndex(): void
+ {
+ $this->mockDefaultSession();
+ $group = $this->getRandomWithdrawalGroup();
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+
+ // generic set for the info blocks:
+ $groupArray = [$this->getRandomWithdrawalAsArray()];
+
+ // role?
+ $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
+
+ // make paginator.
+ $paginator = new LengthAwarePaginator([$group], 1, 40, 1);
+ Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('10');
+
+ $collector->shouldReceive('setTypes')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('setRange')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('setLimit')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('setPage')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('withAccountInformation')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('getPaginatedGroups')->atLeast()->once()->andReturn($paginator);
+ $collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn($groupArray);
+
+
+ $pref = new Preference;
+ $pref->data = 50;
+ Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
+ Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
+
+ $this->be($this->user());
+ $response = $this->get(route('transactions.index', ['withdrawal']));
+ $response->assertStatus(200);
+ }
+
+
+ /**
+ * @covers \FireflyIII\Http\Controllers\Transaction\IndexController
+ */
+ public function testIndexAll(): void
+ {
+ $this->mockDefaultSession();
+ $group = $this->getRandomWithdrawalGroup();
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+
+ // generic set for the info blocks:
+ $groupArray = [$this->getRandomWithdrawalAsArray()];
+
+ // role?
+ $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
+
+ // make paginator.
+ $paginator = new LengthAwarePaginator([$group], 1, 40, 1);
+ //Amount::shouldReceive('formatAnything')->atLeast()->once()->andReturn('10');
+
+ $collector->shouldReceive('setTypes')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('setRange')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('setLimit')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('setPage')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('withAccountInformation')->atLeast()->once()->andReturnSelf();
+ $collector->shouldReceive('getPaginatedGroups')->atLeast()->once()->andReturn($paginator);
+ //$collector->shouldReceive('getExtractedJournals')->atLeast()->once()->andReturn($groupArray);
+
+
+ $pref = new Preference;
+ $pref->data = 50;
+ Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
+ //Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
+
+ $this->be($this->user());
+ $response = $this->get(route('transactions.index.all', ['withdrawal']));
+ $response->assertStatus(200);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/Feature/Controllers/TransactionControllerTest.php b/tests/Feature/Controllers/TransactionControllerTest.php
index 0c0ab08f50..b7f7ef7e91 100644
--- a/tests/Feature/Controllers/TransactionControllerTest.php
+++ b/tests/Feature/Controllers/TransactionControllerTest.php
@@ -58,305 +58,6 @@ class TransactionControllerTest extends TestCase
Log::info(sprintf('Now in %s.', get_class($this)));
}
-
- /**
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- */
- public function testIndex(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
-
- $date = new Carbon;
- $this->session(['start' => $date, 'end' => clone $date]);
-
- // mock stuff
- $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);
-
- $repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
- $collector->shouldReceive('setTypes')->andReturnSelf();
- $collector->shouldReceive('setLimit')->andReturnSelf();
- $collector->shouldReceive('setPage')->andReturnSelf();
- $collector->shouldReceive('addFilter')->andReturnSelf();
- $collector->shouldReceive('setAllAssetAccounts')->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(new Collection);
-
- $this->be($this->user());
- $response = $this->get(route('transactions.index', ['transfer']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('
');
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\TransactionController
- */
- public function testIndexAll(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
-
- $date = new Carbon;
- $this->session(['start' => $date, 'end' => clone $date]);
-
- // mock stuff
- $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);
-
- $repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
- $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
- $collector->shouldReceive('setTypes')->andReturnSelf();
- $collector->shouldReceive('setLimit')->andReturnSelf();
- $collector->shouldReceive('setPage')->andReturnSelf();
- $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
- $collector->shouldReceive('setRange')->andReturnSelf();
- $collector->shouldReceive('addFilter')->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(new Collection);
-
- $this->be($this->user());
- $response = $this->get(route('transactions.index.all', ['transfer']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('');
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- */
- public function testIndexByDate(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
-
- $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
- $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);
-
- $date = new Carbon;
- $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
- $fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
-
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
-
- $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);
-
- $this->be($this->user());
- $response = $this->get(route('transactions.index', ['transfer', '2016-01-01']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('');
- }
-
- /**
- * @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;
-
- $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
- $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);
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
-
- $date = new Carbon;
- $fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
- $fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
-
- $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);
-
- $this->be($this->user());
- $response = $this->get(route('transactions.index', ['transfer', '2016-01-01', '2015-12-31']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('');
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- */
- public function testIndexDeposit(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $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
- $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);
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
-
- $collector->shouldReceive('setTypes')->andReturnSelf();
- $collector->shouldReceive('setLimit')->andReturnSelf();
- $collector->shouldReceive('setPage')->andReturnSelf();
- $collector->shouldReceive('addFilter')->andReturnSelf();
- $collector->shouldReceive('setAllAssetAccounts')->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);
-
- $this->be($this->user());
- $response = $this->get(route('transactions.index', ['deposit']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('');
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- * @covers \FireflyIII\Http\Controllers\TransactionController
- */
- public function testIndexWithdrawal(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $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
- $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);
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
- $repository->shouldReceive('firstNull')->once()->andReturn($transfer);
-
- $collector->shouldReceive('setTypes')->andReturnSelf();
- $collector->shouldReceive('setLimit')->andReturnSelf();
- $collector->shouldReceive('setPage')->andReturnSelf();
- $collector->shouldReceive('addFilter')->andReturnSelf();
- $collector->shouldReceive('setAllAssetAccounts')->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);
-
- $this->be($this->user());
- $response = $this->get(route('transactions.index', ['withdrawal']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('');
- }
-
/**
* @covers \FireflyIII\Http\Controllers\TransactionController
*/