mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
namespaces refactoring
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Accounts;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Folder;
|
||||
|
||||
class PersonalAccessTokenTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Accounts;
|
||||
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use App\Notifications\ResetPassword;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Notification;
|
||||
use Storage;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use Domain\Sharing\Notifications\ResetPassword;
|
||||
|
||||
class SignFlowTest extends TestCase
|
||||
{
|
||||
@@ -31,7 +29,7 @@ class SignFlowTest extends TestCase
|
||||
[
|
||||
'name' => 'user_verification',
|
||||
'value' => 1,
|
||||
]
|
||||
],
|
||||
])->each(function ($setting) {
|
||||
Setting::create([
|
||||
'name' => $setting['name'],
|
||||
@@ -47,7 +45,7 @@ class SignFlowTest extends TestCase
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com',
|
||||
'email' => 'john@doe.com',
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@ use Storage;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
|
||||
class UserAccountTest extends TestCase
|
||||
@@ -51,10 +50,10 @@ class UserAccountTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/password', [
|
||||
'current_password' => 'secret',
|
||||
'password' => 'VerySecretPassword',
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
])->assertStatus(204);
|
||||
'current_password' => 'secret',
|
||||
'password' => 'VerySecretPassword',
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
])->assertStatus(204);
|
||||
|
||||
// TODO: login s novym heslom
|
||||
}
|
||||
@@ -70,9 +69,9 @@ class UserAccountTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson('/api/user/relationships/settings', [
|
||||
'name' => 'address',
|
||||
'value' => 'Jantar',
|
||||
])->assertStatus(204);
|
||||
'name' => 'address',
|
||||
'value' => 'Jantar',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'address' => 'Jantar',
|
||||
@@ -93,8 +92,8 @@ class UserAccountTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson('/api/user/relationships/settings', [
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(204);
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(204);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists($user->settings->getRawOriginal('avatar'));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Admin;
|
||||
|
||||
use DB;
|
||||
use Storage;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use App\Notifications\ResetPassword;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use DB;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Notification;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Domain\Sharing\Notifications\ResetPassword;
|
||||
|
||||
class AdminTest extends TestCase
|
||||
{
|
||||
@@ -39,7 +38,7 @@ class AdminTest extends TestCase
|
||||
|
||||
Setting::forceCreate([
|
||||
'name' => 'license',
|
||||
'value' => 'Regular'
|
||||
'value' => 'Regular',
|
||||
]);
|
||||
|
||||
DB::table('subscriptions')
|
||||
@@ -55,11 +54,11 @@ class AdminTest extends TestCase
|
||||
->getJson('/api/admin/dashboard')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"license" => 'Regular',
|
||||
"app_version" => config('vuefilemanager.version'),
|
||||
"total_users" => 1,
|
||||
"total_used_space" => '2.00MB',
|
||||
"total_premium_users" => 1,
|
||||
'license' => 'Regular',
|
||||
'app_version' => config('vuefilemanager.version'),
|
||||
'total_users' => 1,
|
||||
'total_used_space' => '2.00MB',
|
||||
'total_premium_users' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -174,37 +173,37 @@ class AdminTest extends TestCase
|
||||
->getJson("/api/admin/users/$user->id/storage")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"data" => [
|
||||
"id" => $user->id,
|
||||
"type" => "storage",
|
||||
"attributes" => [
|
||||
"used" => "5.00MB",
|
||||
"capacity" => "5GB",
|
||||
"percentage" => 0.1,
|
||||
'data' => [
|
||||
'id' => $user->id,
|
||||
'type' => 'storage',
|
||||
'attributes' => [
|
||||
'used' => '5.00MB',
|
||||
'capacity' => '5GB',
|
||||
'percentage' => 0.1,
|
||||
],
|
||||
"meta" => [
|
||||
"images" => [
|
||||
"used" => '1.00MB',
|
||||
"percentage" => 0.02,
|
||||
'meta' => [
|
||||
'images' => [
|
||||
'used' => '1.00MB',
|
||||
'percentage' => 0.02,
|
||||
],
|
||||
"audios" => [
|
||||
"used" => '1.00MB',
|
||||
"percentage" => 0.02,
|
||||
'audios' => [
|
||||
'used' => '1.00MB',
|
||||
'percentage' => 0.02,
|
||||
],
|
||||
"videos" => [
|
||||
"used" => '1.00MB',
|
||||
"percentage" => 0.02,
|
||||
'videos' => [
|
||||
'used' => '1.00MB',
|
||||
'percentage' => 0.02,
|
||||
],
|
||||
"documents" => [
|
||||
"used" => '1.00MB',
|
||||
"percentage" => 0.02,
|
||||
'documents' => [
|
||||
'used' => '1.00MB',
|
||||
'percentage' => 0.02,
|
||||
],
|
||||
"others" => [
|
||||
"used" => '1.00MB',
|
||||
"percentage" => 0.02,
|
||||
]
|
||||
]
|
||||
]
|
||||
'others' => [
|
||||
'used' => '1.00MB',
|
||||
'percentage' => 0.02,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -241,10 +240,10 @@ class AdminTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/users/$user->id/capacity", [
|
||||
'attributes' => [
|
||||
'storage_capacity' => 10
|
||||
]
|
||||
])->assertStatus(200);
|
||||
'attributes' => [
|
||||
'storage_capacity' => 10,
|
||||
],
|
||||
])->assertStatus(200);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'user_id' => $user->id,
|
||||
@@ -266,10 +265,10 @@ class AdminTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/users/$user->id/role", [
|
||||
'attributes' => [
|
||||
'role' => 'admin'
|
||||
]
|
||||
])->assertStatus(200);
|
||||
'attributes' => [
|
||||
'role' => 'admin',
|
||||
],
|
||||
])->assertStatus(200);
|
||||
|
||||
$this->assertTrue(User::find($user->id)->role === 'admin');
|
||||
}
|
||||
@@ -287,25 +286,25 @@ class AdminTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson("/api/admin/users/create", [
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'VerySecretPassword',
|
||||
'storage_capacity' => 15,
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(201);
|
||||
->postJson('/api/admin/users/create', [
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'VerySecretPassword',
|
||||
'storage_capacity' => 15,
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com'
|
||||
'email' => 'john@doe.com',
|
||||
]);
|
||||
|
||||
$this->assertNotNull(User::whereEmail('john@doe.com')
|
||||
->get('email_verified_at'));
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'name' => 'John Doe'
|
||||
'name' => 'John Doe',
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
@@ -348,7 +347,6 @@ class AdminTest extends TestCase
|
||||
// Upload files
|
||||
collect([0, 1])
|
||||
->each(function ($index) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
@@ -382,7 +380,7 @@ class AdminTest extends TestCase
|
||||
|
||||
// Delete user
|
||||
$this->deleteJson("/api/admin/users/$user->id/delete", [
|
||||
'name' => $user->settings->name
|
||||
'name' => $user->settings->name,
|
||||
])
|
||||
->assertStatus(204);
|
||||
|
||||
@@ -412,7 +410,6 @@ class AdminTest extends TestCase
|
||||
|
||||
$file_ids
|
||||
->each(function ($id, $index) use ($user) {
|
||||
|
||||
Storage::disk('local')
|
||||
->assertMissing(
|
||||
"files/$user->id/fake-file-$index.pdf"
|
||||
@@ -445,7 +442,7 @@ class AdminTest extends TestCase
|
||||
$this->getJson('/api/admin/pages')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'slug' => $slug
|
||||
'slug' => $slug,
|
||||
]);
|
||||
});
|
||||
}
|
||||
@@ -465,7 +462,7 @@ class AdminTest extends TestCase
|
||||
->getJson('/api/admin/pages/terms-of-service')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'slug' => 'terms-of-service'
|
||||
'slug' => 'terms-of-service',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -482,12 +479,12 @@ class AdminTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/pages/terms-of-service', [
|
||||
'name' => 'title',
|
||||
'value' => 'New Title'
|
||||
])->assertStatus(204);
|
||||
'name' => 'title',
|
||||
'value' => 'New Title',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('pages', [
|
||||
'title' => 'New Title'
|
||||
'title' => 'New Title',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Browsing;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class BrowseTest extends TestCase
|
||||
{
|
||||
@@ -56,60 +55,60 @@ class BrowseTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/navigation")
|
||||
->getJson('/api/browse/navigation')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
"name" => "Home",
|
||||
"location" => "base",
|
||||
"folders" => [
|
||||
'name' => 'Home',
|
||||
'location' => 'base',
|
||||
'folders' => [
|
||||
[
|
||||
"id" => $folder_level_1->id,
|
||||
"parent_id" => null,
|
||||
"name" => "level 1",
|
||||
"items" => 2,
|
||||
"trashed_items" => 2,
|
||||
"type" => "folder",
|
||||
"folders" => [
|
||||
'id' => $folder_level_1->id,
|
||||
'parent_id' => null,
|
||||
'name' => 'level 1',
|
||||
'items' => 2,
|
||||
'trashed_items' => 2,
|
||||
'type' => 'folder',
|
||||
'folders' => [
|
||||
[
|
||||
"id" => $folder_level_2->id,
|
||||
"parent_id" => $folder_level_1->id,
|
||||
"name" => "level 2",
|
||||
"items" => 1,
|
||||
"trashed_items" => 1,
|
||||
"type" => "folder",
|
||||
"folders" => [
|
||||
'id' => $folder_level_2->id,
|
||||
'parent_id' => $folder_level_1->id,
|
||||
'name' => 'level 2',
|
||||
'items' => 1,
|
||||
'trashed_items' => 1,
|
||||
'type' => 'folder',
|
||||
'folders' => [
|
||||
[
|
||||
"id" => $folder_level_3->id,
|
||||
"user_id" => $user->id,
|
||||
"parent_id" => $folder_level_2->id,
|
||||
"name" => "level 3",
|
||||
"color" => null,
|
||||
"emoji" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $folder_level_3->created_at,
|
||||
"updated_at" => $folder_level_3->updated_at->toJson(),
|
||||
"items" => 0,
|
||||
"trashed_items" => 0,
|
||||
"type" => "folder",
|
||||
"folders" => [],
|
||||
'id' => $folder_level_3->id,
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $folder_level_2->id,
|
||||
'name' => 'level 3',
|
||||
'color' => null,
|
||||
'emoji' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $folder_level_3->created_at,
|
||||
'updated_at' => $folder_level_3->updated_at->toJson(),
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'type' => 'folder',
|
||||
'folders' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
"id" => $folder_level_2_sibling->id,
|
||||
"parent_id" => $folder_level_1->id,
|
||||
"name" => "level 2 Sibling",
|
||||
"items" => 0,
|
||||
"trashed_items" => 0,
|
||||
"type" => "folder",
|
||||
"folders" => []
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
'id' => $folder_level_2_sibling->id,
|
||||
'parent_id' => $folder_level_1->id,
|
||||
'name' => 'level 2 Sibling',
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'type' => 'folder',
|
||||
'folders' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -131,7 +130,7 @@ class BrowseTest extends TestCase
|
||||
->create([
|
||||
'parent_id' => $root->id,
|
||||
'name' => 'Documents',
|
||||
"author" => "user",
|
||||
'author' => 'user',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
@@ -140,9 +139,9 @@ class BrowseTest extends TestCase
|
||||
'folder_id' => $root->id,
|
||||
'name' => 'Document',
|
||||
'basename' => 'document.pdf',
|
||||
"mimetype" => "application/pdf",
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'mimetype' => 'application/pdf',
|
||||
'author' => 'user',
|
||||
'type' => 'file',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
@@ -152,53 +151,53 @@ class BrowseTest extends TestCase
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
"id" => $folder->id,
|
||||
"user_id" => $user->id,
|
||||
"parent_id" => $root->id,
|
||||
"name" => "Documents",
|
||||
"color" => null,
|
||||
"emoji" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $folder->created_at,
|
||||
"updated_at" => $folder->updated_at->toJson(),
|
||||
"items" => 0,
|
||||
"trashed_items" => 0,
|
||||
"type" => "folder",
|
||||
"parent" => [
|
||||
"id" => $root->id,
|
||||
"name" => "root",
|
||||
"items" => 2,
|
||||
"trashed_items" => 2,
|
||||
"type" => "folder",
|
||||
'id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $root->id,
|
||||
'name' => 'Documents',
|
||||
'color' => null,
|
||||
'emoji' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $folder->created_at,
|
||||
'updated_at' => $folder->updated_at->toJson(),
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'type' => 'folder',
|
||||
'parent' => [
|
||||
'id' => $root->id,
|
||||
'name' => 'root',
|
||||
'items' => 2,
|
||||
'trashed_items' => 2,
|
||||
'type' => 'folder',
|
||||
],
|
||||
"shared" => null,
|
||||
'shared' => null,
|
||||
],
|
||||
[
|
||||
"id" => $file->id,
|
||||
"user_id" => $user->id,
|
||||
"folder_id" => $root->id,
|
||||
"thumbnail" => null,
|
||||
"name" => "Document",
|
||||
"basename" => "document.pdf",
|
||||
"mimetype" => "application/pdf",
|
||||
"filesize" => $file->filesize,
|
||||
"type" => "file",
|
||||
"metadata" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $file->created_at,
|
||||
"updated_at" => $file->updated_at->toJson(),
|
||||
"file_url" => "http://localhost/file/document.pdf",
|
||||
"parent" => [
|
||||
"id" => $root->id,
|
||||
"name" => "root",
|
||||
"items" => 2,
|
||||
"trashed_items" => 2,
|
||||
"type" => "folder",
|
||||
'id' => $file->id,
|
||||
'user_id' => $user->id,
|
||||
'folder_id' => $root->id,
|
||||
'thumbnail' => null,
|
||||
'name' => 'Document',
|
||||
'basename' => 'document.pdf',
|
||||
'mimetype' => 'application/pdf',
|
||||
'filesize' => $file->filesize,
|
||||
'type' => 'file',
|
||||
'metadata' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $file->created_at,
|
||||
'updated_at' => $file->updated_at->toJson(),
|
||||
'file_url' => 'http://localhost/file/document.pdf',
|
||||
'parent' => [
|
||||
'id' => $root->id,
|
||||
'name' => 'root',
|
||||
'items' => 2,
|
||||
'trashed_items' => 2,
|
||||
'type' => 'folder',
|
||||
],
|
||||
"shared" => null,
|
||||
]
|
||||
'shared' => null,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -221,9 +220,9 @@ class BrowseTest extends TestCase
|
||||
'folder_id' => $root->id,
|
||||
'name' => 'Document 1',
|
||||
'basename' => 'document-1.pdf',
|
||||
"mimetype" => "application/pdf",
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'mimetype' => 'application/pdf',
|
||||
'author' => 'user',
|
||||
'type' => 'file',
|
||||
'user_id' => $user->id,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
@@ -235,64 +234,64 @@ class BrowseTest extends TestCase
|
||||
'folder_id' => $root->id,
|
||||
'name' => 'Document 2',
|
||||
'basename' => 'document-2.pdf',
|
||||
"mimetype" => "application/pdf",
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'mimetype' => 'application/pdf',
|
||||
'author' => 'user',
|
||||
'type' => 'file',
|
||||
'user_id' => $user->id,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/latest")
|
||||
->getJson('/api/browse/latest')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
"id" => $file_2->id,
|
||||
"user_id" => $user->id,
|
||||
"folder_id" => $root->id,
|
||||
"thumbnail" => null,
|
||||
"name" => "Document 2",
|
||||
"basename" => "document-2.pdf",
|
||||
"mimetype" => "application/pdf",
|
||||
"filesize" => $file_2->filesize,
|
||||
"type" => "file",
|
||||
"metadata" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $file_2->created_at,
|
||||
"updated_at" => $file_2->updated_at->toJson(),
|
||||
"file_url" => "http://localhost/file/document-2.pdf",
|
||||
"parent" => [
|
||||
"id" => $root->id,
|
||||
"name" => "root",
|
||||
"items" => 2,
|
||||
"trashed_items" => 2,
|
||||
"type" => "folder",
|
||||
'id' => $file_2->id,
|
||||
'user_id' => $user->id,
|
||||
'folder_id' => $root->id,
|
||||
'thumbnail' => null,
|
||||
'name' => 'Document 2',
|
||||
'basename' => 'document-2.pdf',
|
||||
'mimetype' => 'application/pdf',
|
||||
'filesize' => $file_2->filesize,
|
||||
'type' => 'file',
|
||||
'metadata' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $file_2->created_at,
|
||||
'updated_at' => $file_2->updated_at->toJson(),
|
||||
'file_url' => 'http://localhost/file/document-2.pdf',
|
||||
'parent' => [
|
||||
'id' => $root->id,
|
||||
'name' => 'root',
|
||||
'items' => 2,
|
||||
'trashed_items' => 2,
|
||||
'type' => 'folder',
|
||||
],
|
||||
],
|
||||
[
|
||||
"id" => $file_1->id,
|
||||
"user_id" => $user->id,
|
||||
"folder_id" => $root->id,
|
||||
"thumbnail" => null,
|
||||
"name" => "Document 1",
|
||||
"basename" => "document-1.pdf",
|
||||
"mimetype" => "application/pdf",
|
||||
"filesize" => $file_1->filesize,
|
||||
"type" => "file",
|
||||
"metadata" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $file_1->created_at,
|
||||
"updated_at" => $file_1->updated_at->toJson(),
|
||||
"file_url" => "http://localhost/file/document-1.pdf",
|
||||
"parent" => [
|
||||
"id" => $root->id,
|
||||
"name" => "root",
|
||||
"items" => 2,
|
||||
"trashed_items" => 2,
|
||||
"type" => "folder",
|
||||
'id' => $file_1->id,
|
||||
'user_id' => $user->id,
|
||||
'folder_id' => $root->id,
|
||||
'thumbnail' => null,
|
||||
'name' => 'Document 1',
|
||||
'basename' => 'document-1.pdf',
|
||||
'mimetype' => 'application/pdf',
|
||||
'filesize' => $file_1->filesize,
|
||||
'type' => 'file',
|
||||
'metadata' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $file_1->created_at,
|
||||
'updated_at' => $file_1->updated_at->toJson(),
|
||||
'file_url' => 'http://localhost/file/document-1.pdf',
|
||||
'parent' => [
|
||||
'id' => $root->id,
|
||||
'name' => 'root',
|
||||
'items' => 2,
|
||||
'trashed_items' => 2,
|
||||
'type' => 'folder',
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -308,17 +307,17 @@ class BrowseTest extends TestCase
|
||||
|
||||
$file = File::factory(File::class)
|
||||
->create([
|
||||
"author" => "visitor",
|
||||
"type" => "file",
|
||||
'author' => 'visitor',
|
||||
'type' => 'file',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/participants")
|
||||
->getJson('/api/browse/participants')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -335,7 +334,7 @@ class BrowseTest extends TestCase
|
||||
'parent_id' => null,
|
||||
'name' => 'root',
|
||||
'user_id' => $user->id,
|
||||
"author" => "user",
|
||||
'author' => 'user',
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
|
||||
@@ -344,9 +343,9 @@ class BrowseTest extends TestCase
|
||||
'folder_id' => null,
|
||||
'name' => 'Document',
|
||||
'basename' => 'document.pdf',
|
||||
"mimetype" => "application/pdf",
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'mimetype' => 'application/pdf',
|
||||
'author' => 'user',
|
||||
'type' => 'file',
|
||||
'user_id' => $user->id,
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
@@ -360,42 +359,42 @@ class BrowseTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/trash")
|
||||
->getJson('/api/browse/trash')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
"id" => $folder->id,
|
||||
"user_id" => $user->id,
|
||||
"parent_id" => null,
|
||||
"name" => "root",
|
||||
"color" => null,
|
||||
"emoji" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => $folder->deleted_at,
|
||||
"created_at" => $folder->created_at,
|
||||
"updated_at" => $folder->updated_at->toJson(),
|
||||
"items" => 0,
|
||||
"trashed_items" => 1,
|
||||
"type" => "folder",
|
||||
"parent" => null,
|
||||
'id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => null,
|
||||
'name' => 'root',
|
||||
'color' => null,
|
||||
'emoji' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => $folder->deleted_at,
|
||||
'created_at' => $folder->created_at,
|
||||
'updated_at' => $folder->updated_at->toJson(),
|
||||
'items' => 0,
|
||||
'trashed_items' => 1,
|
||||
'type' => 'folder',
|
||||
'parent' => null,
|
||||
],
|
||||
[
|
||||
"id" => $file->id,
|
||||
"user_id" => $user->id,
|
||||
"folder_id" => null,
|
||||
"thumbnail" => null,
|
||||
"name" => "Document",
|
||||
"basename" => "document.pdf",
|
||||
"mimetype" => "application/pdf",
|
||||
"filesize" => $file->filesize,
|
||||
"type" => "file",
|
||||
"metadata" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => $file->deleted_at,
|
||||
"created_at" => $file->created_at,
|
||||
"updated_at" => $file->updated_at->toJson(),
|
||||
"file_url" => "http://localhost/file/document.pdf",
|
||||
"parent" => null
|
||||
'id' => $file->id,
|
||||
'user_id' => $user->id,
|
||||
'folder_id' => null,
|
||||
'thumbnail' => null,
|
||||
'name' => 'Document',
|
||||
'basename' => 'document.pdf',
|
||||
'mimetype' => 'application/pdf',
|
||||
'filesize' => $file->filesize,
|
||||
'type' => 'file',
|
||||
'metadata' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => $file->deleted_at,
|
||||
'created_at' => $file->created_at,
|
||||
'updated_at' => $file->updated_at->toJson(),
|
||||
'file_url' => 'http://localhost/file/document.pdf',
|
||||
'parent' => null,
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -424,18 +423,18 @@ class BrowseTest extends TestCase
|
||||
->each(function ($item) use ($user) {
|
||||
Share::factory(Share::class)
|
||||
->create([
|
||||
"type" => $item->type === 'folder' ? 'folder' : 'file',
|
||||
"item_id" => $item->id,
|
||||
'type' => $item->type === 'folder' ? 'folder' : 'file',
|
||||
'item_id' => $item->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
});
|
||||
|
||||
collect([$folder, $file])
|
||||
->each(function ($item) use ($user) {
|
||||
$this->getJson("/api/browse/share")
|
||||
$this->getJson('/api/browse/share')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $item->id
|
||||
'id' => $item->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
@@ -456,10 +455,10 @@ class BrowseTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/search?query=doc")
|
||||
->getJson('/api/browse/search?query=doc')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -479,10 +478,10 @@ class BrowseTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/search?query=doc")
|
||||
->getJson('/api/browse/search?query=doc')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Files;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class ContentAccessTest extends TestCase
|
||||
{
|
||||
@@ -211,7 +210,7 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function guest_try_to_get_private_user_file()
|
||||
{
|
||||
$this->get("file/fake-file.pdf")
|
||||
$this->get('file/fake-file.pdf')
|
||||
->assertRedirect();
|
||||
}
|
||||
|
||||
@@ -220,7 +219,7 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function guest_try_to_get_private_user_zip()
|
||||
{
|
||||
$this->get("zip/EHWKcuvKzA4Gv29v-archive.zip")
|
||||
$this->get('zip/EHWKcuvKzA4Gv29v-archive.zip')
|
||||
->assertRedirect();
|
||||
}
|
||||
|
||||
@@ -229,7 +228,7 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function guest_try_to_get_private_user_image_thumbnail()
|
||||
{
|
||||
$this->get("thumbnail/fake-thumbnail.jpg")
|
||||
$this->get('thumbnail/fake-thumbnail.jpg')
|
||||
->assertRedirect();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Files;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class FileTest extends TestCase
|
||||
{
|
||||
@@ -29,7 +28,7 @@ class FileTest extends TestCase
|
||||
->create();
|
||||
|
||||
$this->assertDatabaseHas('files', [
|
||||
'id' => $file->id
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -47,16 +46,16 @@ class FileTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$disk->assertMissing(
|
||||
"chunks/fake-image.jpg"
|
||||
'chunks/fake-image.jpg'
|
||||
);
|
||||
|
||||
$disk->assertExists(
|
||||
@@ -86,16 +85,16 @@ class FileTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
$disk->assertMissing(
|
||||
"chunks/fake-file.pdf"
|
||||
'chunks/fake-file.pdf'
|
||||
);
|
||||
|
||||
$disk->assertExists(
|
||||
@@ -126,10 +125,10 @@ class FileTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload', [
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(422);
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(422);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertMissing("files/$user->id/fake-file.pdf");
|
||||
@@ -149,16 +148,16 @@ class FileTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$file->id}", [
|
||||
'name' => 'Renamed Item',
|
||||
'type' => 'file',
|
||||
])
|
||||
'name' => 'Renamed Item',
|
||||
'type' => 'file',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Renamed Item',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('files', [
|
||||
'name' => 'Renamed Item'
|
||||
'name' => 'Renamed Item',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -178,15 +177,15 @@ class FileTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/move", [
|
||||
'to_id' => $folder->id,
|
||||
'items' => [
|
||||
[
|
||||
'type' => 'file',
|
||||
'id' => $file->id,
|
||||
]
|
||||
],
|
||||
])->assertStatus(204);
|
||||
->postJson('/api/move', [
|
||||
'to_id' => $folder->id,
|
||||
'items' => [
|
||||
[
|
||||
'type' => 'file',
|
||||
'id' => $file->id,
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('files', [
|
||||
'id' => $file->id,
|
||||
@@ -208,20 +207,20 @@ class FileTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $files[0]->id,
|
||||
'type' => 'file',
|
||||
'force_delete' => false,
|
||||
->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $files[0]->id,
|
||||
'type' => 'file',
|
||||
'force_delete' => false,
|
||||
],
|
||||
[
|
||||
'id' => $files[1]->id,
|
||||
'type' => 'file',
|
||||
'force_delete' => false,
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => $files[1]->id,
|
||||
'type' => 'file',
|
||||
'force_delete' => false,
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(204);
|
||||
|
||||
$files
|
||||
->each(function ($file) {
|
||||
@@ -243,7 +242,6 @@ class FileTest extends TestCase
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
@@ -257,7 +255,7 @@ class FileTest extends TestCase
|
||||
|
||||
$file_ids = File::all()->pluck('id');
|
||||
|
||||
$this->postJson("/api/remove", [
|
||||
$this->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $file_ids->first(),
|
||||
@@ -274,7 +272,6 @@ class FileTest extends TestCase
|
||||
|
||||
$file_ids
|
||||
->each(function ($id, $index) use ($user) {
|
||||
|
||||
$this->assertDatabaseMissing('files', [
|
||||
'id' => $id,
|
||||
]);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Folders;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
// TODO: pridat foldre do api skupiny
|
||||
|
||||
@@ -31,7 +29,7 @@ class FolderTest extends TestCase
|
||||
->create();
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'id' => $folder->id
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -46,16 +44,16 @@ class FolderTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/create-folder', [
|
||||
'name' => 'New Folder',
|
||||
'parent_id' => null,
|
||||
])
|
||||
'name' => 'New Folder',
|
||||
'parent_id' => null,
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => 'New Folder',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'name' => 'New Folder'
|
||||
'name' => 'New Folder',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -73,16 +71,16 @@ class FolderTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$folder->id}", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
])
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Renamed Folder',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'name' => 'Renamed Folder'
|
||||
'name' => 'Renamed Folder',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -106,19 +104,19 @@ class FolderTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$folder->id}", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
'emoji' => $emoji_fragment
|
||||
])
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
'emoji' => $emoji_fragment,
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Renamed Folder',
|
||||
'emoji' => $emoji_fragment
|
||||
'emoji' => $emoji_fragment,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'color' => null,
|
||||
'emoji' => json_encode($emoji_fragment)
|
||||
'emoji' => json_encode($emoji_fragment),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -136,10 +134,10 @@ class FolderTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$folder->id}", [
|
||||
'name' => 'Folder Name',
|
||||
'type' => 'folder',
|
||||
'color' => '#AD6FFE'
|
||||
])
|
||||
'name' => 'Folder Name',
|
||||
'type' => 'folder',
|
||||
'color' => '#AD6FFE',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Folder Name',
|
||||
@@ -166,11 +164,11 @@ class FolderTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/folders/favourites", [
|
||||
'folders' => [
|
||||
$folder->id
|
||||
],
|
||||
])->assertStatus(204);
|
||||
->postJson('/api/folders/favourites', [
|
||||
'folders' => [
|
||||
$folder->id,
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('favourite_folder', [
|
||||
'user_id' => $user->id,
|
||||
@@ -220,18 +218,19 @@ class FolderTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/move", [
|
||||
'to_id' => $root->id,
|
||||
'items' => [
|
||||
[
|
||||
'type' => 'folder',
|
||||
'id' => $children->id,
|
||||
]
|
||||
],
|
||||
])->assertStatus(204);
|
||||
->postJson('/api/move', [
|
||||
'to_id' => $root->id,
|
||||
'items' => [
|
||||
[
|
||||
'type' => 'folder',
|
||||
'id' => $children->id,
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertEquals(
|
||||
$root->id, Folder::find($children->id)->parent_id
|
||||
$root->id,
|
||||
Folder::find($children->id)->parent_id
|
||||
);
|
||||
}
|
||||
|
||||
@@ -254,24 +253,23 @@ class FolderTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_1->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => false,
|
||||
->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_1->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => false,
|
||||
],
|
||||
[
|
||||
'id' => $folder_2->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => false,
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => $folder_2->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => false,
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(204);
|
||||
|
||||
collect([$folder_1, $folder_2])
|
||||
->each(function ($folder) {
|
||||
|
||||
$this->assertSoftDeleted('folders', [
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
@@ -298,20 +296,20 @@ class FolderTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_1->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => true,
|
||||
->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_1->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => true,
|
||||
],
|
||||
[
|
||||
'id' => $folder_2->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => $folder_2->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => true,
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('folders', [
|
||||
'id' => $folder_1->id,
|
||||
@@ -332,7 +330,7 @@ class FolderTest extends TestCase
|
||||
|
||||
$folder_root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$folder_children = Folder::factory(Folder::class)
|
||||
@@ -355,15 +353,15 @@ class FolderTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_root->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => false,
|
||||
->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_root->id,
|
||||
'type' => 'folder',
|
||||
'force_delete' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(204);
|
||||
|
||||
collect([$file_1, $file_2])
|
||||
->each(function ($file) {
|
||||
@@ -392,7 +390,7 @@ class FolderTest extends TestCase
|
||||
|
||||
$folder_root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$folder_children = Folder::factory(Folder::class)
|
||||
@@ -403,7 +401,6 @@ class FolderTest extends TestCase
|
||||
|
||||
collect([$folder_root, $folder_children])
|
||||
->each(function ($folder, $index) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
@@ -419,7 +416,7 @@ class FolderTest extends TestCase
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder_root) {
|
||||
$this->postJson("/api/remove", [
|
||||
$this->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_root->id,
|
||||
@@ -432,7 +429,6 @@ class FolderTest extends TestCase
|
||||
|
||||
$uploaded_files
|
||||
->each(function ($file, $index) use ($user) {
|
||||
|
||||
$this->assertDatabaseMissing('files', [
|
||||
'id' => $file->id,
|
||||
]);
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Homepage;
|
||||
|
||||
use App\Http\Mail\SendContactMessage;
|
||||
use Mail;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Homepage\Mail\SendContactMessage;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Mail;
|
||||
use ScssPhp\ScssPhp\Compiler;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HomepageTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Invoices;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\User;
|
||||
|
||||
class UserInvoicesTest extends TestCase
|
||||
{
|
||||
@@ -31,7 +28,7 @@ class UserInvoicesTest extends TestCase
|
||||
$this->getJson('/api/user/invoices')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
'customer' => $this->user['stripe_id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Languages;
|
||||
|
||||
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Language;
|
||||
|
||||
class AdminLanguageTranslatorTest
|
||||
{
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -28,9 +23,9 @@ class AdminLanguageTranslatorTest
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/languages', [
|
||||
'name' => 'Slovenčina',
|
||||
'locale' => 'sk',
|
||||
])
|
||||
'name' => 'Slovenčina',
|
||||
'locale' => 'sk',
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Slovenčina',
|
||||
@@ -64,9 +59,9 @@ class AdminLanguageTranslatorTest
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/languages/$language->id", [
|
||||
'name' => 'name',
|
||||
'value' => 'Slovenčina',
|
||||
])
|
||||
'name' => 'name',
|
||||
'value' => 'Slovenčina',
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Slovenčina',
|
||||
@@ -85,7 +80,7 @@ class AdminLanguageTranslatorTest
|
||||
{
|
||||
$language = Language::create([
|
||||
'name' => 'Slovenčina',
|
||||
'locale' => 'sk'
|
||||
'locale' => 'sk',
|
||||
]);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
@@ -141,8 +136,8 @@ class AdminLanguageTranslatorTest
|
||||
->getJson('/api/admin/languages')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"locale" => "en",
|
||||
"actions.close" => "Close",
|
||||
'locale' => 'en',
|
||||
'actions.close' => 'Close',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -161,9 +156,9 @@ class AdminLanguageTranslatorTest
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/languages/$language->id/strings", [
|
||||
'name' => 'actions.close',
|
||||
'value' => 'Close It, now!',
|
||||
]);
|
||||
'name' => 'actions.close',
|
||||
'value' => 'Close It, now!',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('language_translations', [
|
||||
'key' => 'actions.close',
|
||||
@@ -189,8 +184,8 @@ class AdminLanguageTranslatorTest
|
||||
->getJson("/api/admin/languages/$language->id")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"actions.close" => "Close",
|
||||
"locale" => "en",
|
||||
'actions.close' => 'Close',
|
||||
'locale' => 'en',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Languages;
|
||||
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class TranslationsAccessTest extends TestCase
|
||||
{
|
||||
@@ -26,10 +22,10 @@ class TranslationsAccessTest extends TestCase
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->getJson("/translations/en")
|
||||
$this->getJson('/translations/en')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"actions.close" => "Close",
|
||||
'actions.close' => 'Close',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -57,9 +53,9 @@ class TranslationsAccessTest extends TestCase
|
||||
Language::first()
|
||||
->languageTranslations()
|
||||
->forceCreate([
|
||||
"key" => "test",
|
||||
"value" => "Hi, my name is :name :surname",
|
||||
"lang" => "en",
|
||||
'key' => 'test',
|
||||
'value' => 'Hi, my name is :name :surname',
|
||||
'lang' => 'en',
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
@@ -78,7 +74,6 @@ class TranslationsAccessTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Maintenance;
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
use Domain\Settings\Models\User;
|
||||
|
||||
class AppUpgradeTest extends TestCase
|
||||
{
|
||||
@@ -27,17 +25,16 @@ class AppUpgradeTest extends TestCase
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => 'Extended',
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
collect(['en', 'sk'])
|
||||
->map(function ($locale) {
|
||||
|
||||
DB::table('languages')
|
||||
->insert([
|
||||
'id' => Str::uuid(),
|
||||
'name' => 'English',
|
||||
'locale' => $locale
|
||||
'locale' => $locale,
|
||||
]);
|
||||
|
||||
DB::table('language_translations')
|
||||
@@ -45,12 +42,12 @@ class AppUpgradeTest extends TestCase
|
||||
[
|
||||
'key' => 'activation.stripe.button',
|
||||
'value' => 'Set up your Stripe account',
|
||||
'lang' => $locale
|
||||
'lang' => $locale,
|
||||
], [
|
||||
'key' => 'activation.stripe.description',
|
||||
'value' => 'This is original test description',
|
||||
'lang' => $locale
|
||||
]
|
||||
'lang' => $locale,
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -61,7 +58,6 @@ class AppUpgradeTest extends TestCase
|
||||
|
||||
collect(['en', 'sk'])
|
||||
->map(function ($locale) {
|
||||
|
||||
$this->assertDatabaseHas('language_translations', [
|
||||
'key' => 'activation.stripe.title',
|
||||
'value' => 'Your Stripe account is not set',
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Pages;
|
||||
|
||||
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Tests\TestCase;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class PagesTest extends TestCase
|
||||
{
|
||||
@@ -22,4 +19,4 @@ class PagesTest extends TestCase
|
||||
'title' => 'Terms of Service',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Plans;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\User;
|
||||
|
||||
class AdminPlansTest extends TestCase
|
||||
{
|
||||
@@ -38,17 +35,17 @@ class AdminPlansTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/plans', [
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => $plan_name,
|
||||
'price' => (string)rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
])
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => $plan_name,
|
||||
'price' => (string) rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => $plan_name
|
||||
'name' => $plan_name,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -68,19 +65,19 @@ class AdminPlansTest extends TestCase
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => $plan_name,
|
||||
'price' => (string)rand(1, 99),
|
||||
'price' => (string) rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => $plan_name
|
||||
'name' => $plan_name,
|
||||
]);
|
||||
|
||||
$this->patchJson("/api/admin/plans/" . strtolower($plan_name), [
|
||||
$this->patchJson('/api/admin/plans/' . strtolower($plan_name), [
|
||||
'name' => 'description',
|
||||
'value' => 'updated description'
|
||||
'value' => 'updated description',
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
@@ -95,12 +92,12 @@ class AdminPlansTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
@@ -110,7 +107,7 @@ class AdminPlansTest extends TestCase
|
||||
->getJson('/api/admin/plans/' . $this->plan['data']['id'] . '/subscribers')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $user->id
|
||||
'id' => $user->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -124,7 +121,7 @@ class AdminPlansTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/invoices")
|
||||
->getJson('/api/admin/invoices')
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
@@ -141,7 +138,7 @@ class AdminPlansTest extends TestCase
|
||||
->getJson('/api/user/invoices')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
'customer' => $this->user['stripe_id'],
|
||||
]);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
@@ -172,7 +169,7 @@ class AdminPlansTest extends TestCase
|
||||
->getJson("/api/admin/users/$user->id/invoices")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
'customer' => $this->user['stripe_id'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -189,4 +186,4 @@ class AdminPlansTest extends TestCase
|
||||
->getJson('/api/admin/plans')
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Plans;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\User;
|
||||
|
||||
class PlansTest extends TestCase
|
||||
{
|
||||
@@ -36,17 +33,17 @@ class PlansTest extends TestCase
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => $plan_name,
|
||||
'price' => (string)rand(1, 99),
|
||||
'price' => (string) rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => $plan_name
|
||||
'name' => $plan_name,
|
||||
]);
|
||||
|
||||
$this->deleteJson("/api/admin/plans/" . strtolower($plan_name))
|
||||
$this->deleteJson('/api/admin/plans/' . strtolower($plan_name))
|
||||
->assertStatus(204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Plans;
|
||||
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SetupWizardPlansTest extends TestCase
|
||||
{
|
||||
@@ -20,7 +17,7 @@ class SetupWizardPlansTest extends TestCase
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => 'test-plan-' . Str::random(),
|
||||
'price' => (string)rand(1, 99),
|
||||
'price' => (string) rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
@@ -29,12 +26,12 @@ class SetupWizardPlansTest extends TestCase
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => 'test-plan-' . Str::random(),
|
||||
'price' => (string)rand(1, 99),
|
||||
'price' => (string) rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
])->assertStatus(204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Settings;
|
||||
|
||||
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\Setting;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
@@ -30,8 +27,8 @@ class SettingsTest extends TestCase
|
||||
$this->getJson('/api/content?column=get_started_title|pricing_description')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"get_started_title" => "Hello World!",
|
||||
"pricing_description" => "Give me a money!",
|
||||
'get_started_title' => 'Hello World!',
|
||||
'pricing_description' => 'Give me a money!',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -82,12 +79,12 @@ class SettingsTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/settings', [
|
||||
'name' => 'header_title',
|
||||
'value' => 'New Header Title'
|
||||
])->assertStatus(204);
|
||||
'name' => 'header_title',
|
||||
'value' => 'New Header Title',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'value' => 'New Header Title'
|
||||
'value' => 'New Header Title',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -112,12 +109,12 @@ class SettingsTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/settings', [
|
||||
'name' => 'app_logo',
|
||||
'app_logo' => $logo
|
||||
])->assertStatus(204);
|
||||
'name' => 'app_logo',
|
||||
'app_logo' => $logo,
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('settings', [
|
||||
'app_logo' => null
|
||||
'app_logo' => null,
|
||||
]);
|
||||
|
||||
Storage::assertExists(
|
||||
@@ -150,11 +147,11 @@ class SettingsTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/settings/stripe', [
|
||||
'currency' => 'EUR',
|
||||
'key' => '123456789',
|
||||
'secret' => '123456789',
|
||||
'webhookSecret' => '123456789',
|
||||
])->assertStatus(204);
|
||||
'currency' => 'EUR',
|
||||
'key' => '123456789',
|
||||
'secret' => '123456789',
|
||||
'webhookSecret' => '123456789',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'stripe_currency',
|
||||
@@ -183,12 +180,12 @@ class SettingsTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/settings/email', [
|
||||
'driver' => 'smtp',
|
||||
'host' => 'smtp.email.com',
|
||||
'port' => 25,
|
||||
'username' => 'john@doe.com',
|
||||
'password' => 'secret',
|
||||
'encryption' => 'tls',
|
||||
])->assertStatus(204);
|
||||
'driver' => 'smtp',
|
||||
'host' => 'smtp.email.com',
|
||||
'port' => 25,
|
||||
'username' => 'john@doe.com',
|
||||
'password' => 'secret',
|
||||
'encryption' => 'tls',
|
||||
])->assertStatus(204);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\SetupWizard;
|
||||
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class SetupServiceTest extends TestCase
|
||||
{
|
||||
@@ -41,7 +40,7 @@ class SetupServiceTest extends TestCase
|
||||
|
||||
Language::create([
|
||||
'name' => 'English',
|
||||
'locale' => 'en'
|
||||
'locale' => 'en',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('languages', [
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\SetupWizard;
|
||||
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SetupWizardTest extends TestCase
|
||||
{
|
||||
@@ -29,7 +28,7 @@ class SetupWizardTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->postJson('/api/setup/purchase-code', [
|
||||
'purchaseCode' => '8624194e-3156-4cd0-944e-3440fcecdacb'
|
||||
'purchaseCode' => '8624194e-3156-4cd0-944e-3440fcecdacb',
|
||||
])->assertStatus(204);
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ class SetupWizardTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->postJson('/api/setup/purchase-code', [
|
||||
'purchaseCode' => '8624194e-3156-4cd0-944e-3440fcecdacb'
|
||||
'purchaseCode' => '8624194e-3156-4cd0-944e-3440fcecdacb',
|
||||
])->assertStatus(400);
|
||||
}
|
||||
|
||||
@@ -128,7 +127,6 @@ class SetupWizardTest extends TestCase
|
||||
*/
|
||||
public function it_store_stripe_plans()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +194,6 @@ class SetupWizardTest extends TestCase
|
||||
|
||||
collect(['app_logo', 'app_logo_horizontal', 'app_favicon'])
|
||||
->each(function ($file) {
|
||||
|
||||
$path = get_setting($file);
|
||||
|
||||
$this->assertNotNull($path);
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use App\Notifications\SharedSendViaEmail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Domain\Sharing\Notifications\SharedSendViaEmail;
|
||||
|
||||
class UserShareTest extends TestCase
|
||||
{
|
||||
@@ -26,13 +25,13 @@ class UserShareTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$file->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'file',
|
||||
])->assertStatus(201)->assertJsonFragment([
|
||||
'item_id' => $file->id,
|
||||
'type' => 'file',
|
||||
]);
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'file',
|
||||
])->assertStatus(201)->assertJsonFragment([
|
||||
'item_id' => $file->id,
|
||||
'type' => 'file',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('shares', [
|
||||
'user_id' => $user->id,
|
||||
@@ -58,13 +57,13 @@ class UserShareTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
])->assertStatus(201)->assertJsonFragment([
|
||||
'item_id' => $folder->id,
|
||||
'type' => 'folder',
|
||||
]);
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
])->assertStatus(201)->assertJsonFragment([
|
||||
'item_id' => $folder->id,
|
||||
'type' => 'folder',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('shares', [
|
||||
'user_id' => $user->id,
|
||||
@@ -90,11 +89,11 @@ class UserShareTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => true,
|
||||
'password' => 'secret',
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
])
|
||||
'isPassword' => true,
|
||||
'password' => 'secret',
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'item_id' => $folder->id,
|
||||
@@ -128,11 +127,11 @@ class UserShareTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
'expiration' => 12,
|
||||
])
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
'expiration' => 12,
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'item_id' => $folder->id,
|
||||
@@ -154,14 +153,14 @@ class UserShareTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
'emails' => [
|
||||
'john@doe.com',
|
||||
'jane@doe.com',
|
||||
],
|
||||
])->assertStatus(201);
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
'emails' => [
|
||||
'john@doe.com',
|
||||
'jane@doe.com',
|
||||
],
|
||||
])->assertStatus(201);
|
||||
|
||||
Notification::assertTimesSent(2, SharedSendViaEmail::class);
|
||||
}
|
||||
@@ -216,14 +215,14 @@ class UserShareTest extends TestCase
|
||||
'type' => 'folder',
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->deleteJson("/api/share/revoke", [
|
||||
$this->deleteJson('/api/share/revoke', [
|
||||
'tokens' => [
|
||||
$folder->shared->token
|
||||
$folder->shared->token,
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('shares', [
|
||||
'item_id' => $folder->id
|
||||
'item_id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Str;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class VisitorAccessToItemsTest extends TestCase
|
||||
{
|
||||
@@ -29,7 +28,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
{
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -55,7 +53,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
]);
|
||||
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -66,8 +63,7 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
// Get shared file
|
||||
$this->get("/file/$document->name/$share->token")
|
||||
->assertStatus(200);
|
||||
@@ -102,7 +98,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
{
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -130,12 +125,11 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
]);
|
||||
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = [
|
||||
'share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])
|
||||
]),
|
||||
];
|
||||
|
||||
$this->withCookies($cookie)
|
||||
@@ -143,7 +137,7 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->get("/share/$share->token")
|
||||
->assertStatus(200);
|
||||
}
|
||||
@@ -157,7 +151,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
{
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -183,12 +176,11 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
|
||||
// Get thumbnail file
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = [
|
||||
'share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])
|
||||
]),
|
||||
];
|
||||
|
||||
$this->withCookies($cookie)
|
||||
@@ -196,7 +188,7 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->get("/thumbnail/$thumbnail->name/$share->token")
|
||||
->assertStatus(200);
|
||||
}
|
||||
@@ -215,7 +207,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
{
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -235,15 +226,14 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
$file = UploadedFile::fake()
|
||||
->create($zip->basename, 1000, 'application/zip');
|
||||
|
||||
Storage::putFileAs("zip", $file, $file->name);
|
||||
Storage::putFileAs('zip', $file, $file->name);
|
||||
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = [
|
||||
'share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])
|
||||
]),
|
||||
];
|
||||
|
||||
$this->withCookies($cookie)
|
||||
@@ -251,7 +241,7 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->get("/zip/$zip->id/$share->token")
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class VisitorBrowseTest extends TestCase
|
||||
{
|
||||
@@ -44,7 +43,7 @@ class VisitorBrowseTest extends TestCase
|
||||
'created_at' => $share->created_at->toJson(),
|
||||
'updated_at' => $share->updated_at->toJson(),
|
||||
],
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ class VisitorBrowseTest extends TestCase
|
||||
*/
|
||||
public function it_try_to_get_deleted_share_record()
|
||||
{
|
||||
$this->get("/api/browse/share/19ZMPNiass4ZqWwQ")
|
||||
$this->get('/api/browse/share/19ZMPNiass4ZqWwQ')
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
@@ -100,7 +99,7 @@ class VisitorBrowseTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->postJson("/api/browse/authenticate/$share->token", [
|
||||
'password' => 'secret'
|
||||
'password' => 'secret',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertCookie('share_session', json_encode([
|
||||
@@ -127,7 +126,7 @@ class VisitorBrowseTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->postJson("/api/browse/authenticate/$share->token", [
|
||||
'password' => 'bad-password'
|
||||
'password' => 'bad-password',
|
||||
])
|
||||
->assertStatus(401)
|
||||
->assertCookieMissing('share_session');
|
||||
@@ -141,7 +140,6 @@ class VisitorBrowseTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -164,7 +162,7 @@ class VisitorBrowseTest extends TestCase
|
||||
->create([
|
||||
'parent_id' => $root->id,
|
||||
'name' => 'Documents',
|
||||
"author" => "user",
|
||||
'author' => 'user',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
@@ -173,50 +171,49 @@ class VisitorBrowseTest extends TestCase
|
||||
'folder_id' => $root->id,
|
||||
'name' => 'Document',
|
||||
'basename' => 'document.pdf',
|
||||
"mimetype" => "application/pdf",
|
||||
"author" => "user",
|
||||
"type" => "file",
|
||||
'mimetype' => 'application/pdf',
|
||||
'author' => 'user',
|
||||
'type' => 'file',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$json = [
|
||||
[
|
||||
"id" => $folder->id,
|
||||
"user_id" => $user->id,
|
||||
"parent_id" => $root->id,
|
||||
"name" => "Documents",
|
||||
"color" => null,
|
||||
"emoji" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $folder->created_at,
|
||||
"updated_at" => $folder->updated_at->toJson(),
|
||||
"items" => 0,
|
||||
"trashed_items" => 0,
|
||||
"type" => "folder",
|
||||
'id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $root->id,
|
||||
'name' => 'Documents',
|
||||
'color' => null,
|
||||
'emoji' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $folder->created_at,
|
||||
'updated_at' => $folder->updated_at->toJson(),
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'type' => 'folder',
|
||||
],
|
||||
[
|
||||
"id" => $file->id,
|
||||
"user_id" => $user->id,
|
||||
"folder_id" => $root->id,
|
||||
"thumbnail" => null,
|
||||
"name" => "Document",
|
||||
"basename" => "document.pdf",
|
||||
"mimetype" => "application/pdf",
|
||||
"filesize" => $file->filesize,
|
||||
"type" => "file",
|
||||
"metadata" => null,
|
||||
"author" => "user",
|
||||
"deleted_at" => null,
|
||||
"created_at" => $file->created_at,
|
||||
"updated_at" => $file->updated_at->toJson(),
|
||||
"file_url" => "http://localhost/file/document.pdf/$share->token",
|
||||
]
|
||||
'id' => $file->id,
|
||||
'user_id' => $user->id,
|
||||
'folder_id' => $root->id,
|
||||
'thumbnail' => null,
|
||||
'name' => 'Document',
|
||||
'basename' => 'document.pdf',
|
||||
'mimetype' => 'application/pdf',
|
||||
'filesize' => $file->filesize,
|
||||
'type' => 'file',
|
||||
'metadata' => null,
|
||||
'author' => 'user',
|
||||
'deleted_at' => null,
|
||||
'created_at' => $file->created_at,
|
||||
'updated_at' => $file->updated_at->toJson(),
|
||||
'file_url' => "http://localhost/file/document.pdf/$share->token",
|
||||
],
|
||||
];
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -230,7 +227,7 @@ class VisitorBrowseTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/browse/folders/$root->id/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertExactJson($json);
|
||||
@@ -246,7 +243,6 @@ class VisitorBrowseTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -294,44 +290,43 @@ class VisitorBrowseTest extends TestCase
|
||||
$tree = [
|
||||
[
|
||||
'id' => $share->item_id,
|
||||
"name" => "Home",
|
||||
"location" => "public",
|
||||
"folders" => [
|
||||
'name' => 'Home',
|
||||
'location' => 'public',
|
||||
'folders' => [
|
||||
[
|
||||
"id" => $folder_level_2->id,
|
||||
"parent_id" => $folder_level_1->id,
|
||||
"name" => "level 2",
|
||||
"items" => 1,
|
||||
"trashed_items" => 1,
|
||||
"type" => "folder",
|
||||
"folders" => [
|
||||
'id' => $folder_level_2->id,
|
||||
'parent_id' => $folder_level_1->id,
|
||||
'name' => 'level 2',
|
||||
'items' => 1,
|
||||
'trashed_items' => 1,
|
||||
'type' => 'folder',
|
||||
'folders' => [
|
||||
[
|
||||
"id" => $folder_level_3->id,
|
||||
"parent_id" => $folder_level_2->id,
|
||||
"name" => "level 3",
|
||||
"items" => 0,
|
||||
"trashed_items" => 0,
|
||||
"type" => "folder",
|
||||
"folders" => [],
|
||||
'id' => $folder_level_3->id,
|
||||
'parent_id' => $folder_level_2->id,
|
||||
'name' => 'level 3',
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'type' => 'folder',
|
||||
'folders' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
"id" => $folder_level_2_sibling->id,
|
||||
"parent_id" => $folder_level_1->id,
|
||||
"name" => "level 2 Sibling",
|
||||
"items" => 0,
|
||||
"trashed_items" => 0,
|
||||
"type" => "folder",
|
||||
"folders" => []
|
||||
]
|
||||
]
|
||||
]
|
||||
'id' => $folder_level_2_sibling->id,
|
||||
'parent_id' => $folder_level_1->id,
|
||||
'name' => 'level 2 Sibling',
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'type' => 'folder',
|
||||
'folders' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -345,8 +340,7 @@ class VisitorBrowseTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/browse/navigation/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertExactJson($tree);
|
||||
@@ -362,7 +356,6 @@ class VisitorBrowseTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create();
|
||||
|
||||
@@ -385,7 +378,6 @@ class VisitorBrowseTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -395,17 +387,16 @@ class VisitorBrowseTest extends TestCase
|
||||
->get("/api/browse/search/$share->token?query=doc")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/browse/search/$share->token?query=doc")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
});
|
||||
@@ -419,7 +410,6 @@ class VisitorBrowseTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create();
|
||||
|
||||
@@ -441,7 +431,6 @@ class VisitorBrowseTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -454,8 +443,7 @@ class VisitorBrowseTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/browse/search/$share->token?query=doc")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([]);
|
||||
@@ -471,7 +459,6 @@ class VisitorBrowseTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$file = File::factory(File::class)
|
||||
->create([
|
||||
'name' => 'Document',
|
||||
@@ -489,7 +476,6 @@ class VisitorBrowseTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -499,16 +485,16 @@ class VisitorBrowseTest extends TestCase
|
||||
->get("/api/browse/file/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Document'
|
||||
'name' => 'Document',
|
||||
]);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/browse/file/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Document'
|
||||
'name' => 'Document',
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
|
||||
class VisitorManipulatingTest extends TestCase
|
||||
{
|
||||
@@ -27,18 +26,17 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$file = File::factory(File::class)
|
||||
->create([
|
||||
'folder_id' => $folder->id
|
||||
'folder_id' => $folder->id,
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
@@ -52,7 +50,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -71,7 +68,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->patchJson("/api/editor/rename/{$file->id}/$share->token", [
|
||||
'name' => 'Renamed Item',
|
||||
'type' => 'file',
|
||||
@@ -97,19 +94,18 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$children = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $root->id
|
||||
'parent_id' => $root->id,
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
@@ -123,7 +119,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -142,8 +137,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->patchJson("/api/editor/rename/{$children->id}/$share->token", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
@@ -156,7 +150,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'name' => 'Renamed Folder',
|
||||
'id' => $children->id
|
||||
'id' => $children->id,
|
||||
]);
|
||||
});
|
||||
}
|
||||
@@ -169,7 +163,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -189,7 +182,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -208,8 +200,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/editor/create-folder/$share->token", [
|
||||
'name' => 'Awesome New Folder',
|
||||
'parent_id' => $folder->id,
|
||||
@@ -236,7 +227,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -257,7 +247,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
$files = File::factory(File::class)
|
||||
->count(2)
|
||||
->create([
|
||||
'folder_id' => $folder->id
|
||||
'folder_id' => $folder->id,
|
||||
]);
|
||||
|
||||
$payload = [
|
||||
@@ -277,7 +267,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -290,8 +279,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/editor/remove/$share->token", $payload)
|
||||
->assertStatus(204);
|
||||
}
|
||||
@@ -313,7 +301,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -337,7 +324,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -354,8 +340,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/editor/upload/$share->token", [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
@@ -387,13 +372,12 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$children = Folder::factory(Folder::class)
|
||||
@@ -405,7 +389,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
$file = File::factory(File::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'folder_id' => $root->id
|
||||
'folder_id' => $root->id,
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
@@ -423,13 +407,12 @@ class VisitorManipulatingTest extends TestCase
|
||||
[
|
||||
'type' => 'file',
|
||||
'id' => $file->id,
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -442,8 +425,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/editor/move/$share->token", $payload)
|
||||
->assertStatus(204);
|
||||
}
|
||||
@@ -463,13 +445,12 @@ class VisitorManipulatingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$brother = Folder::factory(Folder::class)
|
||||
@@ -499,13 +480,12 @@ class VisitorManipulatingTest extends TestCase
|
||||
[
|
||||
'type' => 'folder',
|
||||
'id' => $sister->id,
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -518,8 +498,7 @@ class VisitorManipulatingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/editor/move/$share->token", $payload)
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Subscriptions;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\User;
|
||||
|
||||
class AdminSubscriptionTest extends TestCase
|
||||
{
|
||||
@@ -20,12 +17,12 @@ class AdminSubscriptionTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
@@ -35,22 +32,22 @@ class AdminSubscriptionTest extends TestCase
|
||||
->getJson("/api/admin/users/$user->id/subscription")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"data" => [
|
||||
"id" => "business-pack",
|
||||
"type" => "subscription",
|
||||
"attributes" => [
|
||||
"incomplete" => false,
|
||||
"active" => true,
|
||||
"canceled" => false,
|
||||
"name" => "Business Packs",
|
||||
"capacity" => 1000,
|
||||
"capacity_formatted" => "1TB",
|
||||
"slug" => "business-pack",
|
||||
"canceled_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"created_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"ends_at" => format_date(now()->addMonth(), '%d. %B. %Y'),
|
||||
]
|
||||
]
|
||||
'data' => [
|
||||
'id' => 'business-pack',
|
||||
'type' => 'subscription',
|
||||
'attributes' => [
|
||||
'incomplete' => false,
|
||||
'active' => true,
|
||||
'canceled' => false,
|
||||
'name' => 'Business Packs',
|
||||
'capacity' => 1000,
|
||||
'capacity_formatted' => '1TB',
|
||||
'slug' => 'business-pack',
|
||||
'canceled_at' => format_date(now(), '%d. %B. %Y'),
|
||||
'created_at' => format_date(now(), '%d. %B. %Y'),
|
||||
'ends_at' => format_date(now()->addMonth(), '%d. %B. %Y'),
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Subscriptions;
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\User;
|
||||
|
||||
class SubscriptionTest extends TestCase
|
||||
{
|
||||
@@ -30,15 +28,15 @@ class SubscriptionTest extends TestCase
|
||||
// Define test plan to subscribe
|
||||
$this->plan = [
|
||||
'data' => [
|
||||
'id' => "business-pack",
|
||||
'type' => "plans",
|
||||
'id' => 'business-pack',
|
||||
'type' => 'plans',
|
||||
'attributes' => [
|
||||
'name' => "Business Packs",
|
||||
'description' => "When your business start grow up.",
|
||||
'price' => "$44.99",
|
||||
'name' => 'Business Packs',
|
||||
'description' => 'When your business start grow up.',
|
||||
'price' => '$44.99',
|
||||
'capacity' => 1000,
|
||||
'capacity_formatted' => "1TB",
|
||||
'currency' => "USD",
|
||||
'capacity_formatted' => '1TB',
|
||||
'currency' => 'USD',
|
||||
'tax_rates' => [],
|
||||
],
|
||||
],
|
||||
@@ -69,7 +67,7 @@ class SubscriptionTest extends TestCase
|
||||
->getJson('/api/user/subscription/setup-intent')
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
"object" => "setup_intent"
|
||||
'object' => 'setup_intent',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
@@ -88,19 +86,19 @@ class SubscriptionTest extends TestCase
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('subscriptions', [
|
||||
'stripe_status' => 'active'
|
||||
'stripe_status' => 'active',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'storage_capacity' => 1000
|
||||
'storage_capacity' => 1000,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -126,7 +124,7 @@ class SubscriptionTest extends TestCase
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('subscriptions', [
|
||||
'ends_at' => null
|
||||
'ends_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -155,7 +153,7 @@ class SubscriptionTest extends TestCase
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('subscriptions', [
|
||||
'ends_at' => null
|
||||
'ends_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -180,22 +178,22 @@ class SubscriptionTest extends TestCase
|
||||
$this->getJson('/api/user/subscription')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"data" => [
|
||||
"id" => "business-pack",
|
||||
"type" => "subscription",
|
||||
"attributes" => [
|
||||
"incomplete" => false,
|
||||
"active" => true,
|
||||
"canceled" => false,
|
||||
"name" => "Business Packs",
|
||||
"capacity" => 1000,
|
||||
"capacity_formatted" => "1TB",
|
||||
"slug" => "business-pack",
|
||||
"canceled_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"created_at" => format_date(now(), '%d. %B. %Y'),
|
||||
"ends_at" => format_date(now()->addMonth(), '%d. %B. %Y'),
|
||||
]
|
||||
]
|
||||
'data' => [
|
||||
'id' => 'business-pack',
|
||||
'type' => 'subscription',
|
||||
'attributes' => [
|
||||
'incomplete' => false,
|
||||
'active' => true,
|
||||
'canceled' => false,
|
||||
'name' => 'Business Packs',
|
||||
'capacity' => 1000,
|
||||
'capacity_formatted' => '1TB',
|
||||
'slug' => 'business-pack',
|
||||
'canceled_at' => format_date(now(), '%d. %B. %Y'),
|
||||
'created_at' => format_date(now(), '%d. %B. %Y'),
|
||||
'ends_at' => format_date(now()->addMonth(), '%d. %B. %Y'),
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Trash;
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
|
||||
class TrashTest extends TestCase
|
||||
{
|
||||
@@ -34,25 +32,25 @@ class TrashTest extends TestCase
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/trash/restore", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $file->id,
|
||||
'type' => 'file',
|
||||
->postJson('/api/trash/restore', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $file->id,
|
||||
'type' => 'file',
|
||||
],
|
||||
[
|
||||
'id' => $folder->id,
|
||||
'type' => 'folder',
|
||||
],
|
||||
],
|
||||
[
|
||||
'id' => $folder->id,
|
||||
'type' => 'folder',
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('files', [
|
||||
'deleted_at' => null
|
||||
'deleted_at' => null,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'deleted_at' => null
|
||||
'deleted_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -68,7 +66,7 @@ class TrashTest extends TestCase
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$image = UploadedFile::fake()
|
||||
@@ -83,7 +81,7 @@ class TrashTest extends TestCase
|
||||
|
||||
$file = File::first();
|
||||
|
||||
$this->postJson("/api/remove", [
|
||||
$this->postJson('/api/remove', [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $file->id,
|
||||
@@ -98,15 +96,15 @@ class TrashTest extends TestCase
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->deleteJson("/api/trash/dump")
|
||||
$this->deleteJson('/api/trash/dump')
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('files', [
|
||||
'id' => $file->id
|
||||
'id' => $file->id,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('folders', [
|
||||
'id' => $folder->id
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Zipping;
|
||||
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Str;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
|
||||
class SharedZippingTest extends TestCase
|
||||
{
|
||||
@@ -24,18 +20,16 @@ class SharedZippingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder, $user) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create(Str::random() . "-fake-file-$index.pdf", 1000, 'application/pdf');
|
||||
|
||||
@@ -61,7 +55,6 @@ class SharedZippingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -70,14 +63,14 @@ class SharedZippingTest extends TestCase
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->post("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
'items' => File::all()->pluck('id'),
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
'items' => File::all()->pluck('id'),
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
@@ -86,7 +79,7 @@ class SharedZippingTest extends TestCase
|
||||
'shared_token' => $share->token,
|
||||
]);
|
||||
|
||||
Storage::assertExists("zip/" . Zip::first()->basename);
|
||||
Storage::assertExists('zip/' . Zip::first()->basename);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,13 +91,12 @@ class SharedZippingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
@@ -128,7 +120,6 @@ class SharedZippingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -137,14 +128,14 @@ class SharedZippingTest extends TestCase
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->post("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
'items' => File::all()->pluck('id'),
|
||||
])->assertStatus(403);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->postJson("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
'items' => File::all()->pluck('id'),
|
||||
])->assertStatus(403);
|
||||
}
|
||||
});
|
||||
@@ -158,24 +149,22 @@ class SharedZippingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$children = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'parent_id' => $root->id
|
||||
'parent_id' => $root->id,
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($children, $user) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create(Str::random() . "-fake-file-$index.pdf", 1000, 'application/pdf');
|
||||
|
||||
@@ -201,7 +190,6 @@ class SharedZippingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -214,7 +202,7 @@ class SharedZippingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/zip/folder/$children->id/$share->token")
|
||||
->assertStatus(201);
|
||||
}
|
||||
@@ -239,13 +227,12 @@ class SharedZippingTest extends TestCase
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
@@ -257,7 +244,6 @@ class SharedZippingTest extends TestCase
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
@@ -270,10 +256,10 @@ class SharedZippingTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
if (! $is_protected) {
|
||||
$this->getJson("/api/zip/folder/$folder->id/$share->token")
|
||||
->assertStatus(403);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Zipping;
|
||||
|
||||
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Folder;
|
||||
|
||||
class UserZippingTest extends TestCase
|
||||
{
|
||||
@@ -28,7 +24,6 @@ class UserZippingTest extends TestCase
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
@@ -42,12 +37,12 @@ class UserZippingTest extends TestCase
|
||||
|
||||
$file_ids = File::all()->pluck('id');
|
||||
|
||||
$this->postJson("/api/zip/files", [
|
||||
$this->postJson('/api/zip/files', [
|
||||
'items' => $file_ids,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
@@ -68,12 +63,11 @@ class UserZippingTest extends TestCase
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
@@ -89,7 +83,7 @@ class UserZippingTest extends TestCase
|
||||
->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
@@ -97,4 +91,4 @@ class UserZippingTest extends TestCase
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support\Scheduler;
|
||||
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\SetupWizard\Services\SchedulerService;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\SetupWizard\Services\SchedulerService;
|
||||
|
||||
class SchedulerTest extends TestCase
|
||||
{
|
||||
@@ -20,7 +18,7 @@ class SchedulerTest extends TestCase
|
||||
{
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'expire_in' => 24,
|
||||
'expire_in' => 24,
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
@@ -28,7 +26,7 @@ class SchedulerTest extends TestCase
|
||||
->delete_expired_shared_links();
|
||||
|
||||
$this->assertDatabaseMissing('shares', [
|
||||
'id' => $share->id
|
||||
'id' => $share->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -51,7 +49,7 @@ class SchedulerTest extends TestCase
|
||||
->delete_old_zips();
|
||||
|
||||
$this->assertDatabaseMissing('zips', [
|
||||
'id' => $zip->id
|
||||
'id' => $zip->id,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
@@ -69,7 +67,7 @@ class SchedulerTest extends TestCase
|
||||
->create('fake-file.zip', 2000, 'application/zip');
|
||||
|
||||
collect(['chunks'])
|
||||
->each(function ($folder) use ($file){
|
||||
->each(function ($folder) use ($file) {
|
||||
Storage::putFileAs($folder, $file, 'fake-file.zip');
|
||||
});
|
||||
|
||||
@@ -81,7 +79,6 @@ class SchedulerTest extends TestCase
|
||||
Storage::disk('local')
|
||||
->assertMissing("$folder/fake-file.zip");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,19 +89,19 @@ class SchedulerTest extends TestCase
|
||||
$expiredUser = User::factory(User::class)
|
||||
->create([
|
||||
'email_verified_at' => null,
|
||||
'created_at' => now()->subDays(31)
|
||||
'created_at' => now()->subDays(31),
|
||||
]);
|
||||
|
||||
$nonExpiredUser = User::factory(User::class)
|
||||
->create([
|
||||
'email_verified_at' => null,
|
||||
'created_at' => now()->subDays(14)
|
||||
'created_at' => now()->subDays(14),
|
||||
]);
|
||||
|
||||
$verifiedUser = User::factory(User::class)
|
||||
->create([
|
||||
'email_verified_at' => now()->subDays(15),
|
||||
'created_at' => now()->subDays(31)
|
||||
'created_at' => now()->subDays(31),
|
||||
]);
|
||||
|
||||
resolve(SchedulerService::class)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user