mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
added SetupWizardTest skelet
This commit is contained in:
@@ -8,9 +8,9 @@ use App\Http\Resources\PlanResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
use App\Http\Tools\Demo;
|
||||
use App\Plan;
|
||||
use App\Models\Plan;
|
||||
use App\Services\StripeService;
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Laravel\Cashier\Subscription;
|
||||
@@ -69,11 +69,10 @@ class PlanController extends Controller
|
||||
* Create new plan
|
||||
*
|
||||
* @param Request $request
|
||||
* @return PlanResource
|
||||
* @return PlanResource|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
|
||||
if (Cache::has('plan-starter-pack')) {
|
||||
@@ -94,7 +93,7 @@ class PlanController extends Controller
|
||||
// Clear cached plans
|
||||
cache_forget_many(['plans', 'pricing']);
|
||||
|
||||
return $plan;
|
||||
return response($plan, 201);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +105,6 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
@@ -128,7 +126,6 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
// Check if is demo
|
||||
if (env('APP_DEMO')) {
|
||||
return Demo::response_204();
|
||||
}
|
||||
@@ -150,7 +147,8 @@ class PlanController extends Controller
|
||||
*/
|
||||
public function subscribers($id)
|
||||
{
|
||||
$subscribers = Subscription::where('stripe_plan', $id)->pluck('user_id');
|
||||
$subscribers = Subscription::where('stripe_plan', $id)
|
||||
->pluck('user_id');
|
||||
|
||||
return new UsersCollection(
|
||||
User::sortable()->findMany($subscribers)
|
||||
|
||||
@@ -10,12 +10,11 @@ use App\Http\Requests\SetupWizard\StoreEnvironmentSetupRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripeBillingRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripeCredentialsRequest;
|
||||
use App\Http\Requests\SetupWizard\StoreStripePlansRequest;
|
||||
use App\Page;
|
||||
use App\Services\SetupService;
|
||||
use App\Services\StripeService;
|
||||
use App\Setting;
|
||||
use App\User;
|
||||
use App\UserSettings;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\UserSettings;
|
||||
use Artisan;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
@@ -105,7 +104,7 @@ class SetupWizardController extends Controller
|
||||
$this->set_up_application();
|
||||
|
||||
// Store setup wizard progress
|
||||
Setting::create([
|
||||
Setting::forceCreate([
|
||||
'name' => 'setup_wizard_database',
|
||||
'value' => 1,
|
||||
]);
|
||||
@@ -135,7 +134,7 @@ class SetupWizardController extends Controller
|
||||
}
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
collect([
|
||||
[
|
||||
'name' => 'stripe_currency',
|
||||
'value' => $request->currency,
|
||||
@@ -148,11 +147,11 @@ class SetupWizardController extends Controller
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Set stripe credentials to .env
|
||||
@@ -181,7 +180,7 @@ class SetupWizardController extends Controller
|
||||
if ($this->get_setup_status()) abort(410, 'Gone');
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
collect([
|
||||
[
|
||||
'name' => 'billing_phone_number',
|
||||
'value' => $request->billing_phone_number,
|
||||
@@ -214,11 +213,11 @@ class SetupWizardController extends Controller
|
||||
'name' => 'billing_name',
|
||||
'value' => $request->billing_name,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Clear cache
|
||||
@@ -350,7 +349,7 @@ class SetupWizardController extends Controller
|
||||
}
|
||||
|
||||
// Get options
|
||||
$settings = collect([
|
||||
collect([
|
||||
[
|
||||
'name' => 'app_title',
|
||||
'value' => $request->title,
|
||||
@@ -391,11 +390,11 @@ class SetupWizardController extends Controller
|
||||
'name' => 'storage_default',
|
||||
'value' => $request->defaultStorage ? $request->defaultStorage : 5,
|
||||
],
|
||||
]);
|
||||
|
||||
// Store options
|
||||
$settings->each(function ($col) {
|
||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
setEnvironmentValue([
|
||||
@@ -428,7 +427,7 @@ class SetupWizardController extends Controller
|
||||
|
||||
// Store avatar
|
||||
if ($request->hasFile('avatar')) {
|
||||
$avatar = store_avatar($request->file('avatar'), 'avatars');
|
||||
$avatar = store_avatar($request->file('avatar'));
|
||||
}
|
||||
|
||||
// Create user
|
||||
@@ -440,32 +439,32 @@ class SetupWizardController extends Controller
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
// Get default storage capacity
|
||||
$storage_capacity = Setting::where('name', 'storage_default')->first();
|
||||
$user
|
||||
->settings()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'storage_capacity' => get_setting('storage_default'),
|
||||
]);
|
||||
|
||||
// Create settings
|
||||
UserSettings::forceCreate([
|
||||
'user_id' => $user->id,
|
||||
'storage_capacity' => $storage_capacity->value,
|
||||
]);
|
||||
|
||||
// Store setup wizard progress
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
// Store License
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'license',
|
||||
'value' => $request->license,
|
||||
]);
|
||||
|
||||
// Store Purchase Code
|
||||
Setting::updateOrCreate([
|
||||
'name' => 'purchase_code',
|
||||
'value' => $request->purchase_code,
|
||||
]);
|
||||
collect([
|
||||
[
|
||||
'name' => 'setup_wizard_success',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'license',
|
||||
'value' => $request->license,
|
||||
],
|
||||
[
|
||||
'name' => 'purchase_code',
|
||||
'value' => $request->purchase_code,
|
||||
]
|
||||
])->each(function ($col) {
|
||||
Setting::forceCreate([
|
||||
'name' => $col['name'],
|
||||
'value' => $col['value'],
|
||||
]);
|
||||
});
|
||||
|
||||
// Retrieve access token
|
||||
$response = Route::dispatch(self::make_login_request($request));
|
||||
@@ -532,7 +531,7 @@ class SetupWizardController extends Controller
|
||||
DB::getPdo();
|
||||
|
||||
// Get setup_wizard status
|
||||
return Schema::hasTable('settings') ? Setting::where('name', 'setup_wizard_success')->first() : false;
|
||||
return Schema::hasTable('settings') ? get_setting('setup_wizard_success') : false;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ Route::group(['prefix' => 'users'], function () {
|
||||
});
|
||||
|
||||
// Plans
|
||||
// TODO: testy
|
||||
Route::group(['prefix' => 'plans'], function () {
|
||||
Route::get('/{id}/subscribers', [PlanController::class, 'subscribers']);
|
||||
Route::patch('/{id}/update', [PlanController::class, 'update']);
|
||||
@@ -46,6 +47,7 @@ Route::group(['prefix' => 'pages'], function () {
|
||||
});
|
||||
|
||||
// Invoices
|
||||
// TODO: testy
|
||||
Route::group(['prefix' => 'invoices'], function () {
|
||||
Route::get('/{token}', [InvoiceController::class, 'show']);
|
||||
Route::get('/', [InvoiceController::class, 'index']);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\General\SetupWizardController;
|
||||
|
||||
// TODO: testy
|
||||
Route::post('/purchase-code', [SetupWizardController::class, 'verify_purchase_code']);
|
||||
Route::post('/database', [SetupWizardController::class, 'setup_database']);
|
||||
Route::post('/stripe-credentials', [SetupWizardController::class, 'store_stripe_credentials']);
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Http\Controllers\User\AccountController;
|
||||
use App\Http\Controllers\User\PaymentMethodsController;
|
||||
use App\Http\Controllers\User\SubscriptionController;
|
||||
|
||||
// TODO: testy
|
||||
Route::post('/check', [AuthController::class, 'check_account']);
|
||||
Route::post('/register', [AuthController::class, 'register']);
|
||||
Route::post('/login', [AuthController::class, 'login']);
|
||||
@@ -20,6 +21,7 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
Route::get('/', [AccountController::class, 'user']);
|
||||
|
||||
// Payment cards
|
||||
// TODO: testy
|
||||
Route::delete('/payment-cards/{id}', [PaymentMethodsController::class, 'delete']);
|
||||
Route::patch('/payment-cards/{id}', [PaymentMethodsController::class, 'update']);
|
||||
Route::post('/payment-cards', [PaymentMethodsController::class, 'store']);
|
||||
|
||||
@@ -9,10 +9,12 @@ use App\Http\Controllers\WebhookController;
|
||||
Route::post('/stripe/webhook', [WebhookController::class, 'handleWebhook']);
|
||||
|
||||
// App public files
|
||||
// TODO: testy
|
||||
Route::get('/avatars/{avatar}', [FileAccessController::class, 'get_avatar'])->name('avatar');
|
||||
Route::get('/system/{image}', [FileAccessController::class, 'get_system_image']);
|
||||
|
||||
// Get public thumbnails and files
|
||||
// TODO: testy
|
||||
Route::get('/thumbnail/{name}/public/{token}', [FileAccessController::class, 'get_thumbnail_public']);
|
||||
Route::get('/file/{name}/public/{token}', [FileAccessController::class, 'get_file_public']);
|
||||
Route::get('/zip/{id}/public/{token}', [FileAccessController::class, 'get_zip_public'])->name('zip_public');
|
||||
|
||||
66
tests/Feature/SetupWizardTest.php
Normal file
66
tests/Feature/SetupWizardTest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SetupWizardTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_verify_purchase_code()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_setup_database()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_store_stripe_credentials()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_store_stripe_billings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_store_stripe_plans()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_store_app_settings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_create_admin_account()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user