A free open source IT asset/license management system
Added test
snipe12648912aadf
diff --git a/tests/Feature/Locations/Ui/UpdateLocationsTest.php b/tests/Feature/Locations/Ui/UpdateLocationsTest.phpindex 22d9ce5770..a4c6e9c6b0 100644--- a/tests/Feature/Locations/Ui/UpdateLocationsTest.php+++ b/tests/Feature/Locations/Ui/UpdateLocationsTest.php@@ -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);++ }+}