mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
deleted pro code
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\App\Restrictions;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Domain\Settings\Models\Setting;
|
||||
|
||||
class RestrictionsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_metered_driver()
|
||||
{
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'subscription_type',
|
||||
], [
|
||||
'value' => 'metered',
|
||||
]);
|
||||
|
||||
$this->assertEquals('metered', get_restriction_driver());
|
||||
}
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_fixed_driver()
|
||||
{
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'subscription_type',
|
||||
], [
|
||||
'value' => 'fixed',
|
||||
]);
|
||||
|
||||
$this->assertEquals('fixed', get_restriction_driver());
|
||||
}
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_default_driver()
|
||||
{
|
||||
$subscriptionType = Setting::where('name', 'subscription_type')
|
||||
->first();
|
||||
|
||||
$subscriptionType?->delete();
|
||||
|
||||
$this->assertEquals('default', get_restriction_driver());
|
||||
}
|
||||
}
|
||||
@@ -15,239 +15,6 @@ use App\Users\Notifications\RegistrationBonusAddedNotification;
|
||||
|
||||
class SignFlowTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_create_user_from_register_form()
|
||||
{
|
||||
collect([
|
||||
[
|
||||
'name' => 'user_verification',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'default_max_storage_amount',
|
||||
'value' => 10,
|
||||
],
|
||||
])->each(function ($setting) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $setting['name'],
|
||||
], [
|
||||
'value' => $setting['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
$this->postJson('api/register', [
|
||||
'role' => 'admin',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'SecretPassword',
|
||||
'password_confirmation' => 'SecretPassword',
|
||||
'name' => 'John Doe',
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com',
|
||||
'email_verified_at' => null,
|
||||
'role' => 'user',
|
||||
])
|
||||
->assertDatabaseHas('user_settings', [
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
])
|
||||
->assertDatabaseHas('user_limitations', [
|
||||
'max_storage_amount' => 10,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists('files/' . User::first()->id);
|
||||
|
||||
Notification::assertTimesSent(1, VerifyEmail::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_register_user_when_metered_billing_is_active()
|
||||
{
|
||||
// Seed default settings
|
||||
collect([
|
||||
[
|
||||
'name' => 'subscription_type',
|
||||
'value' => 'metered',
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_registration_bonus',
|
||||
'value' => 0,
|
||||
],
|
||||
[
|
||||
'name' => 'registration_bonus_amount',
|
||||
'value' => 15,
|
||||
],
|
||||
])->each(function ($setting) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $setting['name'],
|
||||
], [
|
||||
'value' => $setting['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Create metered plan
|
||||
$plan = Plan::factory()
|
||||
->create([
|
||||
'status' => 'active',
|
||||
'type' => 'metered',
|
||||
'currency' => 'USD',
|
||||
]);
|
||||
|
||||
$this->postJson('api/register', [
|
||||
'role' => 'admin',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'SecretPassword',
|
||||
'password_confirmation' => 'SecretPassword',
|
||||
'name' => 'John Doe',
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseCount('transactions', 0)
|
||||
->assertDatabaseHas('users', [
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
])
|
||||
->assertDatabaseHas('subscriptions', [
|
||||
'status' => 'active',
|
||||
'name' => $plan->name,
|
||||
'ends_at' => null,
|
||||
'renews_at' => now()->addDays(config('subscription.metered_billing.settlement_period')),
|
||||
])
|
||||
->assertDatabaseHas('balances', [
|
||||
'currency' => 'USD',
|
||||
'amount' => 0,
|
||||
])
|
||||
->assertDatabaseHas('user_settings', [
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_register_user_when_metered_billing_is_active_with_registration_bonus()
|
||||
{
|
||||
// Seed default settings
|
||||
collect([
|
||||
[
|
||||
'name' => 'subscription_type',
|
||||
'value' => 'metered',
|
||||
],
|
||||
[
|
||||
'name' => 'allowed_registration_bonus',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'registration_bonus_amount',
|
||||
'value' => 15,
|
||||
],
|
||||
])->each(function ($setting) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $setting['name'],
|
||||
], [
|
||||
'value' => $setting['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Create metered plan
|
||||
$plan = Plan::factory()
|
||||
->create([
|
||||
'status' => 'active',
|
||||
'type' => 'metered',
|
||||
'currency' => 'USD',
|
||||
]);
|
||||
|
||||
$this->postJson('api/register', [
|
||||
'role' => 'admin',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'SecretPassword',
|
||||
'password_confirmation' => 'SecretPassword',
|
||||
'name' => 'John Doe',
|
||||
])->assertStatus(201);
|
||||
|
||||
$user = User::first();
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('users', [
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
])
|
||||
->assertDatabaseHas('subscriptions', [
|
||||
'status' => 'active',
|
||||
'name' => $plan->name,
|
||||
'ends_at' => null,
|
||||
'renews_at' => now()->addDays(config('subscription.metered_billing.settlement_period')),
|
||||
])
|
||||
->assertDatabaseHas('balances', [
|
||||
'currency' => 'USD',
|
||||
'amount' => 15,
|
||||
])
|
||||
->assertDatabaseHas('transactions', [
|
||||
'user_id' => $user->id,
|
||||
'amount' => 15.00,
|
||||
'currency' => 'USD',
|
||||
'status' => 'completed',
|
||||
'type' => 'credit',
|
||||
'driver' => 'system',
|
||||
])
|
||||
->assertDatabaseHas('user_settings', [
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
]);
|
||||
|
||||
Notification::assertSentTo($user, RegistrationBonusAddedNotification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_try_register_when_registration_is_disabled()
|
||||
{
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'registration',
|
||||
], [
|
||||
'value' => 0,
|
||||
]);
|
||||
|
||||
$this->postJson('api/register', [
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'SecretPassword',
|
||||
'password_confirmation' => 'SecretPassword',
|
||||
'name' => 'John Doe',
|
||||
])->assertStatus(401);
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
'email' => 'john@doe.com',
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_try_register_from_disabled_email_provider()
|
||||
{
|
||||
$this->postJson('api/register', [
|
||||
'email' => 'john@maildrop.cc',
|
||||
'password' => 'SecretPassword',
|
||||
'password_confirmation' => 'SecretPassword',
|
||||
'name' => 'John Doe',
|
||||
])->assertStatus(422);
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
'email' => 'john@doe.com',
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -339,33 +106,4 @@ class SignFlowTest extends TestCase
|
||||
'email' => $user->email,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_create_user_from_register_form_with_reCaptcha()
|
||||
{
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'allowed_recaptcha',
|
||||
], [
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
$this->mock(ReCaptchaRules::class, function ($mock) {
|
||||
$mock->shouldReceive('passes')->andReturn(true);
|
||||
});
|
||||
|
||||
$this->postJson('api/register', [
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'SecretPassword',
|
||||
'password_confirmation' => 'SecretPassword',
|
||||
'name' => 'John Doe',
|
||||
'reCaptcha' => 'fakeToken',
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,16 +170,11 @@ class UserAccountTest extends TestCase
|
||||
'meta' => [
|
||||
'restrictions' => [
|
||||
'canCreateFolder' => true,
|
||||
'canCreateTeamFolder' => true,
|
||||
'canDownload' => true,
|
||||
'canInviteTeamMembers' => true,
|
||||
'canUpload' => true,
|
||||
],
|
||||
],
|
||||
'relationships' => [
|
||||
'creditCards' => [
|
||||
'data' => [],
|
||||
],
|
||||
'settings' => [
|
||||
'data' => [
|
||||
'id' => (string) $user->id,
|
||||
@@ -202,12 +197,6 @@ class UserAccountTest extends TestCase
|
||||
'favourites' => [
|
||||
'data' => [],
|
||||
],
|
||||
'readNotifications' => [
|
||||
'data' => [],
|
||||
],
|
||||
'unreadNotifications' => [
|
||||
'data' => [],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -77,24 +77,6 @@ class AdminTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* todo: complete test
|
||||
*/
|
||||
public function it_get_non_existed_user_subscription()
|
||||
{
|
||||
$user = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/users/$user->id/subscription")
|
||||
->assertStatus(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
@@ -25,14 +25,12 @@ class DashboardTest extends TestCase
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'app' => [
|
||||
'earnings' => '$0.00',
|
||||
'isRunningCron' => false,
|
||||
'license' => 'extended',
|
||||
'license' => 'regular',
|
||||
'version' => config('vuefilemanager.version'),
|
||||
],
|
||||
'users' => [
|
||||
'total' => 1,
|
||||
'usersPremiumTotal' => 0,
|
||||
],
|
||||
'used' => '2.00MB',
|
||||
]);
|
||||
|
||||
@@ -69,7 +69,6 @@ class BrowseTest extends TestCase
|
||||
'name' => 'level 1',
|
||||
'items' => 2,
|
||||
'trashed_items' => 2,
|
||||
'team_folder' => false,
|
||||
'folders' => [
|
||||
[
|
||||
'id' => $folder_level_2->id,
|
||||
@@ -77,7 +76,6 @@ class BrowseTest extends TestCase
|
||||
'name' => 'level 2',
|
||||
'items' => 1,
|
||||
'trashed_items' => 1,
|
||||
'team_folder' => false,
|
||||
'folders' => [
|
||||
[
|
||||
'id' => $folder_level_3->id,
|
||||
@@ -92,7 +90,6 @@ class BrowseTest extends TestCase
|
||||
'updated_at' => $folder_level_3->updated_at->toJson(),
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'team_folder' => false,
|
||||
'folders' => [],
|
||||
],
|
||||
],
|
||||
@@ -103,7 +100,6 @@ class BrowseTest extends TestCase
|
||||
'name' => 'level 2 Sibling',
|
||||
'items' => 0,
|
||||
'trashed_items' => 0,
|
||||
'team_folder' => false,
|
||||
'folders' => [],
|
||||
],
|
||||
],
|
||||
@@ -112,20 +108,6 @@ class BrowseTest extends TestCase
|
||||
'isMovable' => true,
|
||||
'isOpen' => true,
|
||||
],
|
||||
[
|
||||
'location' => 'team-folders',
|
||||
'name' => 'Team Folders',
|
||||
'folders' => [],
|
||||
'isMovable' => false,
|
||||
'isOpen' => false,
|
||||
],
|
||||
[
|
||||
'location' => 'shared-with-me',
|
||||
'name' => 'Shared with Me',
|
||||
'folders' => [],
|
||||
'isMovable' => false,
|
||||
'isOpen' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,60 +105,6 @@ class FileTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_remotely_upload_new_file()
|
||||
{
|
||||
Event::fake([
|
||||
RemoteFileCreatedEvent::class,
|
||||
]);
|
||||
|
||||
$user = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$fakeFile = UploadedFile::fake()
|
||||
->create('top-secret-document.pdf', 12000000, 'application/pdf');
|
||||
|
||||
Http::fake([
|
||||
'https://fake.com/top-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
'https://fake.com/another-secret-document.pdf' => Http::response($fakeFile->getContent()),
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload/remote', [
|
||||
'urls' => [
|
||||
'https://fake.com/top-secret-document.pdf',
|
||||
'https://fake.com/another-secret-document.pdf',
|
||||
],
|
||||
'parent_id' => $folder->id,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('files', [
|
||||
'user_id' => $user->id,
|
||||
'name' => 'top-secret-document',
|
||||
'parent_id' => $folder->id,
|
||||
])
|
||||
->assertDatabaseHas('files', [
|
||||
'name' => 'another-secret-document',
|
||||
]);
|
||||
|
||||
File::all()
|
||||
->each(function ($file) {
|
||||
Event::assertDispatched(fn (RemoteFileCreatedEvent $event) => $event->payload['file']->id === $file->id);
|
||||
|
||||
Storage::assertExists("files/$file->user_id/$file->basename");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
<?php
|
||||
namespace Tests\Domain\Homepage;
|
||||
|
||||
use Mail;
|
||||
use Tests\TestCase;
|
||||
use App\Users\Models\User;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Homepage\Mail\SendContactMessage;
|
||||
use Domain\Pages\Actions\SeedDefaultPagesAction;
|
||||
use Domain\Settings\Actions\SeedDefaultSettingsAction;
|
||||
|
||||
class HomepageTest extends TestCase
|
||||
@@ -19,9 +16,7 @@ class HomepageTest extends TestCase
|
||||
*/
|
||||
public function it_get_index_page()
|
||||
{
|
||||
resolve(SeedDefaultPagesAction::class)();
|
||||
|
||||
resolve(SeedDefaultSettingsAction::class)('Extended');
|
||||
resolve(SeedDefaultSettingsAction::class)();
|
||||
|
||||
Setting::create([
|
||||
'name' => 'setup_wizard_success',
|
||||
@@ -136,25 +131,4 @@ class HomepageTest extends TestCase
|
||||
->assertStatus(200)
|
||||
->assertSee('This link is protected by password');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_send_contact_form()
|
||||
{
|
||||
Mail::fake();
|
||||
|
||||
Setting::create([
|
||||
'name' => 'contact_email',
|
||||
'value' => 'jane@doe.com',
|
||||
]);
|
||||
|
||||
$this->postJson('/api/contact', [
|
||||
'email' => 'john@doe.com',
|
||||
'message' => 'Whaats is up!',
|
||||
])
|
||||
->assertStatus(201);
|
||||
|
||||
Mail::assertSent(SendContactMessage::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ use Tests\TestCase;
|
||||
use App\Users\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Domain\Settings\Actions\SeedDefaultSettingsAction;
|
||||
use Domain\Localization\Actions\SeedDefaultLanguageAction;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
@@ -40,7 +38,7 @@ class SettingsTest extends TestCase
|
||||
*/
|
||||
public function it_get_admin_settings()
|
||||
{
|
||||
resolve(SeedDefaultSettingsAction::class)('Extended');
|
||||
resolve(SeedDefaultSettingsAction::class)();
|
||||
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
@@ -74,7 +72,7 @@ class SettingsTest extends TestCase
|
||||
*/
|
||||
public function it_update_settings()
|
||||
{
|
||||
resolve(SeedDefaultSettingsAction::class)('Extended');
|
||||
resolve(SeedDefaultSettingsAction::class)();
|
||||
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
@@ -137,50 +135,6 @@ class SettingsTest extends TestCase
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_store_payment_service_credentials()
|
||||
{
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->post('/api/admin/settings/payment-service', [
|
||||
'service' => 'stripe',
|
||||
'key' => '123456789',
|
||||
'secret' => '123456789',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'allowed_stripe',
|
||||
'value' => '1',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_store_social_service_credentials()
|
||||
{
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->post('/api/admin/settings/social-service', [
|
||||
'client_id' => '123456789',
|
||||
'client_secret' => '123456789',
|
||||
'service' => 'facebook',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'allowed_facebook',
|
||||
'value' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -222,85 +176,4 @@ class SettingsTest extends TestCase
|
||||
],
|
||||
])->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_broadcast()
|
||||
{
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/settings/broadcast', [
|
||||
'driver' => 'pusher',
|
||||
'id' => '123',
|
||||
'key' => '123456',
|
||||
'secret' => 'mOoiofnssddf',
|
||||
'cluster' => 'eu',
|
||||
'port' => null,
|
||||
'host' => null,
|
||||
])->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_upgrade_license()
|
||||
{
|
||||
Http::fake([
|
||||
'https://verify.vuefilemanager.com/api/verify-code/*' => Http::response('b6896a44017217c36f4a6fdc56699728'),
|
||||
]);
|
||||
|
||||
collect([
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => 'regular',
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => '22b28b36-6d84-41b2-a920-a884b2bf63b6',
|
||||
],
|
||||
])->each(function ($col) {
|
||||
Setting::updateOrCreate([
|
||||
'name' => $col['name'],
|
||||
], [
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
resolve(SeedDefaultLanguageAction::class)();
|
||||
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/upgrade-license', [
|
||||
'purchaseCode' => '6ab28b36-6d84-41b2-a920-a884b2bf63b6',
|
||||
])->assertStatus(201);
|
||||
|
||||
collect([
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => 'extended',
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => '6ab28b36-6d84-41b2-a920-a884b2bf63b6',
|
||||
],
|
||||
])->each(function ($col) {
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
$this->assertDatabaseHas('language_translations', [
|
||||
'key' => 'go_to_subscription',
|
||||
'value' => 'Go to Subscription',
|
||||
'lang' => 'en',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,9 +66,6 @@ class SetupWizardTest extends TestCase
|
||||
'description' => 'The best file manager on the internet',
|
||||
'googleAnalytics' => 'UA-12345678-1',
|
||||
'contactMail' => 'john@doe.com',
|
||||
'subscriptionType' => 'metered',
|
||||
'userVerification' => 1,
|
||||
'userRegistration' => 1,
|
||||
'storageLimitation' => 1,
|
||||
'defaultStorage' => 10,
|
||||
'logo' => UploadedFile::fake()->image('fake-logo.jpg'),
|
||||
@@ -79,14 +76,6 @@ class SetupWizardTest extends TestCase
|
||||
])->assertStatus(204);
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('settings', [
|
||||
'name' => 'subscription_type',
|
||||
'value' => 'metered',
|
||||
])
|
||||
->assertDatabaseHas('settings', [
|
||||
'name' => 'user_verification',
|
||||
'value' => 0,
|
||||
])
|
||||
->assertDatabaseHas('settings', [
|
||||
'name' => 'app_color',
|
||||
'value' => '#00BC72',
|
||||
@@ -154,15 +143,6 @@ class SetupWizardTest extends TestCase
|
||||
'avatar' => null,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('pages', [
|
||||
'title' => 'Terms of Service',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'feature_title_1',
|
||||
'value' => 'Truly Freedom',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => '1',
|
||||
|
||||
@@ -72,69 +72,4 @@ class SearchTest extends TestCase
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_searched_shared_with_me_file_and_folders()
|
||||
{
|
||||
$owner = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$member = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$folder = Folder::factory()
|
||||
->create([
|
||||
'name' => "Alice's files",
|
||||
'user_id' => $owner->id,
|
||||
]);
|
||||
|
||||
$folderWithin = Folder::factory()
|
||||
->create([
|
||||
'name' => 'Folder within Alice',
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $owner->id,
|
||||
]);
|
||||
|
||||
$document = File::factory()
|
||||
->create([
|
||||
'name' => 'Document',
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $folderWithin->id,
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
'parent_id' => $folder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->getJson('/api/browse/search?query=ali')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->getJson('/api/browse/search?query=Fol')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id,
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->getJson('/api/browse/search?query=doc')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $document->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,157 +109,4 @@ class GateTest extends TestCase
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function team_member_with_can_edit_privilege_rename_folder()
|
||||
{
|
||||
$owner = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$member = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$teamFolder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'team_folder' => 1,
|
||||
'name' => 'Team Folder',
|
||||
]);
|
||||
|
||||
$parent = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $teamFolder->id,
|
||||
]);
|
||||
|
||||
$children = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $parent->id,
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
[
|
||||
'parent_id' => $teamFolder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
],
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->patchJson("/api/rename/{$children->id}", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Renamed Folder',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function team_member_with_can_visit_privilege_try_rename_folder()
|
||||
{
|
||||
$owner = User::factory()
|
||||
->create();
|
||||
|
||||
$member = User::factory()
|
||||
->create();
|
||||
|
||||
$teamFolder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'team_folder' => 1,
|
||||
'name' => 'Team Folder',
|
||||
]);
|
||||
|
||||
$parent = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $teamFolder->id,
|
||||
]);
|
||||
|
||||
$children = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $parent->id,
|
||||
'name' => 'Captivating',
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
[
|
||||
'parent_id' => $teamFolder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-view',
|
||||
],
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->patchJson("/api/rename/{$children->id}", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
])
|
||||
->assertStatus(403);
|
||||
|
||||
$this->assertDatabaseHas('folders', [
|
||||
'name' => 'Captivating',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function team_member_rename_file()
|
||||
{
|
||||
$owner = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$member = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$teamFolder = Folder::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'team_folder' => 1,
|
||||
'name' => 'Team Folder',
|
||||
]);
|
||||
|
||||
$file = File::factory()
|
||||
->create([
|
||||
'user_id' => $owner->id,
|
||||
'parent_id' => $teamFolder->id,
|
||||
]);
|
||||
|
||||
DB::table('team_folder_members')
|
||||
->insert([
|
||||
[
|
||||
'parent_id' => $teamFolder->id,
|
||||
'user_id' => $member->id,
|
||||
'permission' => 'can-edit',
|
||||
],
|
||||
]);
|
||||
|
||||
$this
|
||||
->actingAs($member)
|
||||
->patchJson("/api/rename/{$file->id}", [
|
||||
'name' => 'Renamed File',
|
||||
'type' => 'file',
|
||||
])
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'name' => 'Renamed File',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,83 +4,14 @@ namespace Tests\Support\Scheduler;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
use App\Users\Models\User;
|
||||
use Domain\Files\Models\File;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Domain\Traffic\Models\Traffic;
|
||||
use Support\Scheduler\Actions\ReportUsageAction;
|
||||
use Support\Scheduler\Actions\DeleteFailedFilesAction;
|
||||
use VueFileManager\Subscription\Domain\Plans\Models\Plan;
|
||||
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
|
||||
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
|
||||
use VueFileManager\Subscription\Domain\Plans\Models\PlanMeteredFeature;
|
||||
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
|
||||
|
||||
class SchedulerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_report_usage_of_subscription()
|
||||
{
|
||||
$user = User::factory()
|
||||
->hasSettings()
|
||||
->create();
|
||||
|
||||
$plan = Plan::factory()
|
||||
->create([
|
||||
'type' => 'metered',
|
||||
]);
|
||||
|
||||
PlanMeteredFeature::factory()
|
||||
->count(4)
|
||||
->sequence(
|
||||
['key' => 'storage'],
|
||||
['key' => 'bandwidth'],
|
||||
['key' => 'flatFee'],
|
||||
['key' => 'member'],
|
||||
)
|
||||
->create([
|
||||
'plan_id' => $plan->id,
|
||||
]);
|
||||
|
||||
$subscription = Subscription::factory()
|
||||
->create([
|
||||
'status' => 'active',
|
||||
'type' => 'pre-paid',
|
||||
'plan_id' => $plan->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
File::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'filesize' => 125000000,
|
||||
]);
|
||||
|
||||
Traffic::factory()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'download' => 155000000,
|
||||
'upload' => 255000000,
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
resolve(ReportUsageAction::class)();
|
||||
|
||||
$this
|
||||
->assertDatabaseHas('usages', [
|
||||
'metered_feature_id' => $plan->meteredFeatures()->get()[0]->id,
|
||||
'subscription_id' => $subscription->id,
|
||||
'quantity' => 0.125,
|
||||
])
|
||||
->assertDatabaseHas('usages', [
|
||||
'metered_feature_id' => $plan->meteredFeatures()->get()[1]->id,
|
||||
'subscription_id' => $subscription->id,
|
||||
'quantity' => 0.410,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user