mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
unit test fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Browsing;
|
||||
|
||||
use Tests\TestCase;
|
||||
@@ -59,8 +60,8 @@ class BrowseTest extends TestCase
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
'name' => 'Files',
|
||||
'folders' => [
|
||||
'name' => 'Files',
|
||||
'folders' => [
|
||||
[
|
||||
'id' => $folder_level_1->id,
|
||||
'parent_id' => null,
|
||||
@@ -109,8 +110,8 @@ class BrowseTest extends TestCase
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'Team Folders',
|
||||
'folders' => [],
|
||||
'name' => 'Team Folders',
|
||||
'folders' => [],
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -152,55 +153,14 @@ class BrowseTest extends TestCase
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/folders/$root->id")
|
||||
->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',
|
||||
],
|
||||
'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',
|
||||
],
|
||||
'shared' => null,
|
||||
],
|
||||
->assertJsonFragment([
|
||||
'id' => $root->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -248,55 +208,11 @@ class BrowseTest extends TestCase
|
||||
->actingAs($user)
|
||||
->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_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',
|
||||
],
|
||||
],
|
||||
->assertJsonFragment([
|
||||
'id' => $file_1->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $file_2->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -340,41 +256,11 @@ class BrowseTest extends TestCase
|
||||
->actingAs($user)
|
||||
->getJson('/api/browse/trash/undefined')
|
||||
->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' => $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,
|
||||
],
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -398,24 +284,28 @@ class BrowseTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
collect([$folder, $file])
|
||||
->each(function ($item) use ($user) {
|
||||
Share::factory(Share::class)
|
||||
->create([
|
||||
'type' => $item->type === 'folder' ? 'folder' : 'file',
|
||||
'item_id' => $item->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
});
|
||||
Share::factory(Share::class)
|
||||
->create([
|
||||
'type' => 'folder',
|
||||
'item_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
collect([$folder, $file])
|
||||
->each(function ($item) {
|
||||
$this->getJson('/api/browse/share')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $item->id,
|
||||
]);
|
||||
});
|
||||
Share::factory(Share::class)
|
||||
->create([
|
||||
'type' => 'file',
|
||||
'item_id' => $file->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->getJson('/api/browse/share')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use Tests\TestCase;
|
||||
@@ -26,13 +27,13 @@ class VisitorBrowseTest extends TestCase
|
||||
'id' => $share->id,
|
||||
'type' => 'shared',
|
||||
'attributes' => [
|
||||
'permission' => $share->permission,
|
||||
'protected' => false,
|
||||
'item_id' => $share->item_id,
|
||||
'expire_in' => $share->expire_in,
|
||||
'token' => $share->token,
|
||||
'link' => $share->link,
|
||||
'type' => $share->type,
|
||||
'permission' => $share->permission,
|
||||
'protected' => false,
|
||||
'item_id' => $share->item_id,
|
||||
'expire_in' => $share->expire_in,
|
||||
'token' => $share->token,
|
||||
'link' => $share->link,
|
||||
'type' => $share->type,
|
||||
],
|
||||
],
|
||||
]);
|
||||
@@ -168,41 +169,6 @@ class VisitorBrowseTest extends TestCase
|
||||
'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' => $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([
|
||||
@@ -214,14 +180,24 @@ class VisitorBrowseTest extends TestCase
|
||||
->withUnencryptedCookies($cookie)
|
||||
->get("/api/browse/folders/$root->id/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertExactJson($json);
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (! $is_protected) {
|
||||
if (!$is_protected) {
|
||||
$this->getJson("/api/browse/folders/$root->id/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertExactJson($json);
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id,
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -328,7 +304,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);
|
||||
@@ -380,7 +356,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([
|
||||
@@ -431,7 +407,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([]);
|
||||
@@ -478,7 +454,7 @@ class VisitorBrowseTest extends TestCase
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (! $is_protected) {
|
||||
if (!$is_protected) {
|
||||
$this->getJson("/api/browse/file/$share->token")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
|
||||
Reference in New Issue
Block a user