From e8a29b5a9333ef7fae57739899b2f5134fdc88de Mon Sep 17 00:00:00 2001 From: Evgeny Ulin Date: Thu, 29 Feb 2024 21:33:53 +0300 Subject: [PATCH] #43: Corrected the code in accordance with the new rules. --- app/Console/Commands/Init.php | 8 +-- app/Http/Controllers/AuthController.php | 6 +- app/Http/Controllers/StatusController.php | 2 +- app/Http/Kernel.php | 12 ++-- .../Auth/CheckRestoreTokenRequest.php | 2 +- .../Requests/Auth/ForgotPasswordRequest.php | 2 +- app/Http/Requests/Auth/LoginRequest.php | 2 +- .../Requests/Auth/RefreshTokenRequest.php | 2 +- .../Requests/Auth/RegisterUserRequest.php | 2 +- .../Requests/Auth/RestorePasswordRequest.php | 2 +- .../Requests/Setting/SearchSettingRequest.php | 2 +- app/Http/Requests/Users/UpdateUserRequest.php | 2 +- app/Models/Setting.php | 4 +- app/Models/User.php | 8 +-- .../Http/Requests/CreateMediaRequest.php | 2 +- .../Http/Requests/SearchMediaRequest.php | 2 +- app/Modules/Media/Models/Media.php | 2 +- app/Modules/Media/tests/MediaTest.php | 60 +++++++++---------- app/Repositories/UserRepository.php | 2 +- app/Services/SettingService.php | 6 +- app/Services/UserService.php | 8 +-- config/app.php | 4 +- config/auth.php | 4 +- config/auto-doc.php | 22 +++---- config/defaults.php | 2 +- config/entity-generator.php | 6 +- config/filesystems.php | 8 +-- config/ide-helper.php | 3 +- database/factories/ModelFactory.php | 6 +- .../2014_03_25_094059_create_roles_table.php | 6 +- database/seeders/UserSeeder.php | 2 +- lang/en/validation.php | 6 +- tests/AuthTest.php | 30 +++++----- tests/Modules/Media/MediaTest.php | 60 +++++++++---------- tests/RoleTest.php | 12 ++-- tests/SettingTest.php | 36 +++++------ tests/Support/MediaTestTrait.php | 2 +- tests/UserTest.php | 36 +++++------ tests/fixtures/InitCommandTest/migration.php | 2 +- 39 files changed, 192 insertions(+), 193 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index f124f9d..ac3e5cf 100755 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -59,14 +59,14 @@ public function handle(): void $this->appUrl = $this->ask('Please enter an application URL', "https://api.dev.{$kebabName}.com"); $this->updateConfigFile('.env.testing', '=', [ - 'DATA_COLLECTOR_KEY' => "{$kebabName}-local" + 'DATA_COLLECTOR_KEY' => "{$kebabName}-local", ]); $envFile = (file_exists('.env')) ? '.env' : '.env.example'; $this->updateConfigFile($envFile, '=', [ 'APP_NAME' => $appName, - 'SWAGGER_REMOTE_DRIVER_KEY' => "{$kebabName}-local" + 'SWAGGER_REMOTE_DRIVER_KEY' => "{$kebabName}-local", ]); $this->updateConfigFile('.env.development', '=', [ @@ -76,7 +76,7 @@ public function handle(): void ]); $this->updateConfigFile('.env.ci-testing', '=', [ - 'DATA_COLLECTOR_KEY' => "{$kebabName}" + 'DATA_COLLECTOR_KEY' => "{$kebabName}", ]); $this->info('Project initialized successfully!'); @@ -132,7 +132,7 @@ protected function createAdminUser(string $kebabName): void 'name' => $this->ask('Please enter an admin name', 'Admin'), 'email' => $this->ask('Please enter an admin email', "admin@{$kebabName}.com"), 'password' => $this->ask('Please enter an admin password', $defaultPassword), - 'role_id' => Role::ADMIN + 'role_id' => Role::ADMIN, ]; $this->publishMigration(); diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 7a7ac0f..530bb4b 100755 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -41,7 +41,7 @@ public function login(LoginRequest $request, UserService $service, JWTAuth $auth 'token' => $token, 'ttl' => config('jwt.ttl'), 'refresh_ttl' => config('jwt.refresh_ttl'), - 'user' => $user + 'user' => $user, ]) ->withCookie($tokenCookie); } @@ -61,7 +61,7 @@ public function register(RegisterUserRequest $request, UserService $service, JWT 'token' => $token, 'ttl' => config('jwt.ttl'), 'refresh_ttl' => config('jwt.refresh_ttl'), - 'user' => $user + 'user' => $user, ]) ->withCookie($tokenCookie); } @@ -87,7 +87,7 @@ public function refreshToken(RefreshTokenRequest $request, JWTAuth $auth): JsonR ->json([ 'token' => $newToken, 'ttl' => config('jwt.ttl'), - 'refresh_ttl' => config('jwt.refresh_ttl') + 'refresh_ttl' => config('jwt.refresh_ttl'), ]) ->withHeaders(['Authorization' => "Bearer {$newToken}"]) ->withCookie($tokenCookie); diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 7733512..107f128 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -2,10 +2,10 @@ namespace App\Http\Controllers; -use DB; use Exception; use Illuminate\Http\Response; use Illuminate\Routing\Controller as BaseController; +use Illuminate\Support\Facades\DB; class StatusController extends BaseController { diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 19c9875..77315a3 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -36,7 +36,7 @@ class Kernel extends HttpKernel ValidatePostSize::class, TrimStrings::class, ConvertEmptyStringsToNull::class, - AutoDocMiddleware::class + AutoDocMiddleware::class, ]; /** @@ -52,21 +52,21 @@ class Kernel extends HttpKernel // AuthenticateSession::class, ShareErrorsFromSession::class, VerifyCsrfToken::class, - SubstituteBindings::class + SubstituteBindings::class, ], 'api' => [ 'throttle:60,1', - 'bindings' + 'bindings', ], 'auth_group' => [ 'auth', - 'maintenance' + 'maintenance', ], 'guest_group' => [ - 'maintenance' + 'maintenance', ], ]; @@ -84,6 +84,6 @@ class Kernel extends HttpKernel 'can' => Authorize::class, 'guest' => RedirectIfAuthenticated::class, 'throttle' => ThrottleRequests::class, - 'maintenance' => CheckForMaintenanceMode::class + 'maintenance' => CheckForMaintenanceMode::class, ]; } diff --git a/app/Http/Requests/Auth/CheckRestoreTokenRequest.php b/app/Http/Requests/Auth/CheckRestoreTokenRequest.php index 66becd0..dfe6a22 100644 --- a/app/Http/Requests/Auth/CheckRestoreTokenRequest.php +++ b/app/Http/Requests/Auth/CheckRestoreTokenRequest.php @@ -9,7 +9,7 @@ class CheckRestoreTokenRequest extends Request public function rules(): array { return [ - 'token' => 'required|string|exists:users,set_password_hash' + 'token' => 'required|string|exists:users,set_password_hash', ]; } } diff --git a/app/Http/Requests/Auth/ForgotPasswordRequest.php b/app/Http/Requests/Auth/ForgotPasswordRequest.php index d015dd6..eac44e4 100755 --- a/app/Http/Requests/Auth/ForgotPasswordRequest.php +++ b/app/Http/Requests/Auth/ForgotPasswordRequest.php @@ -9,7 +9,7 @@ class ForgotPasswordRequest extends Request public function rules(): array { return [ - 'email' => 'required|string|email|exists:users,email' + 'email' => 'required|string|email|exists:users,email', ]; } } diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php index b03f92d..eafce22 100755 --- a/app/Http/Requests/Auth/LoginRequest.php +++ b/app/Http/Requests/Auth/LoginRequest.php @@ -11,7 +11,7 @@ public function rules(): array return [ 'email' => 'required', 'password' => 'required', - 'remember' => 'boolean' + 'remember' => 'boolean', ]; } } diff --git a/app/Http/Requests/Auth/RefreshTokenRequest.php b/app/Http/Requests/Auth/RefreshTokenRequest.php index c34720a..6349c6c 100755 --- a/app/Http/Requests/Auth/RefreshTokenRequest.php +++ b/app/Http/Requests/Auth/RefreshTokenRequest.php @@ -9,7 +9,7 @@ class RefreshTokenRequest extends Request public function rules(): array { return [ - 'remember' => 'boolean' + 'remember' => 'boolean', ]; } } diff --git a/app/Http/Requests/Auth/RegisterUserRequest.php b/app/Http/Requests/Auth/RegisterUserRequest.php index 2454784..1099f52 100755 --- a/app/Http/Requests/Auth/RegisterUserRequest.php +++ b/app/Http/Requests/Auth/RegisterUserRequest.php @@ -13,7 +13,7 @@ public function rules(): array 'email' => 'required|string|email|unique:users,email', 'password' => 'required|string|same:confirm', 'confirm' => 'required|string', - 'remember' => 'boolean' + 'remember' => 'boolean', ]; } } diff --git a/app/Http/Requests/Auth/RestorePasswordRequest.php b/app/Http/Requests/Auth/RestorePasswordRequest.php index 6b2427b..bf6441a 100755 --- a/app/Http/Requests/Auth/RestorePasswordRequest.php +++ b/app/Http/Requests/Auth/RestorePasswordRequest.php @@ -10,7 +10,7 @@ public function rules(): array { return [ 'token' => 'required|string|exists:users,set_password_hash', - 'password' => 'required|string' + 'password' => 'required|string', ]; } } diff --git a/app/Http/Requests/Setting/SearchSettingRequest.php b/app/Http/Requests/Setting/SearchSettingRequest.php index 79cfc3b..3a07f03 100755 --- a/app/Http/Requests/Setting/SearchSettingRequest.php +++ b/app/Http/Requests/Setting/SearchSettingRequest.php @@ -14,7 +14,7 @@ public function rules(): array 'all' => 'integer', 'query' => 'string|nullable', 'order_by' => 'string|in:name', - 'desc' => 'boolean' + 'desc' => 'boolean', ]; } } diff --git a/app/Http/Requests/Users/UpdateUserRequest.php b/app/Http/Requests/Users/UpdateUserRequest.php index bd3a7de..8184c56 100755 --- a/app/Http/Requests/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Users/UpdateUserRequest.php @@ -18,7 +18,7 @@ public function rules(): array return [ 'email' => "string|email|unique:users,email,{$this->route('id')}", 'name' => 'string', - 'role_id' => 'integer|exists:roles,id' + 'role_id' => 'integer|exists:roles,id', ]; } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 42ff54e..d1f0c44 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -17,14 +17,14 @@ class Setting extends Model protected $fillable = [ 'name', 'value', - 'is_public' + 'is_public', ]; protected $hidden = ['pivot']; protected $casts = [ 'value' => 'array', 'name' => 'string', - 'is_public' => 'boolean' + 'is_public' => 'boolean', ]; public function scopeApplySettingPermissionRestrictions(Builder $query): void diff --git a/app/Models/User.php b/app/Models/User.php index a32e952..67c0df9 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -22,22 +22,22 @@ class User extends Authenticatable implements JWTSubject 'email', 'password', 'role_id', - 'set_password_hash_created_at' + 'set_password_hash_created_at', ]; protected $guarded = [ - 'set_password_hash' + 'set_password_hash', ]; protected $hidden = [ 'password', 'remember_token', - 'set_password_hash' + 'set_password_hash', ]; protected $casts = [ 'is_public' => 'boolean', - 'set_password_hash_created_at' => 'datetime' + 'set_password_hash_created_at' => 'datetime', ]; public function getJWTIdentifier(): int diff --git a/app/Modules/Media/Http/Requests/CreateMediaRequest.php b/app/Modules/Media/Http/Requests/CreateMediaRequest.php index ca2721d..5929426 100644 --- a/app/Modules/Media/Http/Requests/CreateMediaRequest.php +++ b/app/Modules/Media/Http/Requests/CreateMediaRequest.php @@ -14,7 +14,7 @@ public function rules(): array return [ 'file' => "file|required|max:5120|mimes:{$types}", 'meta' => 'array', - 'is_public' => 'boolean' + 'is_public' => 'boolean', ]; } } diff --git a/app/Modules/Media/Http/Requests/SearchMediaRequest.php b/app/Modules/Media/Http/Requests/SearchMediaRequest.php index 4d0b4f1..afd7768 100644 --- a/app/Modules/Media/Http/Requests/SearchMediaRequest.php +++ b/app/Modules/Media/Http/Requests/SearchMediaRequest.php @@ -16,7 +16,7 @@ public function rules(): array 'query' => 'string', 'order_by' => 'string', 'desc' => 'boolean', - 'name' => 'string' + 'name' => 'string', ]; } } diff --git a/app/Modules/Media/Models/Media.php b/app/Modules/Media/Models/Media.php index 098eba5..413cf7e 100644 --- a/app/Modules/Media/Models/Media.php +++ b/app/Modules/Media/Models/Media.php @@ -22,7 +22,7 @@ class Media extends Model 'name', 'owner_id', 'is_public', - 'meta' + 'meta', ]; protected $casts = [ diff --git a/app/Modules/Media/tests/MediaTest.php b/app/Modules/Media/tests/MediaTest.php index 05a89da..0050f93 100644 --- a/app/Modules/Media/tests/MediaTest.php +++ b/app/Modules/Media/tests/MediaTest.php @@ -41,7 +41,7 @@ public function testCreate(): void 'name' => 'file.png', 'owner_id' => $this->admin->id, 'is_public' => false, - 'link' => '/storage/file.png' + 'link' => '/storage/file.png', ]); } @@ -60,7 +60,7 @@ public function testCreatePublic(): void 'id' => 6, 'name' => 'file.png', 'owner_id' => $this->user->id, - 'is_public' => true + 'is_public' => true, ]); } @@ -83,7 +83,7 @@ public function testCreateCheckResponse(): void $this->assertDatabaseHas('media', [ 'id' => 6, - 'link' => '/storage/file.png' + 'link' => '/storage/file.png', ]); Storage::disk('local')->assertExists($this->getFilePathFromUrl('file.png')); @@ -106,13 +106,13 @@ public function testBulkCreate(): void 'media' => [ [ 'file' => $this->file, - 'meta' => ['test1'] + 'meta' => ['test1'], ], [ 'file' => $this->file, - 'meta' => ['test2'] - ] - ] + 'meta' => ['test2'], + ], + ], ]); $response->assertOk(); @@ -122,7 +122,7 @@ public function testBulkCreate(): void 'name' => 'file.png', 'owner_id' => $this->admin->id, 'meta' => "[\"test1\"]", - 'is_public' => false + 'is_public' => false, ]); $this->assertDatabaseHas('media', [ @@ -130,7 +130,7 @@ public function testBulkCreate(): void 'name' => 'file.png', 'owner_id' => $this->admin->id, 'meta' => "[\"test2\"]", - 'is_public' => false + 'is_public' => false, ]); } @@ -141,7 +141,7 @@ public function testDelete(): void $response->assertNoContent(); $this->assertSoftDeleted('media', [ - 'id' => 1 + 'id' => 1, ]); } @@ -159,7 +159,7 @@ public function testDeleteNoPermission(): void $response->assertForbidden(); $this->assertDatabaseHas('media', [ - 'id' => 1 + 'id' => 1, ]); } @@ -170,7 +170,7 @@ public function testDeleteNoAuth(): void $response->assertUnauthorized(); $this->assertDatabaseHas('media', [ - 'id' => 1 + 'id' => 1, ]); } @@ -179,7 +179,7 @@ public function getSearchFilters(): array return [ [ 'filter' => ['all' => true], - 'result' => 'get_by_all.json' + 'result' => 'get_by_all.json', ], ]; } @@ -189,17 +189,17 @@ public function getAdminSearchFilters(): array return [ [ 'filter' => ['query' => 'product'], - 'result' => 'get_by_query_as_admin.json' + 'result' => 'get_by_query_as_admin.json', ], [ 'filter' => [ 'query' => 'photo', 'order_by' => 'name', 'desc' => false, - 'per_page' => 3 + 'per_page' => 3, ], - 'result' => 'get_complex_as_admin.json' - ] + 'result' => 'get_complex_as_admin.json', + ], ]; } @@ -208,17 +208,17 @@ public function getUserSearchFilters(): array return [ [ 'filter' => ['query' => 'product'], - 'result' => 'get_by_query_as_user.json' + 'result' => 'get_by_query_as_user.json', ], [ 'filter' => [ 'query' => 'photo', 'order_by' => 'name', 'desc' => false, - 'per_page' => 3 + 'per_page' => 3, ], - 'result' => 'get_complex_as_user.json' - ] + 'result' => 'get_complex_as_user.json', + ], ]; } @@ -271,11 +271,11 @@ public function getBadFiles(): array { return [ [ - 'filter' => ['fileName' => 'notAVirus.exe'] + 'filter' => ['fileName' => 'notAVirus.exe'], ], [ - 'filter' => ['fileName' => 'notAVirus.psd'] - ] + 'filter' => ['fileName' => 'notAVirus.psd'], + ], ]; } @@ -294,8 +294,8 @@ public function testUploadingBadFiles(array $filter): void $response->assertJson([ 'errors' => [ - 'file' => ['The file must be a file of type: jpg, jpeg, bmp, png.'] - ] + 'file' => ['The file must be a file of type: jpg, jpeg, bmp, png.'], + ], ]); } @@ -303,14 +303,14 @@ public function getGoodFiles(): array { return [ [ - 'filter' => ['fileName' => 'image.jpg'] + 'filter' => ['fileName' => 'image.jpg'], ], [ - 'filter' => ['fileName' => 'image.png'] + 'filter' => ['fileName' => 'image.png'], ], [ - 'filter' => ['fileName' => 'image.bmp'] - ] + 'filter' => ['fileName' => 'image.bmp'], + ], ]; } diff --git a/app/Repositories/UserRepository.php b/app/Repositories/UserRepository.php index 47c3d81..c7ddfbf 100755 --- a/app/Repositories/UserRepository.php +++ b/app/Repositories/UserRepository.php @@ -23,7 +23,7 @@ public function clearSetPasswordHash(): int ->where('set_password_hash_created_at', '<', Carbon::now()->subHours(config('defaults.password_hash_lifetime'))) ->update([ 'set_password_hash' => null, - 'set_password_hash_created_at' => null + 'set_password_hash_created_at' => null, ]); } } diff --git a/app/Services/SettingService.php b/app/Services/SettingService.php index a8f065c..6095f67 100755 --- a/app/Services/SettingService.php +++ b/app/Services/SettingService.php @@ -58,7 +58,7 @@ public function set($key, $value) if (empty($setting)) { return $this->repository->create([ 'name' => $key, - 'value' => $value + 'value' => $value, ]); } @@ -68,9 +68,9 @@ public function set($key, $value) Arr::set($setting, $valuePath, $value); return $this->repository->update([ - 'name' => $primaryKey + 'name' => $primaryKey, ], [ - 'value' => $setting['value'] + 'value' => $setting['value'], ]); } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index e701c09..d4e24ea 100755 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -56,10 +56,10 @@ public function forgotPassword(string $email): void $this->repository ->force() ->update([ - 'email' => $email + 'email' => $email, ], [ 'set_password_hash' => $hash, - 'set_password_hash_created_at' => Carbon::now() + 'set_password_hash_created_at' => Carbon::now(), ]); Mail::to($email)->send(new ForgotPasswordMail(['hash' => $hash])); @@ -70,10 +70,10 @@ public function restorePassword(string $token, string $password): void $this->repository ->force() ->update([ - 'set_password_hash' => $token + 'set_password_hash' => $token, ], [ 'password' => Hash::make($password), - 'set_password_hash' => null + 'set_password_hash' => null, ]); } diff --git a/config/app.php b/config/app.php index c973ea7..8b9893e 100644 --- a/config/app.php +++ b/config/app.php @@ -210,7 +210,7 @@ // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, - App\Providers\DevDependenciesServiceProvider::class + App\Providers\DevDependenciesServiceProvider::class, ], @@ -261,7 +261,7 @@ 'Str' => Illuminate\Support\Str::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, - 'View' => Illuminate\Support\Facades\View::class + 'View' => Illuminate\Support\Facades\View::class, ], ]; diff --git a/config/auth.php b/config/auth.php index c15333b..7ab3215 100644 --- a/config/auth.php +++ b/config/auth.php @@ -43,7 +43,7 @@ 'nova' => [ 'driver' => 'session', 'provider' => 'users', - ] + ], ], /* @@ -95,7 +95,7 @@ 'provider' => 'users', 'table' => 'password_resets', 'expire' => 60, - ] + ], ], /* diff --git a/config/auto-doc.php b/config/auto-doc.php index d9802d0..f453a07 100644 --- a/config/auto-doc.php +++ b/config/auto-doc.php @@ -47,12 +47,12 @@ 'title' => env('APP_NAME', 'Name of Your Application'), 'termsOfService' => '', 'contact' => [ - 'email' => 'your@email.com' + 'email' => 'your@email.com', ], 'license' => [ 'name' => '', - 'url' => '' - ] + 'url' => '', + ], ], /* @@ -86,8 +86,8 @@ 'code-descriptions' => [ '200' => 'Operation successfully done', '204' => 'Operation successfully done', - '404' => 'This entity not found' - ] + '404' => 'This entity not found', + ], ], /* @@ -115,12 +115,12 @@ 'drivers' => [ 'local' => [ 'class' => LocalDriver::class, - 'production_path' => storage_path('documentation.json') + 'production_path' => storage_path('documentation.json'), ], 'remote' => [ 'class' => RemoteDriver::class, 'key' => env('SWAGGER_REMOTE_DRIVER_KEY', 'project_name'), - 'url' => env('SWAGGER_REMOTE_DRIVER_URL', 'https://example.com') + 'url' => env('SWAGGER_REMOTE_DRIVER_URL', 'https://example.com'), ], 'storage' => [ 'class' => StorageDriver::class, @@ -133,8 +133,8 @@ | One of the filesystems.disks config value */ 'disk' => env('SWAGGER_STORAGE_DRIVER_DISK', 'public'), - 'production_path' => 'documentation.json' - ] + 'production_path' => 'documentation.json', + ], ], /* @@ -168,8 +168,8 @@ */ 'display_environments' => [ 'local', - 'development' + 'development', ], - 'config_version' => '2.6' + 'config_version' => '2.6', ]; diff --git a/config/defaults.php b/config/defaults.php index 366d53a..3dd0359 100644 --- a/config/defaults.php +++ b/config/defaults.php @@ -12,5 +12,5 @@ | */ - 'password_hash_lifetime' => env('PASSWORD_HASH_LIFETIME', 1) + 'password_hash_lifetime' => env('PASSWORD_HASH_LIFETIME', 1), ]; diff --git a/config/entity-generator.php b/config/entity-generator.php index fc71b95..d3e2f6f 100644 --- a/config/entity-generator.php +++ b/config/entity-generator.php @@ -19,7 +19,7 @@ 'factory' => 'database/factories/ModelFactory.php', 'seeds' => 'database/seeds', 'database_seeder' => 'database/seeds/DatabaseSeeder.php', - 'translations' => 'resources/lang/en/validation.php' + 'translations' => 'resources/lang/en/validation.php', ], 'stubs' => [ 'model' => 'entity-generator::model', @@ -39,6 +39,6 @@ 'translation_not_found' => 'entity-generator::translation_not_found', 'validation' => 'entity-generator::validation', 'seeder' => 'entity-generator::seeder', - 'database_empty_seeder' => 'entity-generator::database_seed_empty' - ] + 'database_empty_seeder' => 'entity-generator::database_seed_empty', + ], ]; diff --git a/config/filesystems.php b/config/filesystems.php index edc0318..ac6b200 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -33,7 +33,7 @@ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), - 'throw' => true + 'throw' => true, ], 'public' => [ @@ -41,7 +41,7 @@ 'root' => storage_path('app/public'), 'url' => env('APP_URL') . '/storage', 'visibility' => 'public', - 'throw' => true + 'throw' => true, ], 's3' => [ @@ -52,7 +52,7 @@ 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), 'endpoint' => env('AWS_ENDPOINT'), - 'throw' => true + 'throw' => true, ], 'testing' => [ @@ -67,7 +67,7 @@ 'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET'), 'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null), 'visibility' => 'public', - 'throw' => true + 'throw' => true, ], ], diff --git a/config/ide-helper.php b/config/ide-helper.php index e7b25a6..826ae5d 100644 --- a/config/ide-helper.php +++ b/config/ide-helper.php @@ -67,7 +67,6 @@ 'app', ], - /* |-------------------------------------------------------------------------- | Extra classes @@ -92,7 +91,7 @@ 'critical' => 'Monolog\Logger::addCritical', 'alert' => 'Monolog\Logger::addAlert', 'emergency' => 'Monolog\Logger::addEmergency', - ] + ], ], /* diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 5c36ab4..4c65c40 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -24,18 +24,18 @@ 'email' => $faker->unique()->safeEmail, 'password' => $password ?: $password = Hash::make('secret'), 'remember_token' => Str::random(10), - 'role_id' => Role::USER + 'role_id' => Role::USER, ]; }); $factory->define(App\Models\Role::class, function () { return [ - 'name' => 'user' + 'name' => 'user', ]; }); $factory->define(App\Models\Setting::class, function (Faker\Generator $faker) { return [ 'key' => $faker->word, - 'value' => $faker->word + 'value' => $faker->word, ]; }); diff --git a/database/migrations/2014_03_25_094059_create_roles_table.php b/database/migrations/2014_03_25_094059_create_roles_table.php index 78b4a40..e450028 100644 --- a/database/migrations/2014_03_25_094059_create_roles_table.php +++ b/database/migrations/2014_03_25_094059_create_roles_table.php @@ -35,12 +35,12 @@ public function addRoles() $roles = [ [ 'id' => 1, - 'name' => 'administrator' + 'name' => 'administrator', ], [ 'id' => 2, - 'name' => 'user' - ] + 'name' => 'user', + ], ]; DB::table('roles')->insert($roles); diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index ce0cf97..e42ddf9 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -11,7 +11,7 @@ class UserSeeder extends Seeder public function run() { factory(User::class)->create([ - 'role_id' => Role::USER + 'role_id' => Role::USER, ]); } } diff --git a/lang/en/validation.php b/lang/en/validation.php index 028c3eb..2c1bcba 100644 --- a/lang/en/validation.php +++ b/lang/en/validation.php @@ -104,8 +104,8 @@ 'rule-name' => 'custom-message', ], 'role_id' => [ - 'access_denied' => 'You are not able to change user role' - ] + 'access_denied' => 'You are not able to change user role', + ], ], /* @@ -132,6 +132,6 @@ 'exceptions' => [ 'not_found' => ':Entity does not exist', - ] + ], ]; diff --git a/tests/AuthTest.php b/tests/AuthTest.php index 7fe08ed..d1502ce 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -32,7 +32,7 @@ public function testLogin() { $response = $this->json('post', '/login', [ 'email' => $this->users[1]['email'], - 'password' => $this->users[1]['password'] + 'password' => $this->users[1]['password'], ]); $response->assertOk(); @@ -45,7 +45,7 @@ public function testLoginWrongCredentials() { $response = $this->json('post', '/login', [ 'email' => 'wrong email', - 'password' => 'wrong password' + 'password' => 'wrong password', ]); $response->assertUnauthorized(); @@ -56,7 +56,7 @@ public function testLoginWithRemember() $response = $this->json('post', '/login', [ 'email' => $this->users[1]['email'], 'password' => $this->users[1]['password'], - 'remember' => true + 'remember' => true, ]); $response->assertOk(); @@ -69,7 +69,7 @@ public function testLoginWithoutRemember() $response = $this->json('post', '/login', [ 'email' => $this->users[1]['email'], 'password' => $this->users[1]['password'], - 'remember' => false + 'remember' => false, ]); $response->assertOk(); @@ -81,7 +81,7 @@ public function testLoginAsRegisteredUser() { $response = $this->json('post', '/login', [ 'email' => $this->users[0]['email'], - 'password' => $this->users[0]['password'] + 'password' => $this->users[0]['password'], ]); $response->assertOk(); @@ -94,7 +94,7 @@ public function testLoginAsAuthorizedUser() { $response = $this->actingAs($this->admin)->json('post', '/login', [ 'email' => $this->users[0]['email'], - 'password' => $this->users[0]['password'] + 'password' => $this->users[0]['password'], ]); $response->assertOk(); @@ -183,7 +183,7 @@ public function refreshTokenAfterRefreshTTL() public function testRefreshTokenWithRemember() { $response = $this->actingAs($this->admin)->json('get', '/auth/refresh', [ - 'remember' => true + 'remember' => true, ]); $response->assertOk(); @@ -197,7 +197,7 @@ public function testRefreshTokenWithRememberWithoutBlacklist() config(['jwt.blacklist_enabled' => false]); $response = $this->actingAs($this->admin)->json('get', '/auth/refresh', [ - 'remember' => true + 'remember' => true, ]); $response->assertUnauthorized(); @@ -245,7 +245,7 @@ public function testForgotPassword() $this->mockOpensslRandomPseudoBytes(); $response = $this->json('post', '/auth/forgot-password', [ - 'email' => 'fidel.kutch@example.com' + 'email' => 'fidel.kutch@example.com', ]); $response->assertNoContent(); @@ -253,21 +253,21 @@ public function testForgotPassword() $this->assertDatabaseMissing('users', [ 'email' => 'fidel.kutch@example.com', 'set_password_hash' => null, - 'set_password_hash_created_at' => null + 'set_password_hash_created_at' => null, ]); $this->assertMailEquals(ForgotPasswordMail::class, [ [ 'emails' => 'fidel.kutch@example.com', - 'fixture' => 'forgot_password_email.html' - ] + 'fixture' => 'forgot_password_email.html', + ], ]); } public function testForgotPasswordUserDoesNotExists() { $response = $this->json('post', '/auth/forgot-password', [ - 'email' => 'not_exists@example.com' + 'email' => 'not_exists@example.com', ]); $response->assertUnprocessable(); @@ -284,12 +284,12 @@ public function testRestorePassword() $this->assertDatabaseMissing('users', [ 'email' => 'fidel.kutch@example.com', - 'password' => 'old_password' + 'password' => 'old_password', ]); $this->assertDatabaseMissing('users', [ 'email' => 'fidel.kutch@example.com', - 'set_password_hash' => 'restore_token' + 'set_password_hash' => 'restore_token', ]); } diff --git a/tests/Modules/Media/MediaTest.php b/tests/Modules/Media/MediaTest.php index dbe8c65..ee24d90 100644 --- a/tests/Modules/Media/MediaTest.php +++ b/tests/Modules/Media/MediaTest.php @@ -41,7 +41,7 @@ public function testCreate(): void 'name' => 'file.png', 'owner_id' => $this->admin->id, 'is_public' => false, - 'link' => '/storage/file.png' + 'link' => '/storage/file.png', ]); } @@ -61,7 +61,7 @@ public function testCreatePublic(): void 'name' => 'file.png', 'owner_id' => $this->user->id, 'is_public' => true, - 'link' => '/storage/file.png' + 'link' => '/storage/file.png', ]); } @@ -84,7 +84,7 @@ public function testCreateCheckResponse(): void $this->assertDatabaseHas('media', [ 'id' => 6, - 'link' => '/storage/file.png' + 'link' => '/storage/file.png', ]); Storage::disk('local')->assertExists($this->getFilePathFromUrl('file.png')); @@ -107,13 +107,13 @@ public function testBulkCreate(): void 'media' => [ [ 'file' => $this->file, - 'meta' => ['test1'] + 'meta' => ['test1'], ], [ 'file' => $this->file, - 'meta' => ['test2'] - ] - ] + 'meta' => ['test2'], + ], + ], ]); $response->assertOk(); @@ -123,7 +123,7 @@ public function testBulkCreate(): void 'name' => 'file.png', 'owner_id' => $this->admin->id, 'meta' => "[\"test1\"]", - 'is_public' => false + 'is_public' => false, ]); $this->assertDatabaseHas('media', [ @@ -131,7 +131,7 @@ public function testBulkCreate(): void 'name' => 'file.png', 'owner_id' => $this->admin->id, 'meta' => "[\"test2\"]", - 'is_public' => false + 'is_public' => false, ]); } @@ -142,7 +142,7 @@ public function testDelete(): void $response->assertNoContent(); $this->assertSoftDeleted('media', [ - 'id' => 1 + 'id' => 1, ]); } @@ -160,7 +160,7 @@ public function testDeleteNoPermission(): void $response->assertForbidden(); $this->assertDatabaseHas('media', [ - 'id' => 1 + 'id' => 1, ]); } @@ -171,7 +171,7 @@ public function testDeleteNoAuth(): void $response->assertUnauthorized(); $this->assertDatabaseHas('media', [ - 'id' => 1 + 'id' => 1, ]); } @@ -180,7 +180,7 @@ public function getSearchFilters(): array return [ [ 'filter' => ['all' => true], - 'result' => 'get_by_all.json' + 'result' => 'get_by_all.json', ], ]; } @@ -190,17 +190,17 @@ public function getAdminSearchFilters(): array return [ [ 'filter' => ['query' => 'product'], - 'result' => 'get_by_query_as_admin.json' + 'result' => 'get_by_query_as_admin.json', ], [ 'filter' => [ 'query' => 'photo', 'order_by' => 'name', 'desc' => false, - 'per_page' => 3 + 'per_page' => 3, ], - 'result' => 'get_complex_as_admin.json' - ] + 'result' => 'get_complex_as_admin.json', + ], ]; } @@ -209,17 +209,17 @@ public function getUserSearchFilters(): array return [ [ 'filter' => ['query' => 'product'], - 'result' => 'get_by_query_as_user.json' + 'result' => 'get_by_query_as_user.json', ], [ 'filter' => [ 'query' => 'photo', 'order_by' => 'name', 'desc' => false, - 'per_page' => 3 + 'per_page' => 3, ], - 'result' => 'get_complex_as_user.json' - ] + 'result' => 'get_complex_as_user.json', + ], ]; } @@ -272,11 +272,11 @@ public function getBadFiles(): array { return [ [ - 'filter' => ['fileName' => 'notAVirus.exe'] + 'filter' => ['fileName' => 'notAVirus.exe'], ], [ - 'filter' => ['fileName' => 'notAVirus.psd'] - ] + 'filter' => ['fileName' => 'notAVirus.psd'], + ], ]; } @@ -295,8 +295,8 @@ public function testUploadingBadFiles(array $filter): void $response->assertJson([ 'errors' => [ - 'file' => ['The file must be a file of type: jpg, jpeg, bmp, png.'] - ] + 'file' => ['The file must be a file of type: jpg, jpeg, bmp, png.'], + ], ]); } @@ -304,14 +304,14 @@ public function getGoodFiles(): array { return [ [ - 'filter' => ['fileName' => 'image.jpg'] + 'filter' => ['fileName' => 'image.jpg'], ], [ - 'filter' => ['fileName' => 'image.png'] + 'filter' => ['fileName' => 'image.png'], ], [ - 'filter' => ['fileName' => 'image.bmp'] - ] + 'filter' => ['fileName' => 'image.bmp'], + ], ]; } diff --git a/tests/RoleTest.php b/tests/RoleTest.php index 89cba7a..35511ab 100644 --- a/tests/RoleTest.php +++ b/tests/RoleTest.php @@ -11,26 +11,26 @@ public function getSearchFilters() return [ [ 'filter' => ['all' => 1], - 'result' => 'search_by_all.json' + 'result' => 'search_by_all.json', ], [ 'filter' => [ 'page' => 2, 'per_page' => 1, ], - 'result' => 'search_by_page_per.json' + 'result' => 'search_by_page_per.json', ], [ 'filter' => ['query' => 'us'], - 'result' => 'get_roles_by_name.json' + 'result' => 'get_roles_by_name.json', ], [ 'filter' => [ 'desc' => true, - 'order_by' => 'name' + 'order_by' => 'name', ], - 'result' => 'get_roles_check_order.json' - ] + 'result' => 'get_roles_check_order.json', + ], ]; } diff --git a/tests/SettingTest.php b/tests/SettingTest.php index 9bb2ae0..eb0bb50 100644 --- a/tests/SettingTest.php +++ b/tests/SettingTest.php @@ -28,7 +28,7 @@ public function testUpdate() $this->assertDatabaseHas('settings', [ 'name' => $setting['name'], - 'value' => json_encode($setting['value']) + 'value' => json_encode($setting['value']), ]); } @@ -51,7 +51,7 @@ public function testUpdateNoAuth() $this->assertDatabaseMissing('settings', [ 'name' => $setting['name'], - 'value' => json_encode($setting['value']) + 'value' => json_encode($setting['value']), ]); } @@ -65,7 +65,7 @@ public function testUpdateNoPermission() $this->assertDatabaseMissing('settings', [ 'name' => $setting['name'], - 'value' => json_encode($setting['value']) + 'value' => json_encode($setting['value']), ]); } @@ -109,34 +109,34 @@ public function getSearchFilters() return [ [ 'filter' => ['query' => 'states'], - 'result' => 'get_setting_by_key.json' + 'result' => 'get_setting_by_key.json', ], [ 'filter' => [ 'order_by' => 'name', - 'desc' => false + 'desc' => false, ], - 'result' => 'get_settings_check_order.json' + 'result' => 'get_settings_check_order.json', ], [ 'filters' => [ - 'per_page' => 2 + 'per_page' => 2, ], - 'fixture' => 'search_per_page.json' + 'fixture' => 'search_per_page.json', ], [ 'filters' => [ - 'all' => 1 + 'all' => 1, ], - 'fixture' => 'search_all.json' + 'fixture' => 'search_all.json', ], [ 'filters' => [ 'per_page' => 1, 'query' => 'states', ], - 'fixture' => 'search_complex.json' - ] + 'fixture' => 'search_complex.json', + ], ]; } @@ -160,8 +160,8 @@ public function getUserSearchFilters() return [ [ 'filter' => [], - 'result' => 'get_public_settings.json' - ] + 'result' => 'get_public_settings.json', + ], ]; } @@ -184,7 +184,7 @@ public function testSetNotExistsSetting() { $setting = [ 'name' => 'test.value', - 'value' => 123 + 'value' => 123, ]; $result = app(SettingService::class)->set($setting['name'], $setting['value']); @@ -193,7 +193,7 @@ public function testSetNotExistsSetting() $this->assertDatabaseHas('settings', [ 'name' => $setting['name'], - 'value' => json_encode($setting['value']) + 'value' => json_encode($setting['value']), ]); } @@ -201,7 +201,7 @@ public function testSetExistsSetting() { $setting = [ 'name' => 'attribute', - 'value' => 'new value' + 'value' => 'new value', ]; $result = app(SettingService::class)->set($setting['name'], $setting['value']); @@ -210,7 +210,7 @@ public function testSetExistsSetting() $this->assertDatabaseHas('settings', [ 'name' => $setting['name'], - 'value' => json_encode($setting['value']) + 'value' => json_encode($setting['value']), ]); } diff --git a/tests/Support/MediaTestTrait.php b/tests/Support/MediaTestTrait.php index edfc7e2..3725908 100644 --- a/tests/Support/MediaTestTrait.php +++ b/tests/Support/MediaTestTrait.php @@ -16,7 +16,7 @@ class: MediaService::class, callChain: array_fill(0, $callsCount, [ 'method' => 'generateName', 'arguments' => [], - 'result' => 'file.png' + 'result' => 'file.png', ]) ); } diff --git a/tests/UserTest.php b/tests/UserTest.php index ef0bb11..2213abe 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -83,14 +83,14 @@ public function testUpdateByUser() public function testUpdateWithEmailOfAnotherUser() { $response = $this->actingAs($this->admin)->json('put', '/users/2', [ - 'email' => 'admin@example.com' + 'email' => 'admin@example.com', ]); $response->assertUnprocessable(); $this->assertDatabaseMissing('users', [ 'id' => 2, - 'email' => 'admin@example.com' + 'email' => 'admin@example.com', ]); } @@ -172,11 +172,11 @@ public function testDeleteProfile() $response->assertCookieExpired('token'); $this->assertDatabaseMissing('users', [ - 'id' => 2 + 'id' => 2, ]); $this->assertDatabaseMissing('media', [ - 'owner_id' => 2 + 'owner_id' => 2, ]); } @@ -210,7 +210,7 @@ public function testDelete() $response->assertNoContent(); $this->assertDatabaseMissing('users', [ - 'id' => 2 + 'id' => 2, ]); } @@ -235,14 +235,14 @@ public function testDeleteNoAuth() $response->assertUnauthorized(); $this->assertDatabaseHas('users', [ - 'id' => 1 + 'id' => 1, ]); } public function testGetProfile() { $response = $this->actingAs($this->admin)->json('get', '/profile', [ - 'with' => ['role', 'media.owner'] + 'with' => ['role', 'media.owner'], ]); $response->assertOk(); @@ -253,7 +253,7 @@ public function testGetProfile() public function testGet() { $response = $this->actingAs($this->admin)->json('get', '/users/1', [ - 'with' => ['role', 'media.owner'] + 'with' => ['role', 'media.owner'], ]); $response->assertOk(); @@ -273,43 +273,43 @@ public function getSearchFilters() return [ [ 'filter' => ['all' => 1], - 'result' => 'search_by_all_user.json' + 'result' => 'search_by_all_user.json', ], [ 'filter' => [ 'page' => 1, 'per_page' => 2, ], - 'result' => 'search_by_page_per_page_user.json' + 'result' => 'search_by_page_per_page_user.json', ], [ 'filter' => ['query' => 'Another User'], - 'result' => 'get_users_by_name.json' + 'result' => 'get_users_by_name.json', ], [ 'filter' => ['query' => 'admin@example.com'], - 'result' => 'get_users_by_email.json' + 'result' => 'get_users_by_email.json', ], [ 'filter' => ['query' => 'Admin'], - 'result' => 'get_users_by_query.json' + 'result' => 'get_users_by_query.json', ], [ 'filter' => [ 'query' => 'Admin', 'with' => ['role'], 'order_by' => 'created_at', - 'desc' => false + 'desc' => false, ], - 'result' => 'get_users_complex.json' + 'result' => 'get_users_complex.json', ], [ 'filter' => [ 'desc' => false, - 'order_by' => 'name' + 'order_by' => 'name', ], - 'result' => 'get_users_check_order.json' - ] + 'result' => 'get_users_check_order.json', + ], ]; } diff --git a/tests/fixtures/InitCommandTest/migration.php b/tests/fixtures/InitCommandTest/migration.php index cc0abd6..677353c 100644 --- a/tests/fixtures/InitCommandTest/migration.php +++ b/tests/fixtures/InitCommandTest/migration.php @@ -15,7 +15,7 @@ public function up() 'name' => 'TestAdmin', 'email' => 'mail@mail.com', 'password' => Hash::make('123456'), - 'role_id' => '1' + 'role_id' => '1', ]); } }