mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Re-implement transaction and transaction link tests.
This commit is contained in:
parent
851c4d2907
commit
2b76b4a2b2
@ -42,7 +42,8 @@ trait TransactionValidation
|
||||
public function validateAccountInformation(Validator $validator): void
|
||||
{
|
||||
Log::debug('Now in validateAccountInformation()');
|
||||
$data = $validator->getData();
|
||||
$data = $validator->getData();
|
||||
|
||||
$transactionType = $data['type'] ?? 'invalid';
|
||||
$transactions = $data['transactions'] ?? [];
|
||||
|
||||
@ -51,6 +52,7 @@ trait TransactionValidation
|
||||
|
||||
Log::debug(sprintf('Going to loop %d transaction(s)', count($transactions)));
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
$transactionType = $transaction['type'] ?? $transactionType;
|
||||
$accountValidator->setTransactionType($transactionType);
|
||||
|
||||
// validate source account.
|
||||
|
@ -63,9 +63,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailDescription(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -116,9 +113,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailDestination(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -172,9 +166,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailForeignCurrencyAmount(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -226,9 +217,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailForeignCurrencyInfo(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -280,9 +268,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailSource(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -335,9 +320,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailStoreGroupTitle(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -395,9 +377,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailStoreNoTransactions(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
@ -434,9 +413,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailTypes(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -497,9 +473,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailTypesDeposit(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
|
||||
@ -561,9 +534,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreFailTypesTransfer(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
$dest = $this->getRandomAsset($source->id);
|
||||
@ -629,9 +599,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreOK(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$source = $this->getRandomAsset();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
@ -713,21 +680,22 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailBadJournal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(AccountValidator::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['invalid'])->atLeast()->once();
|
||||
$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
|
||||
$data = [
|
||||
'group_title' => 'Empty',
|
||||
'transactions' => [
|
||||
@ -756,8 +724,8 @@ class TransactionControllerTest extends TestCase
|
||||
$response->assertExactJson(
|
||||
[
|
||||
'errors' => [
|
||||
'transactions.0.source_name' => ['When updating a transaction with splits, each split must have a valid transaction journal id (field "transaction_journal_id").'],
|
||||
'transactions.1.source_name' => ['When updating a transaction with splits, each split must have a valid transaction journal id (field "transaction_journal_id").'],
|
||||
'transactions.0.source_name' => ['Each split must have transaction_journal_id (either valid ID or 0).'],
|
||||
'transactions.1.source_name' => ['Each split must have transaction_journal_id (either valid ID or 0).'],
|
||||
],
|
||||
'message' => 'The given data was invalid.',
|
||||
]
|
||||
@ -765,133 +733,6 @@ class TransactionControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update transaction but fail to submit equal destination accounts for a deposit.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Requests\TransactionUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testUpdateFailDepositDestination(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(AccountValidator::class);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$data = [
|
||||
'group_title' => 'Empty',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_journal_id' => 0,
|
||||
'order' => 0,
|
||||
'reconciled' => 'false',
|
||||
'tags' => [],
|
||||
'interest_date' => '2019-01-01',
|
||||
'type' => 'deposit',
|
||||
'destination_name' => 'A',
|
||||
'description' => 'Some new description',
|
||||
],
|
||||
[
|
||||
'transaction_journal_id' => 0,
|
||||
'order' => 0,
|
||||
'reconciled' => 'false',
|
||||
'tags' => [],
|
||||
'interest_date' => '2019-01-01',
|
||||
'type' => 'deposit',
|
||||
'destination_name' => 'B',
|
||||
'description' => 'Some new description',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->put(sprintf('/api/v1/transactions/%d', $group->id), $data, ['Accept' => 'application/json']);
|
||||
|
||||
$response->assertExactJson(
|
||||
[
|
||||
'errors' => [
|
||||
'transactions.0.destination_id' => ['All accounts in this field must be equal.'],
|
||||
],
|
||||
'message' => 'The given data was invalid.',
|
||||
]
|
||||
);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update transaction but fail to submit equal destination accounts for a deposit.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Requests\TransactionUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testUpdateFailTransferDestination(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(AccountValidator::class);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$data = [
|
||||
'group_title' => 'Empty',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_journal_id' => 0,
|
||||
'order' => 0,
|
||||
'reconciled' => 'false',
|
||||
'tags' => [],
|
||||
'interest_date' => '2019-01-01',
|
||||
'type' => 'transfer',
|
||||
'destination_name' => 'A',
|
||||
'description' => 'Some new description',
|
||||
],
|
||||
[
|
||||
'transaction_journal_id' => 0,
|
||||
'order' => 0,
|
||||
'reconciled' => 'false',
|
||||
'tags' => [],
|
||||
'interest_date' => '2019-01-01',
|
||||
'type' => 'transfer',
|
||||
'destination_name' => 'B',
|
||||
'description' => 'Some new description',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->put(sprintf('/api/v1/transactions/%d', $group->id), $data, ['Accept' => 'application/json']);
|
||||
|
||||
$response->assertExactJson(
|
||||
[
|
||||
'errors' => [
|
||||
'transactions.0.destination_id' => ['All accounts in this field must be equal.'],
|
||||
'transactions.0.source_id' => ['All accounts in this field must be equal.'],
|
||||
],
|
||||
'message' => 'The given data was invalid.',
|
||||
]
|
||||
);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update transaction but fail to submit equal transaction types.
|
||||
*
|
||||
@ -900,16 +741,18 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateFailTypes(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(AccountValidator::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['withdrawal'])->atLeast()->once();
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['deposit'])->atLeast()->once();
|
||||
$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@ -953,69 +796,6 @@ class TransactionControllerTest extends TestCase
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update transaction but fail to submit equal source accounts for a withdrawal.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Requests\TransactionUpdateRequest
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testUpdateFailWithdrawalSource(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// mock repository
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(AccountValidator::class);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$data = [
|
||||
'group_title' => 'Empty',
|
||||
'transactions' => [
|
||||
[
|
||||
'transaction_journal_id' => 0,
|
||||
'order' => 0,
|
||||
'reconciled' => 'false',
|
||||
'tags' => [],
|
||||
'interest_date' => '2019-01-01',
|
||||
'type' => 'withdrawal',
|
||||
'source_name' => 'A',
|
||||
'description' => 'Some new description',
|
||||
],
|
||||
[
|
||||
'transaction_journal_id' => 0,
|
||||
'order' => 0,
|
||||
'reconciled' => 'false',
|
||||
'tags' => [],
|
||||
'interest_date' => '2019-01-01',
|
||||
'type' => 'withdrawal',
|
||||
'source_name' => 'B',
|
||||
'description' => 'Some new description',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->put(sprintf('/api/v1/transactions/%d', $group->id), $data, ['Accept' => 'application/json']);
|
||||
|
||||
$response->assertExactJson(
|
||||
[
|
||||
'errors' => [
|
||||
'transactions.0.source_id' => ['All accounts in this field must be equal.'],
|
||||
],
|
||||
'message' => 'The given data was invalid.',
|
||||
]
|
||||
);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the minimum amount of data to update a single withdrawal.
|
||||
*
|
||||
@ -1024,9 +804,6 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateOK(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock data:
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
@ -1034,9 +811,13 @@ class TransactionControllerTest extends TestCase
|
||||
$repository = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$transformer = $this->mock(TransactionGroupTransformer::class);
|
||||
$this->mock(AccountValidator::class);
|
||||
$validator = $this->mock(AccountValidator::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
|
||||
$validator->shouldReceive('setTransactionType')->withArgs(['invalid'])->atLeast()->once();
|
||||
$validator->shouldReceive('validateSource')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->withArgs([null, null])->atLeast()->once()->andReturn(true);
|
||||
|
||||
// some mock calls:
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();
|
||||
|
@ -25,13 +25,13 @@ namespace Tests\Api\V1\Controllers;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use FireflyIII\Transformers\TransactionLinkTransformer;
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Passport\Passport;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
@ -62,9 +62,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStore(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
@ -74,13 +71,11 @@ class TransactionLinkControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionLinkTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
@ -89,7 +84,7 @@ class TransactionLinkControllerTest extends TestCase
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal)->atLeast()->once();
|
||||
$repository->shouldReceive('storeLink')->once()->andReturn($journalLink);
|
||||
$repository->shouldReceive('findLink')->once()->andReturn(false);
|
||||
|
||||
@ -116,10 +111,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreExistingLink(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
@ -128,19 +119,11 @@ class TransactionLinkControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('findLink')->once()->andReturn(true);
|
||||
@ -171,11 +154,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreInvalidInward(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
$transaction->transaction_type_type = 'Withdrawal';
|
||||
@ -183,19 +161,10 @@ class TransactionLinkControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->once()->withArgs([1])->andReturn(null);
|
||||
$journalRepos->shouldReceive('findNull')->once()->withArgs([2])->andReturn(null);
|
||||
@ -224,10 +193,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreInvalidOutward(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
@ -236,19 +201,10 @@ class TransactionLinkControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->once()->withArgs([1])->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->once()->withArgs([2])->andReturn(null);
|
||||
@ -275,10 +231,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreNoJournal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
@ -287,19 +239,10 @@ class TransactionLinkControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->twice()->withArgs([1])->andReturn($journal, null);
|
||||
$journalRepos->shouldReceive('findNull')->twice()->withArgs([2])->andReturn($journal, null);
|
||||
@ -327,11 +270,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testStoreWithNull(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
$transaction->transaction_type_type = 'Withdrawal';
|
||||
@ -339,19 +277,10 @@ class TransactionLinkControllerTest extends TestCase
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn(null);
|
||||
|
||||
@ -377,13 +306,9 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock repositories
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionLinkTransformer::class);
|
||||
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
@ -401,16 +326,8 @@ class TransactionLinkControllerTest extends TestCase
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('updateLink')->once()->andReturn($journalLink);
|
||||
@ -436,13 +353,9 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateNoJournal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock repositories
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
@ -452,16 +365,8 @@ class TransactionLinkControllerTest extends TestCase
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->twice()->withArgs([1])->andReturn($journal, null);
|
||||
$journalRepos->shouldReceive('findNull')->twice()->withArgs([2])->andReturn($journal, null);
|
||||
@ -488,32 +393,19 @@ class TransactionLinkControllerTest extends TestCase
|
||||
*/
|
||||
public function testUpdateWithNull(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock repositories
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$journal = $this->user()->transactionJournals()->find(1);
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
$transaction->transaction_type_type = 'Withdrawal';
|
||||
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser');
|
||||
$journalRepos->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
|
||||
$collector->shouldReceive('setUser')->withAnyArgs();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection([$transaction]));
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$journalRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('findNull')->andReturn(null);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user