mirror of
https://github.com/10h30/Test-Laravel-File-Upload.git
synced 2026-06-05 15:07:47 +09:00
Task 4 - download file
This commit is contained in:
@@ -54,11 +54,24 @@ class FileUploadTest extends TestCase
|
||||
$house = House::first();
|
||||
$this->assertTrue(Storage::exists($house->photo));
|
||||
|
||||
$response = $this->put('houses/1', [
|
||||
$response = $this->put('houses/' . $house->id, [
|
||||
'name' => 'Some name',
|
||||
'photo' => UploadedFile::fake()->image('photo2.jpg')
|
||||
]);
|
||||
$response->assertStatus(200);
|
||||
$this->assertFalse(Storage::exists($house->photo));
|
||||
}
|
||||
|
||||
public function test_download_uploaded_file()
|
||||
{
|
||||
$this->post('houses', [
|
||||
'name' => 'Some name',
|
||||
'photo' => UploadedFile::fake()->image('photo.jpg')
|
||||
]);
|
||||
$house = House::first();
|
||||
|
||||
$response = $this->get('houses/download/' . $house->id);
|
||||
$response->assertStatus(200);
|
||||
$response->assertDownload(str_replace('houses/', '', $house->photo));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user