Clean up tests, test only the important things.

This commit is contained in:
James Cole
2019-04-12 04:53:18 +02:00
parent 6f063a134f
commit 5ac39dbdef
65 changed files with 464 additions and 4016 deletions

View File

@@ -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