mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Refactor some code for recurrences.
This commit is contained in:
@@ -48,6 +48,35 @@ class AttachmentControllerTest extends TestCase
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test show attachment.
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AttachmentController
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
$transformer = $this->mock(AttachmentTransformer::class);
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->atLeast()->once();
|
||||
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
|
||||
[
|
||||
'id' => 1,
|
||||
'attributes' => [
|
||||
'file' => 'Test.pdf',
|
||||
],
|
||||
]);
|
||||
$transformer->shouldReceive('setCurrentScope')->atLeast()->once();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->atLeast()->once()->andReturn([]);
|
||||
|
||||
$attachment = $this->user()->attachments()->inRandomOrder()->first();
|
||||
|
||||
// test API
|
||||
$response = $this->get(route('api.v1.attachments.show', [$attachment->id]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a new attachment.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user