added it_rename_shared_file test

This commit is contained in:
Peter Papp
2021-03-10 11:02:05 +01:00
parent 8a4ffd03c6
commit 1126a45524
5 changed files with 76 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\Services\SetupService;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Str;
use Laravel\Sanctum\Sanctum;
use Storage;
use Tests\TestCase;
@@ -24,6 +25,47 @@ class ShareEditorTest extends TestCase
$this->setup = app()->make(SetupService::class);
}
/**
* @test
*/
public function it_rename_shared_file()
{
$user = User::factory(User::class)
->create();
$folder = Folder::factory(Folder::class)
->create([
'user_id' => $user->id
]);
$file = File::factory(File::class)
->create([
'folder_id' => $folder->id
]);
$share = Share::factory(Share::class)
->create([
'item_id' => $folder->id,
'user_id' => $user->id,
'type' => 'folder',
'is_protected' => false,
'permission' => 'editor',
]);
$this->patchJson("/api/editor/rename/{$file->id}/public/$share->token", [
'name' => 'Renamed Item',
'type' => 'file',
])
->assertStatus(200)
->assertJsonFragment([
'name' => 'Renamed Item',
]);
$this->assertDatabaseHas('files', [
'name' => 'Renamed Item'
]);
}
/**
* @test
*/
@@ -67,7 +109,7 @@ class ShareEditorTest extends TestCase
'is_protected' => false,
]);
$this->postJson("/api/zip/public/$share->token", [
$this->postJson("/api/zip/files/public/$share->token", [
'items' => File::all()->pluck('id')
])->assertStatus(201);
@@ -111,7 +153,7 @@ class ShareEditorTest extends TestCase
'is_protected' => false,
]);
$this->postJson("/api/zip/public/$share->token", [
$this->postJson("/api/zip/files/public/$share->token", [
'items' => File::all()->pluck('id')
])->assertStatus(403);
}
@@ -165,7 +207,7 @@ class ShareEditorTest extends TestCase
'is_protected' => false,
]);
$this->getJson("/api/zip-folder/$children->id/public/$share->token")
$this->getJson("/api/zip/folder/$children->id/public/$share->token")
->assertStatus(201);
$this->assertDatabaseHas('zips', [
@@ -200,7 +242,7 @@ class ShareEditorTest extends TestCase
'is_protected' => false,
]);
$this->getJson("/api/zip-folder/$folder->id/public/$share->token")
$this->getJson("/api/zip/folder/$folder->id/public/$share->token")
->assertStatus(403);
}
}