mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Clean up tests, test only the important things.
This commit is contained in:
@@ -53,102 +53,6 @@ class TransactionLinkControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('destroyLink')->once()->andReturn(true);
|
||||
|
||||
// get a link
|
||||
/** @var TransactionJournalLink $journalLink */
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
|
||||
// call API
|
||||
$response = $this->delete('/api/v1/transaction_links/' . $journalLink->id);
|
||||
$response->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
$transaction->transaction_type_type = 'Withdrawal';
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionLinkTransformer::class);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$repository->shouldReceive('findByName')->once()->andReturn(null);
|
||||
$repository->shouldReceive('getJournalLinks')->once()->andReturn(new Collection);
|
||||
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
|
||||
// call API
|
||||
$response = $this->get('/api/v1/transaction_links');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$journalLink = TransactionJournalLink::first();
|
||||
$transaction = Transaction::first();
|
||||
$transaction->date = new Carbon;
|
||||
$transaction->transaction_type_type = 'Withdrawal';
|
||||
|
||||
|
||||
// mock stuff:
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionLinkTransformer::class);
|
||||
|
||||
// mock transformer
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$journalRepos->shouldReceive('setUser')->once();
|
||||
|
||||
|
||||
// call API
|
||||
$response = $this->get('/api/v1/transaction_links/' . $journalLink->id);
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee($journalLink->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\TransactionLinkController
|
||||
* @covers \FireflyIII\Api\V1\Requests\TransactionLinkRequest
|
||||
|
Reference in New Issue
Block a user