Added test
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
4c898a8741
commit
12648912aa
1 changed files with 34 additions and 0 deletions
|
@ -4,7 +4,10 @@ namespace Tests\Feature\Locations\Ui;
|
|||
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use App\Models\Actionlog;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UpdateLocationsTest extends TestCase
|
||||
{
|
||||
|
@ -75,5 +78,36 @@ class UpdateLocationsTest extends TestCase
|
|||
}
|
||||
|
||||
|
||||
public function testFileIsUploadedAndLogged()
|
||||
{
|
||||
$location = Location::factory()->create();
|
||||
Storage::fake('local');
|
||||
$file = UploadedFile::fake()->image('file.jpg', 100, 100)->size(100);
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('upload/locations', $location), [
|
||||
'file' => [$file],
|
||||
'notes' => 'Test Upload',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
|
||||
$location->refresh();
|
||||
|
||||
$logentry = Actionlog::where('item_type', Location::class)
|
||||
->where('item_id', $location->id)
|
||||
->where('action_type', 'uploaded')
|
||||
->first();
|
||||
|
||||
$this->assertTrue(Actionlog::where('item_type', Location:: class)->where('item_id', $location->id)->where('filename', $logentry->filename)->exists());
|
||||
|
||||
|
||||
// Assert the file was stored...
|
||||
// This doesn't work with the way we handle files :( Should try to fix this.
|
||||
// Storage::disk('local')->assertExists($logentry->filename);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue