mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
test groups refactoring
This commit is contained in:
@@ -1769,7 +1769,7 @@
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \App\Models\User|null
|
||||
* @return \Domain\Settings\Models\User|null
|
||||
* @static
|
||||
*/
|
||||
public static function user()
|
||||
@@ -1804,7 +1804,7 @@
|
||||
* Log the given user ID into the application without sessions or cookies.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return \App\Models\User|false
|
||||
* @return \Domain\Settings\Models\User|false
|
||||
* @static
|
||||
*/
|
||||
public static function onceUsingId($id)
|
||||
@@ -1882,7 +1882,7 @@
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $remember
|
||||
* @return \App\Models\User|false
|
||||
* @return \Domain\Settings\Models\User|false
|
||||
* @static
|
||||
*/
|
||||
public static function loginUsingId($id, $remember = false)
|
||||
@@ -1958,7 +1958,7 @@
|
||||
/**
|
||||
* Get the last user we attempted to authenticate.
|
||||
*
|
||||
* @return \App\Models\User
|
||||
* @return \Domain\Settings\Models\User
|
||||
* @static
|
||||
*/
|
||||
public static function getLastAttempted()
|
||||
@@ -2060,7 +2060,7 @@
|
||||
/**
|
||||
* Return the currently cached user.
|
||||
*
|
||||
* @return \App\Models\User|null
|
||||
* @return \Domain\Settings\Models\User|null
|
||||
* @static
|
||||
*/
|
||||
public static function getUser()
|
||||
@@ -2106,7 +2106,7 @@
|
||||
/**
|
||||
* Determine if the current user is authenticated. If not, throw an exception.
|
||||
*
|
||||
* @return \App\Models\User
|
||||
* @return \Domain\Settings\Models\User
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
* @static
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,7 @@ return [
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
'model' => Domain\Settings\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
|
||||
@@ -56,7 +56,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'model' => env('CASHIER_MODEL', App\Models\User::class),
|
||||
'model' => env('CASHIER_MODEL', Domain\Settings\Models\User::class),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\File;
|
||||
use Domain\Settings\Models\File;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class FolderFactory extends Factory
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Share;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Zip;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Setting;
|
||||
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 Illuminate\Support\Str;
|
||||
use App\Services\SetupService;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use App\Services\SetupService;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SetupProdEnvironment extends Command
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Console;
|
||||
|
||||
use App\Services\SchedulerService;
|
||||
use Domain\SetupWizard\Services\SchedulerService;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use App\Console\Commands\SetupDevEnvironment;
|
||||
use App\Console\Commands\SetupProdEnvironment;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use App\Models\UserSettings;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\UserSettings;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\CheckAccountRequest;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Models;
|
||||
use ByteUnits\Metric;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Cashier\Billable;
|
||||
use App\Services\HelperService;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\HelperService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use App\Notifications\ResetPassword;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\File;
|
||||
use Domain\Settings\Models\File;
|
||||
use ByteUnits\Metric;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use ByteUnits\Metric;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UsersCollection;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Services\StripeService;
|
||||
use Domain\Settings\Models\Invoice;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\InvoiceResource;
|
||||
use App\Http\Resources\InvoiceAdminCollection;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Storage;
|
||||
use App\Models\User;
|
||||
use App\Models\UserSettings;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\UserSettings;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\UserResource;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Cashier\Cashier;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\Zip;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\HelperService;
|
||||
use App\Models\File as UserFile;
|
||||
use Domain\SetupWizard\Services\HelperService;
|
||||
use Domain\Settings\Models\File as UserFile;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\App;
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Models\Share;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Language;
|
||||
use Domain\Settings\Models\Page;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PageResource;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use Exception;
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Services\HelperService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\HelperService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\FileManagerService;
|
||||
use Domain\SetupWizard\Services\FileManagerService;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\Language;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\LanguageResource;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use App\Services\LanguageService;
|
||||
use Domain\SetupWizard\Services\LanguageService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Kyslik\ColumnSortable\Sortable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Language;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class LanguageCollection extends ResourceCollection
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
namespace App\Services;
|
||||
|
||||
use DB;
|
||||
use App\Models\Language;
|
||||
use App\Models\LanguageTranslation;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\Settings\Models\LanguageTranslation;
|
||||
|
||||
class LanguageService
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ namespace App\Http\Controllers\App;
|
||||
|
||||
use Gate;
|
||||
use Artisan;
|
||||
use App\Models\Language;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\LanguageService;
|
||||
use Domain\SetupWizard\Services\LanguageService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Page;
|
||||
use Domain\Settings\Models\Page;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PageResource;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\Plan;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\PlanResource;
|
||||
|
||||
@@ -3,9 +3,9 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Stripe;
|
||||
use Artisan;
|
||||
use App\Models\Setting;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Cartalyst\Stripe\Exception\UnauthorizedException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
namespace Domain\Settings\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace App\Http\Controllers\App;
|
||||
use Schema;
|
||||
use Stripe;
|
||||
use Artisan;
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\SetupService;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
namespace Domain\SetupWizard\Services;
|
||||
|
||||
use App\Models\Page;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Language;
|
||||
use Domain\Settings\Models\Page;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class SetupService
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\HelperService;
|
||||
use Domain\SetupWizard\Services\HelperService;
|
||||
use Illuminate\Support\Collection;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\FileResource;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Models\Zip;
|
||||
use App\Models\Share;
|
||||
use App\Services\HelperService;
|
||||
use App\Models\File as UserFile;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\SetupWizard\Services\HelperService;
|
||||
use Domain\Settings\Models\File as UserFile;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Services\HelperService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\HelperService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\FileManagerService;
|
||||
use Domain\SetupWizard\Services\FileManagerService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\FileFunctions\UploadRequest;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use Validator;
|
||||
use App\Models\Zip;
|
||||
use App\Models\Share;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
@@ -3,8 +3,8 @@ namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Laravel\Cashier\PaymentMethod;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Subscription;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\StripeService;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Laravel\Cashier\Http\Controllers\WebhookController as CashierController;
|
||||
|
||||
class StripeWebhookController extends CashierController
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Stripe\SetupIntent;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use Illuminate\Http\Response;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Http\Resources\UserSubscription;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InvoiceResource extends JsonResource
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Laravel\Cashier\Cashier;
|
||||
use App\Services\StripeService;
|
||||
use Domain\SetupWizard\Services\StripeService;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PricingResource extends JsonResource
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use Stripe;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Cashier\Cashier;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\FileManager;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\DemoService;
|
||||
use Domain\SetupWizard\Services\DemoService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\File;
|
||||
use Domain\Settings\Models\File;
|
||||
use ByteUnits\Metric;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use App\Http\Requests\FileFunctions\RenameItemRequest;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
namespace App\Services;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Zip;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
namespace App\Services;
|
||||
|
||||
use DB;
|
||||
use App\Models\Zip;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\Zip;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\File as UserFile;
|
||||
use Domain\Settings\Models\File as UserFile;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
namespace App\Services;
|
||||
|
||||
use DB;
|
||||
use App\Models\File;
|
||||
use App\Models\Share;
|
||||
use App\Models\Folder;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Aws\S3\MultipartUploader;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\File;
|
||||
use App\Models\User;
|
||||
use App\Models\Share;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\Settings\Models\Share;
|
||||
use ByteUnits\Metric;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Language;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Tests\Feature\Accounts;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PersonalAccessTokenTest extends TestCase
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Tests\Feature\Accounts;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use App\Notifications\ResetPassword;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
@@ -107,9 +107,9 @@ class SignFlowTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/logout')
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/logout')
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace Tests\Feature\Accounts;
|
||||
use Storage;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use App\Services\SetupService;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
@@ -48,9 +48,9 @@ class UserAccountTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/password', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/password', [
|
||||
'current_password' => 'secret',
|
||||
'password' => 'VerySecretPassword',
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
@@ -67,9 +67,9 @@ class UserAccountTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->patchJson('/api/user/relationships/settings', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson('/api/user/relationships/settings', [
|
||||
'name' => 'address',
|
||||
'value' => 'Jantar',
|
||||
])->assertStatus(204);
|
||||
@@ -84,17 +84,15 @@ class UserAccountTest extends TestCase
|
||||
*/
|
||||
public function it_update_user_avatar()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$avatar = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$this->patchJson('/api/user/relationships/settings', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson('/api/user/relationships/settings', [
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(204);
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
namespace Tests\Domain\Admin;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use Domain\Settings\Models\File;
|
||||
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 App\Services\SetupService;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use DB;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Notification;
|
||||
@@ -50,9 +50,9 @@ class AdminTest extends TestCase
|
||||
'stripe_status' => 'active',
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->getJson('/api/admin/dashboard')
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson('/api/admin/dashboard')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"license" => 'Regular',
|
||||
@@ -120,10 +120,10 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
// TODO: pridat exactjson po refaktorovani userresource
|
||||
$this->getJson("/api/admin/users/$user->id/detail")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/users/$user->id/detail")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $user->id,
|
||||
@@ -141,9 +141,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson("/api/admin/users/$user->id/subscription")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/users/$user->id/subscription")
|
||||
->assertStatus(404);
|
||||
}
|
||||
|
||||
@@ -169,9 +169,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson("/api/admin/users/$user->id/storage")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/users/$user->id/storage")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"data" => [
|
||||
@@ -219,9 +219,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->postJson("/api/admin/users/$user->id/reset-password")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson("/api/admin/users/$user->id/reset-password")
|
||||
->assertStatus(204);
|
||||
|
||||
Notification::assertTimesSent(1, ResetPassword::class);
|
||||
@@ -238,9 +238,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->patchJson("/api/admin/users/$user->id/capacity", [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/users/$user->id/capacity", [
|
||||
'attributes' => [
|
||||
'storage_capacity' => 10
|
||||
]
|
||||
@@ -263,9 +263,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->patchJson("/api/admin/users/$user->id/role", [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/users/$user->id/role", [
|
||||
'attributes' => [
|
||||
'role' => 'admin'
|
||||
]
|
||||
@@ -282,12 +282,12 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$avatar = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$this->postJson("/api/admin/users/create", [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson("/api/admin/users/create", [
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
@@ -319,8 +319,6 @@ class AdminTest extends TestCase
|
||||
*/
|
||||
public function it_delete_user_with_all_data()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
// Create and login user
|
||||
$user = User::factory(User::class)
|
||||
->create(['role' => 'user']);
|
||||
@@ -462,9 +460,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/pages/terms-of-service')
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/pages/terms-of-service')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'slug' => 'terms-of-service'
|
||||
@@ -481,9 +479,9 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->patchJson('/api/admin/pages/terms-of-service', [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/pages/terms-of-service', [
|
||||
'name' => 'title',
|
||||
'value' => 'New Title'
|
||||
])->assertStatus(204);
|
||||
@@ -492,147 +490,4 @@ class AdminTest extends TestCase
|
||||
'title' => 'New Title'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/settings?column=section_features|section_feature_boxes')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'section_features' => '1',
|
||||
'section_feature_boxes' => '1',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->patchJson('/api/admin/settings', [
|
||||
'name' => 'header_title',
|
||||
'value' => 'New Header Title'
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'value' => 'New Header Title'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings_image()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
Setting::forceCreate([
|
||||
'name' => 'app_logo',
|
||||
'value' => null,
|
||||
]);
|
||||
|
||||
$logo = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->patchJson('/api/admin/settings', [
|
||||
'name' => 'app_logo',
|
||||
'app_logo' => $logo
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('settings', [
|
||||
'app_logo' => null
|
||||
]);
|
||||
|
||||
Storage::assertExists(
|
||||
get_setting('app_logo')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_flush_cache()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/settings/flush-cache')
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_stripe()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->postJson('/api/admin/settings/stripe', [
|
||||
'currency' => 'EUR',
|
||||
'key' => '123456789',
|
||||
'secret' => '123456789',
|
||||
'webhookSecret' => '123456789',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'stripe_currency',
|
||||
'value' => 'EUR',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_email()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->postJson('/api/admin/settings/email', [
|
||||
'driver' => 'smtp',
|
||||
'host' => 'smtp.email.com',
|
||||
'port' => 25,
|
||||
'username' => 'john@doe.com',
|
||||
'password' => 'secret',
|
||||
'encryption' => 'tls',
|
||||
])->assertStatus(204);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\FileManager;
|
||||
namespace Tests\Domain\Browsing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
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;
|
||||
@@ -23,8 +23,6 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder_level_1 = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'name' => 'level 1',
|
||||
@@ -56,7 +54,9 @@ class BrowseTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/navigation")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/navigation")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
@@ -121,8 +121,6 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'name' => 'root',
|
||||
@@ -148,7 +146,9 @@ class BrowseTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/folders/$root->id")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/folders/$root->id")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
@@ -210,8 +210,6 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'name' => 'root',
|
||||
@@ -244,7 +242,9 @@ class BrowseTest extends TestCase
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/latest")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/latest")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
@@ -306,8 +306,6 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$file = File::factory(File::class)
|
||||
->create([
|
||||
"author" => "visitor",
|
||||
@@ -315,7 +313,9 @@ class BrowseTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/participants")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/participants")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id
|
||||
@@ -330,8 +330,6 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'parent_id' => null,
|
||||
@@ -360,7 +358,9 @@ class BrowseTest extends TestCase
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/trash")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/trash")
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
[
|
||||
@@ -448,15 +448,15 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$file = File::factory(File::class)
|
||||
->create([
|
||||
'name' => 'Document',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/search?query=doc")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/search?query=doc")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $file->id
|
||||
@@ -471,15 +471,15 @@ class BrowseTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'name' => 'Documents',
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->getJson("/api/browse/search?query=doc")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson("/api/browse/search?query=doc")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $folder->id
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\FileManager;
|
||||
namespace Tests\Domain\Files;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
@@ -26,8 +26,6 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function it_get_public_user_avatar()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$avatar = UploadedFile::fake()
|
||||
->image('fake-avatar.jpg');
|
||||
|
||||
@@ -44,8 +42,6 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function it_get_public_system_image()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$system = UploadedFile::fake()
|
||||
->image('fake-logo.jpg');
|
||||
|
||||
@@ -62,8 +58,6 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function it_get_private_user_file()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -79,9 +73,9 @@ class ContentAccessTest extends TestCase
|
||||
'name' => 'fake-file.pdf',
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->get("file/$file->name")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->get("file/$file->name")
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
@@ -90,8 +84,6 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function it_get_private_user_image_thumbnail()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -107,9 +99,9 @@ class ContentAccessTest extends TestCase
|
||||
'name' => 'fake-thumbnail.jpg',
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->get("thumbnail/$thumbnail->name")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->get("thumbnail/$thumbnail->name")
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
@@ -118,13 +110,9 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function it_get_private_user_zip()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create('archive.zip', 2000, 'application/zip');
|
||||
|
||||
@@ -135,7 +123,9 @@ class ContentAccessTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->get("zip/$zip->id")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->get("zip/$zip->id")
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
@@ -144,8 +134,6 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function logged_user_try_to_get_another_private_user_image_thumbnail()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$users = User::factory(User::class)
|
||||
->count(2)
|
||||
->create();
|
||||
@@ -173,8 +161,6 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function logged_user_try_to_get_another_private_user_file()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$users = User::factory(User::class)
|
||||
->count(2)
|
||||
->create();
|
||||
@@ -202,13 +188,9 @@ class ContentAccessTest extends TestCase
|
||||
*/
|
||||
public function logged_user_try_to_get_another_private_user_zip()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create('archive.zip', 2000, 'application/zip');
|
||||
|
||||
@@ -218,7 +200,9 @@ class ContentAccessTest extends TestCase
|
||||
'basename' => 'EHWKcuvKzA4Gv29v-archive.zip',
|
||||
]);
|
||||
|
||||
$this->get("zip/$zip->id")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->get("zip/$zip->id")
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\FileManager;
|
||||
namespace Tests\Domain\Files;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
@@ -39,17 +38,15 @@ class FileTest extends TestCase
|
||||
*/
|
||||
public function it_upload_image_file_and_create_thumbnail()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
@@ -80,17 +77,15 @@ class FileTest extends TestCase
|
||||
*/
|
||||
public function it_upload_new_file()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create('fake-file.pdf', 1200, 'application/pdf');
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
@@ -117,8 +112,6 @@ class FileTest extends TestCase
|
||||
*/
|
||||
public function it_upload_blacklisted_mimetype_file()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
Setting::create([
|
||||
'name' => 'mimetypes_blacklist',
|
||||
'value' => 'pdf',
|
||||
@@ -130,9 +123,9 @@ class FileTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/upload', [
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
@@ -153,9 +146,9 @@ class FileTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->patchJson("/api/rename/{$file->id}", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$file->id}", [
|
||||
'name' => 'Renamed Item',
|
||||
'type' => 'file',
|
||||
])
|
||||
@@ -183,9 +176,9 @@ class FileTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/move", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/move", [
|
||||
'to_id' => $folder->id,
|
||||
'items' => [
|
||||
[
|
||||
@@ -213,9 +206,9 @@ class FileTest extends TestCase
|
||||
->count(2)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/remove", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $files[0]->id,
|
||||
@@ -243,8 +236,6 @@ class FileTest extends TestCase
|
||||
*/
|
||||
public function it_delete_multiple_files_hardly()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -294,46 +285,4 @@ class FileTest extends TestCase
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_zip_multiple_files_and_download_it()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$file_ids = File::all()->pluck('id');
|
||||
|
||||
$this->postJson("/api/zip/files", [
|
||||
'items' => $file_ids,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\FileManager;
|
||||
namespace Tests\Domain\Folders;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
@@ -43,9 +43,9 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/create-folder', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/create-folder', [
|
||||
'name' => 'New Folder',
|
||||
'parent_id' => null,
|
||||
])
|
||||
@@ -70,9 +70,9 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->patchJson("/api/rename/{$folder->id}", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$folder->id}", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
])
|
||||
@@ -97,15 +97,15 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$emoji_fragment = [
|
||||
'category' => 'Smileys & Emotion (face-smiling)',
|
||||
'char' => '😁',
|
||||
'name' => 'beaming face with smiling eyes',
|
||||
];
|
||||
|
||||
$this->patchJson("/api/rename/{$folder->id}", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$folder->id}", [
|
||||
'name' => 'Renamed Folder',
|
||||
'type' => 'folder',
|
||||
'emoji' => $emoji_fragment
|
||||
@@ -133,9 +133,9 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->patchJson("/api/rename/{$folder->id}", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->patchJson("/api/rename/{$folder->id}", [
|
||||
'name' => 'Folder Name',
|
||||
'type' => 'folder',
|
||||
'color' => '#AD6FFE'
|
||||
@@ -164,9 +164,9 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/folders/favourites", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/folders/favourites", [
|
||||
'folders' => [
|
||||
$folder->id
|
||||
],
|
||||
@@ -189,13 +189,13 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$user
|
||||
->favouriteFolders()
|
||||
->attach($folder->id);
|
||||
|
||||
$this->deleteJson("/api/folders/favourites/$folder->id")
|
||||
$this
|
||||
->actingAs($user)
|
||||
->deleteJson("/api/folders/favourites/$folder->id")
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('favourite_folder', [
|
||||
@@ -218,9 +218,9 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/move", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/move", [
|
||||
'to_id' => $root->id,
|
||||
'items' => [
|
||||
[
|
||||
@@ -252,9 +252,9 @@ class FolderTest extends TestCase
|
||||
$user->favouriteFolders()->attach($folder_1->id);
|
||||
$user->favouriteFolders()->attach($folder_2->id);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/remove", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_1->id,
|
||||
@@ -296,9 +296,9 @@ class FolderTest extends TestCase
|
||||
$folder_2 = Folder::factory(Folder::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/remove", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_1->id,
|
||||
@@ -330,8 +330,6 @@ class FolderTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder_root = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
@@ -355,7 +353,9 @@ class FolderTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->postJson("/api/remove", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/remove", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $folder_root->id,
|
||||
@@ -385,8 +385,6 @@ class FolderTest extends TestCase
|
||||
*/
|
||||
public function it_delete_folder_with_their_content_within_hardly()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
@@ -452,48 +450,4 @@ class FolderTest extends TestCase
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_zip_folder_with_content_within_and_download()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => $folder->id,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$this->getJson("/api/zip/folder/$folder->id")
|
||||
->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\App;
|
||||
namespace Tests\Domain\Homepage;
|
||||
|
||||
use App\Http\Mail\SendContactMessage;
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
use App\Services\SetupService;
|
||||
use Domain\Settings\Models\File;
|
||||
use Domain\Settings\Models\Folder;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\Share;
|
||||
use Domain\Settings\Models\User;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Mail;
|
||||
use ScssPhp\ScssPhp\Compiler;
|
||||
use Tests\TestCase;
|
||||
@@ -144,20 +144,6 @@ class HomepageTest extends TestCase
|
||||
->assertSee('This link is protected by password');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_legal_page()
|
||||
{
|
||||
$this->setup->seed_default_pages();
|
||||
|
||||
$this->getJson('/api/page/terms-of-service')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'title' => 'Terms of Service',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -178,41 +164,4 @@ class HomepageTest extends TestCase
|
||||
|
||||
Mail::assertSent(SendContactMessage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_settings()
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Hello World!',
|
||||
]);
|
||||
|
||||
Setting::create([
|
||||
'name' => 'pricing_description',
|
||||
'value' => 'Give me a money!',
|
||||
]);
|
||||
|
||||
$this->getJson('/api/content?column=get_started_title|pricing_description')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"get_started_title" => "Hello World!",
|
||||
"pricing_description" => "Give me a money!",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_try_get_secured_settings_via_public_api()
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'purchase_code',
|
||||
'value' => '15a53561-d387-4e0a-8de1-5d1bff34c1ed',
|
||||
]);
|
||||
|
||||
$this->getJson('/api/content?column=purchase_code')
|
||||
->assertStatus(401);
|
||||
}
|
||||
}
|
||||
|
||||
37
tests/Domain/Invoices/UserInvoicesTest.php
Normal file
37
tests/Domain/Invoices/UserInvoicesTest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Invoices;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserInvoicesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_user_invoices()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->getJson('/api/user/invoices')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use App\Models\Language;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Services\SetupService;
|
||||
namespace Tests\Domain\Languages;
|
||||
|
||||
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LanguagesTest extends TestCase
|
||||
class AdminLanguageTranslatorTest
|
||||
{
|
||||
protected $setup;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setup = app()->make(SetupService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
@@ -32,9 +25,9 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->postJson('/api/admin/languages', [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/languages', [
|
||||
'name' => 'Slovenčina',
|
||||
'locale' => 'sk',
|
||||
])
|
||||
@@ -66,11 +59,11 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$language = Language::first();
|
||||
|
||||
$this->patchJson("/api/admin/languages/$language->id", [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/languages/$language->id", [
|
||||
'name' => 'name',
|
||||
'value' => 'Slovenčina',
|
||||
])
|
||||
@@ -98,9 +91,9 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->deleteJson("/api/admin/languages/$language->id")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->deleteJson("/api/admin/languages/$language->id")
|
||||
->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('languages', [
|
||||
@@ -125,11 +118,11 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$language = Language::first();
|
||||
|
||||
$this->deleteJson("/api/admin/languages/$language->id")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->deleteJson("/api/admin/languages/$language->id")
|
||||
->assertStatus(401);
|
||||
}
|
||||
|
||||
@@ -143,9 +136,9 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/languages')
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/languages')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"locale" => "en",
|
||||
@@ -163,11 +156,11 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$language = Language::first();
|
||||
|
||||
$this->patchJson("/api/admin/languages/$language->id/strings", [
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson("/api/admin/languages/$language->id/strings", [
|
||||
'name' => 'actions.close',
|
||||
'value' => 'Close It, now!',
|
||||
]);
|
||||
@@ -189,86 +182,15 @@ class LanguagesTest extends TestCase
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$language = Language::first();
|
||||
|
||||
$this->getJson("/api/admin/languages/$language->id")
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/languages/$language->id")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"actions.close" => "Close",
|
||||
"locale" => "en",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_language_translations_for_frontend()
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->getJson("/translations/en")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"actions.close" => "Close",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_custom_translations_from_file_config()
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->assertDatabaseHas('language_translations', [
|
||||
'key' => 'custom',
|
||||
'value' => 'translation',
|
||||
'lang' => 'en',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_translated_string_from_t_helper_function()
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
Language::first()
|
||||
->languageTranslations()
|
||||
->forceCreate([
|
||||
"key" => "test",
|
||||
"value" => "Hi, my name is :name :surname",
|
||||
"lang" => "en",
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
'Close',
|
||||
__t('actions.close')
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'🙋 John share some files with you. Look at it!',
|
||||
__t('shared_link_email_subject', ['user' => 'John'])
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'Hi, my name is John Doe',
|
||||
__t('test', ['name' => 'John', 'surname' => 'Doe'])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_translated_string_from_t_helper_without_database_connection()
|
||||
{
|
||||
$this->assertEquals(
|
||||
__t('actions.close'),
|
||||
'Close'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
tests/Domain/Languages/TranslationsAccessTest.php
Normal file
92
tests/Domain/Languages/TranslationsAccessTest.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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;
|
||||
|
||||
class TranslationsAccessTest extends TestCase
|
||||
{
|
||||
protected $setup;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setup = app()->make(SetupService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_language_translations_for_frontend()
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->getJson("/translations/en")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
"actions.close" => "Close",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_custom_translations_from_file_config()
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
$this->assertDatabaseHas('language_translations', [
|
||||
'key' => 'custom',
|
||||
'value' => 'translation',
|
||||
'lang' => 'en',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_translated_string_from_t_helper_function()
|
||||
{
|
||||
$this->setup->seed_default_language();
|
||||
|
||||
Language::first()
|
||||
->languageTranslations()
|
||||
->forceCreate([
|
||||
"key" => "test",
|
||||
"value" => "Hi, my name is :name :surname",
|
||||
"lang" => "en",
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
'Close',
|
||||
__t('actions.close')
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'🙋 John share some files with you. Look at it!',
|
||||
__t('shared_link_email_subject', ['user' => 'John'])
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'Hi, my name is John Doe',
|
||||
__t('test', ['name' => 'John', 'surname' => 'Doe'])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_translated_string_from_t_helper_without_database_connection()
|
||||
{
|
||||
$this->assertEquals(
|
||||
__t('actions.close'),
|
||||
'Close'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\App;
|
||||
namespace Tests\Domain\Maintenance;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
@@ -10,11 +10,6 @@ use Tests\TestCase;
|
||||
|
||||
class AppUpgradeTest extends TestCase
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -23,8 +18,6 @@ class AppUpgradeTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
DB::table('settings')
|
||||
->insert([
|
||||
[
|
||||
@@ -61,7 +54,9 @@ class AppUpgradeTest extends TestCase
|
||||
]);
|
||||
});
|
||||
|
||||
$this->get('/upgrade/translations')
|
||||
$this
|
||||
->actingAs($user)
|
||||
->get('/upgrade/translations')
|
||||
->assertStatus(201);
|
||||
|
||||
collect(['en', 'sk'])
|
||||
|
||||
25
tests/Domain/Pages/PagesTest.php
Normal file
25
tests/Domain/Pages/PagesTest.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Pages;
|
||||
|
||||
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PagesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_legal_page()
|
||||
{
|
||||
resolve(SetupService::class)->seed_default_pages();
|
||||
|
||||
$this->getJson('/api/page/terms-of-service')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'title' => 'Terms of Service',
|
||||
]);
|
||||
}
|
||||
}
|
||||
192
tests/Domain/Plans/AdminPlansTest.php
Normal file
192
tests/Domain/Plans/AdminPlansTest.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Plans;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlansTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_single_plan_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/plans/' . $this->plan['data']['id'])
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_create_single_plan_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$plan_name = 'test-plan-' . Str::random(16);
|
||||
|
||||
$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),
|
||||
],
|
||||
])
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'name' => $plan_name
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_update_single_plan_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$plan_name = 'test-plan-' . Str::random(16);
|
||||
|
||||
$this->postJson('/api/admin/plans', [
|
||||
'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
|
||||
]);
|
||||
|
||||
$this->patchJson("/api/admin/plans/" . strtolower($plan_name), [
|
||||
'name' => 'description',
|
||||
'value' => 'updated description'
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_subscribers_from_plan_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/plans/' . $this->plan['data']['id'] . '/subscribers')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $user->id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_all_invoices_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/invoices")
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_single_user_invoice_page_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
$invoices = $this
|
||||
->actingAs($user)
|
||||
->getJson('/api/user/invoices')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$invoice_id = json_decode($invoices->content(), true)['data'][0]['data']['id'];
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->get("/invoice/{$this->user['stripe_id']}/$invoice_id")
|
||||
->assertStatus(200)
|
||||
->assertSee('Invoice');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_user_invoices_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson("/api/admin/users/$user->id/invoices")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_all_plans_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/plans')
|
||||
->assertStatus(200);
|
||||
}
|
||||
}
|
||||
52
tests/Domain/Plans/PlansTest.php
Normal file
52
tests/Domain/Plans/PlansTest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Plans;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlansTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_all_plans_for_index_page()
|
||||
{
|
||||
$this->getJson('/api/pricing')
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_delete_single_plan()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$plan_name = 'test-plan-' . Str::random(16);
|
||||
|
||||
$this->postJson('/api/admin/plans', [
|
||||
'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
|
||||
]);
|
||||
|
||||
$this->deleteJson("/api/admin/plans/" . strtolower($plan_name))
|
||||
->assertStatus(204);
|
||||
}
|
||||
}
|
||||
40
tests/Domain/Plans/SetupWizardPlansTest.php
Normal file
40
tests/Domain/Plans/SetupWizardPlansTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Plans;
|
||||
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SetupWizardPlansTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_store_stripe_plans_via_setup_wizard()
|
||||
{
|
||||
$this->postJson('/api/setup/stripe-plans', [
|
||||
'plans' => [
|
||||
[
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => 'test-plan-' . Str::random(),
|
||||
'price' => (string)rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => 'test-plan-' . Str::random(),
|
||||
'price' => (string)rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
],
|
||||
]
|
||||
])->assertStatus(204);
|
||||
}
|
||||
}
|
||||
194
tests/Domain/Settings/SettingsTest.php
Normal file
194
tests/Domain/Settings/SettingsTest.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Settings;
|
||||
|
||||
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_page_settings()
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Hello World!',
|
||||
]);
|
||||
|
||||
Setting::create([
|
||||
'name' => 'pricing_description',
|
||||
'value' => 'Give me a money!',
|
||||
]);
|
||||
|
||||
$this->getJson('/api/content?column=get_started_title|pricing_description')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"get_started_title" => "Hello World!",
|
||||
"pricing_description" => "Give me a money!",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_admin_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/settings?column=section_features|section_feature_boxes')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'section_features' => '1',
|
||||
'section_feature_boxes' => '1',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_try_get_secured_settings_via_public_api()
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'purchase_code',
|
||||
'value' => '15a53561-d387-4e0a-8de1-5d1bff34c1ed',
|
||||
]);
|
||||
|
||||
$this->getJson('/api/content?column=purchase_code')
|
||||
->assertStatus(401);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/settings', [
|
||||
'name' => 'header_title',
|
||||
'value' => 'New Header Title'
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'value' => 'New Header Title'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings_image()
|
||||
{
|
||||
Setting::forceCreate([
|
||||
'name' => 'app_logo',
|
||||
'value' => null,
|
||||
]);
|
||||
|
||||
$logo = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/settings', [
|
||||
'name' => 'app_logo',
|
||||
'app_logo' => $logo
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('settings', [
|
||||
'app_logo' => null
|
||||
]);
|
||||
|
||||
Storage::assertExists(
|
||||
get_setting('app_logo')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_flush_cache()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/settings/flush-cache')
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_stripe()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/settings/stripe', [
|
||||
'currency' => 'EUR',
|
||||
'key' => '123456789',
|
||||
'secret' => '123456789',
|
||||
'webhookSecret' => '123456789',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'stripe_currency',
|
||||
'value' => 'EUR',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_email()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Setup;
|
||||
namespace Tests\Domain\SetupWizard;
|
||||
|
||||
use App\Models\Language;
|
||||
use App\Models\Setting;
|
||||
use App\Services\SetupService;
|
||||
use Domain\Settings\Models\Language;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -21,7 +21,7 @@ class SetupServiceTest extends TestCase
|
||||
*/
|
||||
public function it_create_system_folders()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
// folders are created in TestCase
|
||||
|
||||
collect(['avatars', 'chunks', 'system', 'files', 'temp', 'zip'])
|
||||
->each(function ($directory) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Setup;
|
||||
namespace Tests\Domain\SetupWizard;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Share;
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\User;
|
||||
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;
|
||||
@@ -23,9 +23,9 @@ class UserShareTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/share/$file->id", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$file->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'file',
|
||||
@@ -55,9 +55,9 @@ class UserShareTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/share/$folder->id", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
@@ -87,9 +87,9 @@ class UserShareTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/share/$folder->id", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => true,
|
||||
'password' => 'secret',
|
||||
'permission' => 'editor',
|
||||
@@ -125,9 +125,9 @@ class UserShareTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/share/$folder->id", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
@@ -151,9 +151,9 @@ class UserShareTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson("/api/share/$folder->id", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/share/$folder->id", [
|
||||
'isPassword' => false,
|
||||
'permission' => 'editor',
|
||||
'type' => 'folder',
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Share;
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
@@ -27,8 +27,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
*/
|
||||
public function it_download_file()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
@@ -102,8 +100,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
*/
|
||||
public function it_get_shared_image()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
@@ -159,8 +155,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
*/
|
||||
public function it_get_public_thumbnail()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
@@ -219,8 +213,6 @@ class VisitorAccessToItemsTest extends TestCase
|
||||
*/
|
||||
public function it_download_publicly_zipped_files()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Share;
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use App\Services\SetupService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Str;
|
||||
use Storage;
|
||||
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;
|
||||
|
||||
class VisitorBrowseTest extends TestCase
|
||||
@@ -137,273 +133,6 @@ class VisitorBrowseTest extends TestCase
|
||||
->assertCookieMissing('share_session');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_zip_shared_multiple_files()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
// 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
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder, $user) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create(Str::random() . "-fake-file-$index.pdf", 1000, 'application/pdf');
|
||||
|
||||
Storage::putFileAs("files/$user->id", $file, $file->name);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'filesize' => $file->getSize(),
|
||||
'folder_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'basename' => $file->name,
|
||||
'name' => "fake-file-$index.pdf",
|
||||
]);
|
||||
});
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'item_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->post("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->postJson("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id,
|
||||
'shared_token' => $share->token,
|
||||
]);
|
||||
|
||||
Storage::assertExists("zip/" . Zip::first()->basename);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_try_zip_not_shared_file_with_already_shared_multiple_files()
|
||||
{
|
||||
// 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
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'folder_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'item_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->post("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(403);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->postJson("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(403);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_zip_shared_folder()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
// 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
|
||||
]);
|
||||
|
||||
$children = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->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');
|
||||
|
||||
Storage::putFileAs("files/$user->id", $file, $file->name);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'filesize' => $file->getSize(),
|
||||
'folder_id' => $children->id,
|
||||
'user_id' => $user->id,
|
||||
'basename' => $file->name,
|
||||
'name' => "fake-file-$index.pdf",
|
||||
]);
|
||||
});
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'item_id' => $children->id,
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->get("/api/zip/folder/$children->id/$share->token")
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->getJson("/api/zip/folder/$children->id/$share->token")
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id,
|
||||
'shared_token' => $share->token,
|
||||
]);
|
||||
|
||||
Zip::all()
|
||||
->each(function ($zip) {
|
||||
Storage::assertExists("zip/$zip->basename");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_try_zip_not_shared_folder()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
// 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
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->get("/api/zip/folder/$folder->id/$share->token")
|
||||
->assertStatus(403);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->getJson("/api/zip/folder/$folder->id/$share->token")
|
||||
->assertStatus(403);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Share;
|
||||
namespace Tests\Domain\Sharing;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
@@ -310,8 +310,6 @@ class VisitorManipulatingTest extends TestCase
|
||||
*/
|
||||
public function editor_upload_file_into_shared_folder()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
// check private or public share record
|
||||
collect([true, false])
|
||||
->each(function ($is_protected) {
|
||||
|
||||
56
tests/Domain/Subscriptions/AdminSubscriptionTest.php
Normal file
56
tests/Domain/Subscriptions/AdminSubscriptionTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Subscriptions;
|
||||
|
||||
|
||||
use Domain\Settings\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminSubscriptionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_user_subscription_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->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'),
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\External;
|
||||
namespace Tests\Domain\Subscriptions;
|
||||
|
||||
use App\Models\User;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SubscriptionTest extends TestCase
|
||||
{
|
||||
private $user;
|
||||
private User $user;
|
||||
|
||||
private $plan;
|
||||
private array $plan;
|
||||
|
||||
private $billing;
|
||||
private array $billing;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -64,9 +64,9 @@ class SubscriptionTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->getJson('/api/user/subscription/setup-intent')
|
||||
$this
|
||||
->actingAs($user)
|
||||
->getJson('/api/user/subscription/setup-intent')
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
"object" => "setup_intent"
|
||||
@@ -85,9 +85,9 @@ class SubscriptionTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
@@ -198,323 +198,4 @@ class SubscriptionTest extends TestCase
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_user_invoices()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->getJson('/api/user/invoices')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_user_subscription_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->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'),
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_store_stripe_plans_via_setup_wizard()
|
||||
{
|
||||
$this->postJson('/api/setup/stripe-plans', [
|
||||
'plans' => [
|
||||
[
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => 'test-plan-' . Str::random(16),
|
||||
'price' => (string)rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
],
|
||||
[
|
||||
'type' => 'plan',
|
||||
'attributes' => [
|
||||
'name' => 'test-plan-' . Str::random(16),
|
||||
'price' => (string)rand(1, 99),
|
||||
'description' => 'Some random description',
|
||||
'capacity' => rand(1, 999),
|
||||
],
|
||||
],
|
||||
]
|
||||
])->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_delete_single_plan()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$plan_name = 'test-plan-' . Str::random(16);
|
||||
|
||||
$this->postJson('/api/admin/plans', [
|
||||
'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
|
||||
]);
|
||||
|
||||
$this->deleteJson("/api/admin/plans/" . strtolower($plan_name))
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_update_single_plan_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$plan_name = 'test-plan-' . Str::random(16);
|
||||
|
||||
$this->postJson('/api/admin/plans', [
|
||||
'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
|
||||
]);
|
||||
|
||||
$this->patchJson("/api/admin/plans/" . strtolower($plan_name), [
|
||||
'name' => 'description',
|
||||
'value' => 'updated description'
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_subscribers_from_plan_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/user/subscription/upgrade', [
|
||||
'billing' => $this->billing,
|
||||
'plan' => $this->plan,
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/plans/' . $this->plan['data']['id'] . '/subscribers')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'id' => $user->id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_all_invoices_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson("/api/admin/invoices")
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_single_user_invoice_page_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$invoices = $this->getJson('/api/user/invoices')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$invoice_id = json_decode($invoices->content(), true)['data'][0]['data']['id'];
|
||||
|
||||
$this->get("/invoice/{$this->user['stripe_id']}/$invoice_id")
|
||||
->assertStatus(200)
|
||||
->assertSee('Invoice');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_user_invoices_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson("/api/admin/users/$user->id/invoices")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_all_plans_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/plans')
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_all_plans_for_index_page()
|
||||
{
|
||||
$this->getJson('/api/pricing')
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_get_single_plan_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson('/api/admin/plans/' . $this->plan['data']['id'])
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function it_create_single_plan_from_admin()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$plan_name = 'test-plan-' . Str::random(16);
|
||||
|
||||
$this->postJson('/api/admin/plans', [
|
||||
'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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\FileManager;
|
||||
namespace Tests\Domain\Trash;
|
||||
|
||||
use App\Models\File;
|
||||
use App\Models\Folder;
|
||||
use App\Models\User;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
@@ -13,12 +13,6 @@ use Tests\TestCase;
|
||||
|
||||
class TrashTest extends TestCase
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setup = app()->make(SetupService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -27,8 +21,6 @@ class TrashTest extends TestCase
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$attributes = [
|
||||
'user_id' => $user->id,
|
||||
'deleted_at' => now(),
|
||||
@@ -40,7 +32,9 @@ class TrashTest extends TestCase
|
||||
$file = File::factory(File::class)
|
||||
->create($attributes);
|
||||
|
||||
$this->postJson("/api/trash/restore", [
|
||||
$this
|
||||
->actingAs($user)
|
||||
->postJson("/api/trash/restore", [
|
||||
'items' => [
|
||||
[
|
||||
'id' => $file->id,
|
||||
@@ -67,8 +61,6 @@ class TrashTest extends TestCase
|
||||
*/
|
||||
public function it_dump_trash()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
|
||||
279
tests/Domain/Zipping/SharedZippingTest.php
Normal file
279
tests/Domain/Zipping/SharedZippingTest.php
Normal file
@@ -0,0 +1,279 @@
|
||||
<?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;
|
||||
|
||||
class SharedZippingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_zip_shared_multiple_files()
|
||||
{
|
||||
// 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
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder, $user) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create(Str::random() . "-fake-file-$index.pdf", 1000, 'application/pdf');
|
||||
|
||||
Storage::putFileAs("files/$user->id", $file, $file->name);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'filesize' => $file->getSize(),
|
||||
'folder_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'basename' => $file->name,
|
||||
'name' => "fake-file-$index.pdf",
|
||||
]);
|
||||
});
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'item_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->post("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->postJson("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(201);
|
||||
}
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id,
|
||||
'shared_token' => $share->token,
|
||||
]);
|
||||
|
||||
Storage::assertExists("zip/" . Zip::first()->basename);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_try_zip_not_shared_file_with_already_shared_multiple_files()
|
||||
{
|
||||
// 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
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'folder_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'item_id' => $folder->id,
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->post("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(403);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->postJson("/api/zip/files/$share->token", [
|
||||
'items' => File::all()->pluck('id')
|
||||
])->assertStatus(403);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_zip_shared_folder()
|
||||
{
|
||||
// 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
|
||||
]);
|
||||
|
||||
$children = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->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');
|
||||
|
||||
Storage::putFileAs("files/$user->id", $file, $file->name);
|
||||
|
||||
File::factory(File::class)
|
||||
->create([
|
||||
'filesize' => $file->getSize(),
|
||||
'folder_id' => $children->id,
|
||||
'user_id' => $user->id,
|
||||
'basename' => $file->name,
|
||||
'name' => "fake-file-$index.pdf",
|
||||
]);
|
||||
});
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'item_id' => $children->id,
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->get("/api/zip/folder/$children->id/$share->token")
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->getJson("/api/zip/folder/$children->id/$share->token")
|
||||
->assertStatus(201);
|
||||
}
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id,
|
||||
'shared_token' => $share->token,
|
||||
]);
|
||||
|
||||
Zip::all()
|
||||
->each(function ($zip) {
|
||||
Storage::assertExists("zip/$zip->basename");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function visitor_try_zip_not_shared_folder()
|
||||
{
|
||||
// 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
|
||||
]);
|
||||
|
||||
$share = Share::factory(Share::class)
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'type' => 'folder',
|
||||
'is_protected' => $is_protected,
|
||||
]);
|
||||
|
||||
// Check shared item protected by password
|
||||
if ($is_protected) {
|
||||
|
||||
$cookie = ['share_session' => json_encode([
|
||||
'token' => $share->token,
|
||||
'authenticated' => true,
|
||||
])];
|
||||
|
||||
$this
|
||||
->withUnencryptedCookies($cookie)
|
||||
->get("/api/zip/folder/$folder->id/$share->token")
|
||||
->assertStatus(403);
|
||||
}
|
||||
|
||||
// Check public shared item
|
||||
if (!$is_protected) {
|
||||
$this->getJson("/api/zip/folder/$folder->id/$share->token")
|
||||
->assertStatus(403);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
100
tests/Domain/Zipping/UserZippingTest.php
Normal file
100
tests/Domain/Zipping/UserZippingTest.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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;
|
||||
|
||||
class UserZippingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_zip_multiple_files_and_download_it()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => null,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$file_ids = File::all()->pluck('id');
|
||||
|
||||
$this->postJson("/api/zip/files", [
|
||||
'items' => $file_ids,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_zip_folder_with_content_within_and_download()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$folder = Folder::factory(Folder::class)
|
||||
->create([
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
|
||||
collect([0, 1])
|
||||
->each(function ($index) use ($folder) {
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
$this->postJson('/api/upload', [
|
||||
'filename' => $file->name,
|
||||
'file' => $file,
|
||||
'folder_id' => $folder->id,
|
||||
'is_last' => true,
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
$this->getJson("/api/zip/folder/$folder->id")
|
||||
->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('zips', [
|
||||
'user_id' => $user->id
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
'zip/' . Zip::first()->basename
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\App;
|
||||
namespace Tests\Support\Scheduler;
|
||||
|
||||
use App\Models\Share;
|
||||
use App\Models\User;
|
||||
use App\Models\Zip;
|
||||
use App\Services\SchedulerService;
|
||||
use App\Services\SetupService;
|
||||
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;
|
||||
|
||||
class SchedulerTest extends TestCase
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setup = resolve(SetupService::class);
|
||||
$this->scheduler = resolve(SchedulerService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@@ -31,7 +24,8 @@ class SchedulerTest extends TestCase
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$this->scheduler->delete_expired_shared_links();
|
||||
resolve(SchedulerService::class)
|
||||
->delete_expired_shared_links();
|
||||
|
||||
$this->assertDatabaseMissing('shares', [
|
||||
'id' => $share->id
|
||||
@@ -43,8 +37,6 @@ class SchedulerTest extends TestCase
|
||||
*/
|
||||
public function it_delete_zips_older_than_one_day()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
->create('archive.zip', 2000, 'application/zip');
|
||||
|
||||
@@ -55,7 +47,8 @@ class SchedulerTest extends TestCase
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
$this->scheduler->delete_old_zips();
|
||||
resolve(SchedulerService::class)
|
||||
->delete_old_zips();
|
||||
|
||||
$this->assertDatabaseMissing('zips', [
|
||||
'id' => $zip->id
|
||||
@@ -70,8 +63,6 @@ class SchedulerTest extends TestCase
|
||||
*/
|
||||
public function it_delete_failed_files_older_than_one_day()
|
||||
{
|
||||
$this->setup->create_directories();
|
||||
|
||||
$this->travel(-26)->hours();
|
||||
|
||||
$file = UploadedFile::fake()
|
||||
@@ -82,7 +73,8 @@ class SchedulerTest extends TestCase
|
||||
Storage::putFileAs($folder, $file, 'fake-file.zip');
|
||||
});
|
||||
|
||||
$this->scheduler->delete_failed_files();
|
||||
resolve(SchedulerService::class)
|
||||
->delete_failed_files();
|
||||
|
||||
collect(['chunks'])
|
||||
->each(function ($folder) {
|
||||
@@ -115,7 +107,8 @@ class SchedulerTest extends TestCase
|
||||
'created_at' => now()->subDays(31)
|
||||
]);
|
||||
|
||||
$this->scheduler->delete_unverified_users();
|
||||
resolve(SchedulerService::class)
|
||||
->delete_unverified_users();
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
'id' => $expiredUser->id,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Domain\SetupWizard\Services\SetupService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
@@ -22,5 +23,7 @@ abstract class TestCase extends BaseTestCase
|
||||
Notification::fake();
|
||||
|
||||
Storage::fake('local');
|
||||
|
||||
resolve(SetupService::class)->create_directories();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user