mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 13:16:31 +00:00
Clean up tests, test only the important things.
This commit is contained in:
@@ -56,63 +56,6 @@ class TransactionControllerTest extends TestCase
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testAttachments(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$attachmentRepos = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$transformer = $this->mock(AttachmentTransformer::class);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('getAttachmentsByTr')->once()->andReturn(new Collection);
|
||||
|
||||
// get account:
|
||||
$transaction = $this->user()->transactions()->first();
|
||||
|
||||
// call API
|
||||
$response = $this->get(route('api.v1.transactions.attachments', [$transaction->id]));
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy journal over API.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('destroy')->once()->andReturn(true);
|
||||
|
||||
// get account:
|
||||
$transaction = $this->user()->transactions()->first();
|
||||
|
||||
// call API
|
||||
$response = $this->delete('/api/v1/transactions/' . $transaction->id);
|
||||
$response->assertStatus(204);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit with bad currency code
|
||||
*
|
||||
@@ -1323,234 +1266,6 @@ class TransactionControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show index.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')
|
||||
->andReturn($this->user()->accounts()->where('account_type_id', 3)->get());
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
$repository->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf();
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn($paginator);
|
||||
|
||||
|
||||
// mock some calls:
|
||||
|
||||
// test API
|
||||
$response = $this->get('/api/v1/transactions');
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['data' => [],]);
|
||||
$response->assertJson(['meta' => ['pagination' => ['total' => 0, 'count' => 0, 'per_page' => 50, 'current_page' => 1, 'total_pages' => 1]],]);
|
||||
$response->assertJson(['links' => ['self' => true, 'first' => true, 'last' => true,],]);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show index with range.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testIndexWithRange(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')
|
||||
->andReturn($this->user()->accounts()->where('account_type_id', 3)->get());
|
||||
|
||||
$paginator = new LengthAwarePaginator(new Collection, 0, 50);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$repository->shouldReceive('setUser');
|
||||
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn($paginator);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
// mock some calls:
|
||||
|
||||
// test API
|
||||
$response = $this->get('/api/v1/transactions?start=2018-01-01&end=2018-01-31');
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['data' => [],]);
|
||||
$response->assertJson(
|
||||
['meta' =>
|
||||
['pagination' =>
|
||||
[
|
||||
'total' => 0,
|
||||
'count' => 0,
|
||||
'per_page' => 50,
|
||||
'current_page' => 1,
|
||||
'total_pages' => 1,
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$response->assertJson(['links' => ['self' => true, 'first' => true, 'last' => true,],]);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testPiggyBankEvents(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(PiggyBankEventTransformer::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('getPiggyBankEventsbyTr')->once()->andReturn(new Collection);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
|
||||
// get account:
|
||||
$transaction = $this->user()->transactions()->first();
|
||||
|
||||
// call API
|
||||
$response = $this->get(route('api.v1.transactions.piggy_bank_events', [$transaction->id]));
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a withdrawal.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testShowDeposit(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')
|
||||
->andReturn($this->user()->accounts()->where('account_type_id', 3)->get());
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$repository->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('addFilter')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
// test API
|
||||
$response = $this->get('/api/v1/transactions/' . $deposit->id);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(
|
||||
[
|
||||
'data' => [
|
||||
],
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a withdrawal.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionController
|
||||
*/
|
||||
public function testShowWithdrawal(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')
|
||||
->andReturn($this->user()->accounts()->where('account_type_id', 3)->get());
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$repository->shouldReceive('setUser');
|
||||
$collector->shouldReceive('setUser')->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setJournals')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('addFilter')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getTransactions')->andReturn(new Collection);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
// test API
|
||||
$response = $this->get('/api/v1/transactions/' . $withdrawal->id);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(
|
||||
[
|
||||
'data' => [
|
||||
],
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a transaction (withdrawal) with attached bill ID
|
||||
|
||||
Reference in New Issue
Block a user