From 8eb174a6dc764f9ad5c6efba195b61f98385bfcc Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 19 Apr 2019 19:36:36 +0800 Subject: [PATCH] Apply fixes from StyleCI (#35) --- app/Console/Commands/ExecuteInstallation.php | 1 + app/Http/Controllers/AdminController.php | 9 +++++---- app/Http/Controllers/AuthController.php | 5 +++-- app/Http/Controllers/MarketController.php | 2 +- app/Http/Controllers/PlayerController.php | 3 ++- app/Http/Controllers/ReportController.php | 6 ++++-- app/Http/Controllers/SetupController.php | 1 + app/Http/Controllers/TextureController.php | 2 ++ app/Http/Controllers/UpdateController.php | 6 +++++- app/Http/Controllers/UserController.php | 3 +++ app/Http/Middleware/CheckAdministrator.php | 1 + app/Http/Middleware/CheckSuperAdmin.php | 1 + app/Http/Middleware/CheckUserVerified.php | 1 + app/Listeners/CacheAvatarPreview.php | 1 + app/Listeners/CachePlayerExists.php | 2 +- app/Listeners/CachePlayerJson.php | 1 - app/Listeners/CacheSkinPreview.php | 2 +- app/Models/Report.php | 2 +- app/Models/User.php | 1 + app/Rules/Captcha.php | 3 ++- app/Services/PackageManager.php | 2 +- app/Services/Plugin.php | 6 ------ app/Services/PluginManager.php | 1 - app/helpers.php | 4 +++- routes/web.php | 2 +- tests/AdminControllerTest.php | 6 +++--- tests/AuthControllerTest.php | 4 +++- tests/CacheTest/CacheAvatarPreviewTest.php | 1 - tests/CacheTest/CachePlayerExistsTest.php | 2 -- tests/CacheTest/CachePlayerJsonTest.php | 2 -- tests/CacheTest/CacheSkinPreviewTest.php | 1 - tests/MiddlewareTest.php | 1 - tests/PlayerControllerTest.php | 4 ++-- tests/ReportControllerTest.php | 18 +++++++++--------- tests/RulesTest/CaptchaTest.php | 2 +- tests/ServicesTest/HookTest.php | 3 ++- tests/SkinlibControllerTest.php | 2 +- tests/UpdateControllerTest.php | 5 ----- tests/UserControllerTest.php | 2 +- 39 files changed, 64 insertions(+), 57 deletions(-) diff --git a/app/Console/Commands/ExecuteInstallation.php b/app/Console/Commands/ExecuteInstallation.php index 26122cd5..89494b8b 100644 --- a/app/Console/Commands/ExecuteInstallation.php +++ b/app/Console/Commands/ExecuteInstallation.php @@ -15,6 +15,7 @@ class ExecuteInstallation extends Command { if (\App\Http\Controllers\SetupController::checkTablesExist()) { $this->info('You have installed Blessing Skin Server. Nothing to do.'); + return; } diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 7aad0f07..c1f86432 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -23,6 +23,7 @@ class AdminController extends Controller $xAxis = Collection::times(30, function ($number) use ($today) { $time = Carbon::createFromTimestamp($today - (31 - $number) * 86400); + return $time->format('m-d'); }); @@ -57,13 +58,13 @@ class AdminController extends Controller return [ 'labels' => [ trans('admin.index.user-registration'), - trans('admin.index.texture-uploads') + trans('admin.index.texture-uploads'), ], 'xAxis' => $xAxis, 'data' => [ $xAxis->map($aligning($userRegistration)), $xAxis->map($aligning($textureUploads)), - ] + ], ]; } @@ -108,7 +109,7 @@ class AdminController extends Controller return view('admin.customize', [ 'forms' => compact('homepage', 'customJsCss'), - 'extra' => ['currentSkin' => option('color_scheme')] + 'extra' => ['currentSkin' => option('color_scheme')], ]); } @@ -455,7 +456,7 @@ class AdminController extends Controller return json(trans('admin.users.operations.score.success'), 0); } elseif ($action == 'permission') { $user->permission = $this->validate($request, [ - 'permission' => 'required|in:-1,0,1' + 'permission' => 'required|in:-1,0,1', ])['permission']; $user->save(); diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 91c6450d..e06be54d 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -75,6 +75,7 @@ class AuthController extends Controller { if (Auth::check()) { Auth::logout(); + return json(trans('auth.logout.success'), 0); } else { return json(trans('auth.logout.fail'), 1); @@ -89,7 +90,7 @@ class AuthController extends Controller 'player' => (bool) option('register_with_player_name'), 'recaptcha' => option('recaptcha_sitekey'), 'invisible' => (bool) option('recaptcha_invisible'), - ] + ], ]); } else { throw new PrettyPageException(trans('auth.register.close'), 7); @@ -166,7 +167,7 @@ class AuthController extends Controller 'extra' => [ 'recaptcha' => option('recaptcha_sitekey'), 'invisible' => (bool) option('recaptcha_invisible'), - ] + ], ]); } else { throw new PrettyPageException(trans('auth.forgot.disabled'), 8); diff --git a/app/Http/Controllers/MarketController.php b/app/Http/Controllers/MarketController.php index 60935071..d9c785e4 100644 --- a/app/Http/Controllers/MarketController.php +++ b/app/Http/Controllers/MarketController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use Exception; -use ZipArchive; use Illuminate\Support\Arr; use Illuminate\Http\Request; use App\Services\PluginManager; @@ -93,6 +92,7 @@ class MarketController extends Controller } catch (Exception $e) { return json($e->getMessage(), 1); } + return json(trans('admin.plugins.market.install-success'), 0); } diff --git a/app/Http/Controllers/PlayerController.php b/app/Http/Controllers/PlayerController.php index 3a88539e..176bc80c 100644 --- a/app/Http/Controllers/PlayerController.php +++ b/app/Http/Controllers/PlayerController.php @@ -58,7 +58,7 @@ class PlayerController extends Controller 'length' => trans( 'user.player.player-name-length', ['min' => option('player_name_length_min'), 'max' => option('player_name_length_max')] - ) + ), ]); } @@ -186,6 +186,7 @@ class PlayerController extends Controller } }, ['skin', 'cape']); $this->player->save(); + return json(trans('user.player.clear.success', ['name' => $this->player->name]), 0); } diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 2efeb307..9f45d45c 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -14,7 +14,7 @@ class ReportController extends Controller { $data = $this->validate($request, [ 'tid' => 'required|exists:textures', - 'reason' => 'required' + 'reason' => 'required', ]); $reporter = auth()->user(); @@ -71,6 +71,7 @@ class ReportController extends Controller if ($report->informer) { $report->reporterName = $report->informer->nickname; } + return $report; }); @@ -84,7 +85,7 @@ class ReportController extends Controller { $data = $this->validate($request, [ 'id' => 'required|exists:reports', - 'action' => ['required', Rule::in(['delete', 'ban', 'reject'])] + 'action' => ['required', Rule::in(['delete', 'ban', 'reject'])], ]); $report = Report::find($data['id']); @@ -102,6 +103,7 @@ class ReportController extends Controller } $report->status = Report::REJECTED; $report->save(); + return json(trans('general.op-success'), 0, ['status' => Report::REJECTED]); } diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 77fe7423..b9025878 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -32,6 +32,7 @@ class SetupController extends Controller if ($request->isMethod('get')) { try { DB::getPdo(); + return redirect('setup/info'); // @codeCoverageIgnoreStart } catch (\Exception $e) { diff --git a/app/Http/Controllers/TextureController.php b/app/Http/Controllers/TextureController.php index 81fc77c6..9c6e0f35 100644 --- a/app/Http/Controllers/TextureController.php +++ b/app/Http/Controllers/TextureController.php @@ -111,6 +111,7 @@ class TextureController extends Controller return $responses[0]; // @codeCoverageIgnore } else { $png = Minecraft::generateAvatarFromSkin(Storage::disk('textures')->read($t->hash), $size); + return Response::png(png($png)); } } @@ -209,6 +210,7 @@ class TextureController extends Controller { $player = Player::where('name', $player_name)->first(); abort_if($player->isBanned(), 403, trans('general.player-banned')); + return $player; } diff --git a/app/Http/Controllers/UpdateController.php b/app/Http/Controllers/UpdateController.php index d09c78f1..3d8ccda4 100644 --- a/app/Http/Controllers/UpdateController.php +++ b/app/Http/Controllers/UpdateController.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers; -use Log; use Exception; use Illuminate\Support\Arr; use Illuminate\Http\Request; @@ -32,6 +31,7 @@ class UpdateController extends Controller ]; $error = $this->error; $extra = ['canUpdate' => $this->canUpdate()]; + return view('admin.update', compact('info', 'error', 'extra')); } @@ -51,9 +51,11 @@ class UpdateController extends Controller case 'download': try { $package->download($this->info['url'], $path)->extract(base_path()); + return json(trans('admin.update.complete'), 0); } catch (Exception $e) { report($e); + return json($e->getMessage(), 1); } case 'progress': @@ -79,12 +81,14 @@ class UpdateController extends Controller $this->error = $e->getMessage(); } } + return $this->info; } protected function canUpdate() { $this->getUpdateInfo(); + return Comparator::greaterThan(Arr::get($this->info, 'latest'), $this->currentVersion); } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index b64c3c02..4dbcd3ea 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -158,6 +158,7 @@ class UserController extends Controller public function profile() { $user = Auth::user(); + return view('user.profile') ->with('extra', [ 'unverified' => option('require_verification') && ! $user->verified, @@ -282,6 +283,7 @@ class UserController extends Controller if ($tid == 0) { $user->avatar = 0; $user->save(); + return json(trans('user.profile.avatar.success'), 0); } @@ -293,6 +295,7 @@ class UserController extends Controller $user->avatar = $tid; $user->save(); + return json(trans('user.profile.avatar.success'), 0); } else { return json(trans('skinlib.non-existent'), 1); diff --git a/app/Http/Middleware/CheckAdministrator.php b/app/Http/Middleware/CheckAdministrator.php index c6a54b4c..cb0307b3 100644 --- a/app/Http/Middleware/CheckAdministrator.php +++ b/app/Http/Middleware/CheckAdministrator.php @@ -7,6 +7,7 @@ class CheckAdministrator public function handle($request, \Closure $next) { abort_unless(auth()->user()->isAdmin(), 403, trans('auth.check.admin')); + return $next($request); } } diff --git a/app/Http/Middleware/CheckSuperAdmin.php b/app/Http/Middleware/CheckSuperAdmin.php index 4d3fb00e..864f48c1 100644 --- a/app/Http/Middleware/CheckSuperAdmin.php +++ b/app/Http/Middleware/CheckSuperAdmin.php @@ -10,6 +10,7 @@ class CheckSuperAdmin public function handle($request, Closure $next) { abort_if(auth()->user()->permission != User::SUPER_ADMIN, 403, trans('auth.check.super-admin')); + return $next($request); } } diff --git a/app/Http/Middleware/CheckUserVerified.php b/app/Http/Middleware/CheckUserVerified.php index 71c47ac0..2a58f16d 100644 --- a/app/Http/Middleware/CheckUserVerified.php +++ b/app/Http/Middleware/CheckUserVerified.php @@ -7,6 +7,7 @@ class CheckUserVerified public function handle($request, \Closure $next) { abort_if(option('require_verification') && ! auth()->user()->verified, 403, trans('auth.check.verified')); + return $next($request); } } diff --git a/app/Listeners/CacheAvatarPreview.php b/app/Listeners/CacheAvatarPreview.php index f49d2539..59451193 100644 --- a/app/Listeners/CacheAvatarPreview.php +++ b/app/Listeners/CacheAvatarPreview.php @@ -17,6 +17,7 @@ class CacheAvatarPreview $content = Cache::rememberForever($key, function () use ($texture, $size) { $res = Storage::disk('textures')->read($texture->hash); + return png(Minecraft::generateAvatarFromSkin($res, $size)); }); diff --git a/app/Listeners/CachePlayerExists.php b/app/Listeners/CachePlayerExists.php index f8e9a530..809ae679 100644 --- a/app/Listeners/CachePlayerExists.php +++ b/app/Listeners/CachePlayerExists.php @@ -3,7 +3,6 @@ namespace App\Listeners; use Cache; -use Storage; use App\Events; use App\Models\Player; use Illuminate\Events\Dispatcher; @@ -25,6 +24,7 @@ class CachePlayerExists if (! $player) { Cache::forever($key, '1'); + return false; } else { return true; diff --git a/app/Listeners/CachePlayerJson.php b/app/Listeners/CachePlayerJson.php index d88df8e4..c4f2026a 100644 --- a/app/Listeners/CachePlayerJson.php +++ b/app/Listeners/CachePlayerJson.php @@ -3,7 +3,6 @@ namespace App\Listeners; use Cache; -use Storage; use App\Models\Player; use App\Events\GetPlayerJson; use App\Events\PlayerProfileUpdated; diff --git a/app/Listeners/CacheSkinPreview.php b/app/Listeners/CacheSkinPreview.php index 0e10b083..970811b4 100644 --- a/app/Listeners/CacheSkinPreview.php +++ b/app/Listeners/CacheSkinPreview.php @@ -27,7 +27,7 @@ class CacheSkinPreview }); return response()->png($content, 200, [ - 'Last-Modified' => Storage::disk('textures')->lastModified($texture->hash) + 'Last-Modified' => Storage::disk('textures')->lastModified($texture->hash), ]); } } diff --git a/app/Models/Report.php b/app/Models/Report.php index 2d0f9f2d..408a23b4 100644 --- a/app/Models/Report.php +++ b/app/Models/Report.php @@ -9,7 +9,7 @@ class Report extends Model public const CREATED_AT = 'report_at'; public const UPDATED_AT = null; - public const PENDING = 0; + public const PENDING = 0; public const RESOLVED = 1; public const REJECTED = 2; diff --git a/app/Models/User.php b/app/Models/User.php index 4ae3aebb..378400f1 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -68,6 +68,7 @@ class User extends Authenticatable public function getPlayerNameAttribute() { $player = $this->players->first(); + return $player ? $player->name : ''; } diff --git a/app/Rules/Captcha.php b/app/Rules/Captcha.php index df673361..bcb229b2 100644 --- a/app/Rules/Captcha.php +++ b/app/Rules/Captcha.php @@ -22,10 +22,11 @@ class Captcha implements Rule 'form_params' => [ 'secret' => $secretkey, 'response' => $value, - ] + ], ]); if ($response->getStatusCode() == 200) { $body = json_decode((string) $response->getBody()); + return $body->success; } } catch (\GuzzleHttp\Exception\RequestException $e) { diff --git a/app/Services/PackageManager.php b/app/Services/PackageManager.php index df9cf4f9..04b1ba82 100644 --- a/app/Services/PackageManager.php +++ b/app/Services/PackageManager.php @@ -28,7 +28,7 @@ class PackageManager try { $this->guzzle->request('GET', $url, [ 'sink' => $path, - 'progress' => $this->onProgress + 'progress' => $this->onProgress, ]); } catch (Exception $e) { throw new Exception(trans('admin.download.errors.download', ['error' => $e->getMessage()])); diff --git a/app/Services/Plugin.php b/app/Services/Plugin.php index 0c8696cd..dc43885e 100644 --- a/app/Services/Plugin.php +++ b/app/Services/Plugin.php @@ -71,17 +71,11 @@ class Plugin $this->packageInfo = $packageInfo; } - /** - * {@inheritdoc} - */ public function __get($name) { return $this->packageInfoAttribute(snake_case($name, '-')); } - /** - * {@inheritdoc} - */ public function __isset($name) { return isset($this->{$name}) || $this->packageInfoAttribute(snake_case($name, '-')); diff --git a/app/Services/PluginManager.php b/app/Services/PluginManager.php index 872da1c3..d2ac7891 100644 --- a/app/Services/PluginManager.php +++ b/app/Services/PluginManager.php @@ -4,7 +4,6 @@ namespace App\Services; use Storage; use App\Events; -use App\Services\Option; use Composer\Semver\Semver; use Illuminate\Support\Arr; use Composer\Semver\Comparator; diff --git a/app/helpers.php b/app/helpers.php index 193e1577..1f856c4f 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -3,7 +3,6 @@ use Carbon\Carbon; use App\Models\User; use Illuminate\Support\Arr; -use Illuminate\Support\Str; if (! function_exists('webpack_assets')) { function webpack_assets($relativeUri) @@ -13,6 +12,7 @@ if (! function_exists('webpack_assets')) { } else { $path = app('webpack')->$relativeUri; $cdn = option('cdn_address'); + return $cdn ? "$cdn/app/$path" : url("/app/$path"); } } @@ -192,6 +192,7 @@ if (! function_exists('option')) { if (is_array($key)) { $options->set($key); + return; } @@ -360,6 +361,7 @@ if (! function_exists('png')) { $image = ob_get_contents(); ob_end_clean(); imagedestroy($resource); + return $image; } } diff --git a/routes/web.php b/routes/web.php index 3f5a4d01..a8bb9f8e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -43,7 +43,7 @@ Route::group(['prefix' => 'auth'], function () { */ Route::group([ 'middleware' => ['web', 'auth', \App\Http\Middleware\RequireBindPlayer::class], - 'prefix' => 'user' + 'prefix' => 'user', ], function () { Route::any('', 'UserController@index'); Route::get('/score-info', 'UserController@scoreInfo'); diff --git a/tests/AdminControllerTest.php b/tests/AdminControllerTest.php index 9e3f562c..bf9e7472 100644 --- a/tests/AdminControllerTest.php +++ b/tests/AdminControllerTest.php @@ -29,7 +29,7 @@ class AdminControllerTest extends BrowserKitTestCase $this->getJson('/admin/chart') ->seeJson(['labels' => [ trans('admin.index.user-registration'), - trans('admin.index.texture-uploads') + trans('admin.index.texture-uploads'), ]]) ->seeJsonStructure(['labels', 'xAxis', 'data']); } @@ -468,7 +468,7 @@ class AdminControllerTest extends BrowserKitTestCase $this->postJson('/admin/users', [ 'uid' => $user->uid, 'action' => 'permission', - 'permission' => -2 + 'permission' => -2, ])->seeJsonStructure(['errors' => ['permission']]); $user = User::find($user->uid); $this->assertEquals(User::NORMAL, $user->permission); @@ -477,7 +477,7 @@ class AdminControllerTest extends BrowserKitTestCase $this->postJson('/admin/users', [ 'uid' => $user->uid, 'action' => 'permission', - 'permission' => -1 + 'permission' => -1, ])->seeJson([ 'errno' => 0, 'msg' => trans('admin.users.operations.permission'), diff --git a/tests/AuthControllerTest.php b/tests/AuthControllerTest.php index e12f9970..71428ba1 100644 --- a/tests/AuthControllerTest.php +++ b/tests/AuthControllerTest.php @@ -21,7 +21,9 @@ class AuthControllerTest extends TestCase { parent::setUp(); app()->instance(\App\Rules\Captcha::class, new class extends \App\Rules\Captcha { - public function __construct(\GuzzleHttp\Client $client = null) {} + public function __construct(\GuzzleHttp\Client $client = null) + { + } public function passes($attribute, $value) { diff --git a/tests/CacheTest/CacheAvatarPreviewTest.php b/tests/CacheTest/CacheAvatarPreviewTest.php index 7d4a07eb..7cd39f29 100644 --- a/tests/CacheTest/CacheAvatarPreviewTest.php +++ b/tests/CacheTest/CacheAvatarPreviewTest.php @@ -9,7 +9,6 @@ use Storage; use App\Models\Texture; use App\Events\GetAvatarPreview; use Illuminate\Http\UploadedFile; -use App\Listeners\CacheAvatarPreview; use Illuminate\Foundation\Testing\DatabaseTransactions; class CacheAvatarPreviewTest extends TestCase diff --git a/tests/CacheTest/CachePlayerExistsTest.php b/tests/CacheTest/CachePlayerExistsTest.php index 18597c9b..29f0e3c4 100644 --- a/tests/CacheTest/CachePlayerExistsTest.php +++ b/tests/CacheTest/CachePlayerExistsTest.php @@ -6,8 +6,6 @@ use Cache; use Event; use App\Events; use App\Models\Player; -use Illuminate\Http\UploadedFile; -use App\Listeners\CachePlayerExists; use Illuminate\Foundation\Testing\DatabaseTransactions; class CachePlayerExistsTest extends TestCase diff --git a/tests/CacheTest/CachePlayerJsonTest.php b/tests/CacheTest/CachePlayerJsonTest.php index 0be3bdab..9454d3ff 100644 --- a/tests/CacheTest/CachePlayerJsonTest.php +++ b/tests/CacheTest/CachePlayerJsonTest.php @@ -6,8 +6,6 @@ use Cache; use Event; use App\Models\Player; use App\Events\GetPlayerJson; -use Illuminate\Http\UploadedFile; -use App\Listeners\CachePlayerJson; use App\Events\PlayerProfileUpdated; use Illuminate\Foundation\Testing\DatabaseTransactions; diff --git a/tests/CacheTest/CacheSkinPreviewTest.php b/tests/CacheTest/CacheSkinPreviewTest.php index 27852fd9..44deb56c 100644 --- a/tests/CacheTest/CacheSkinPreviewTest.php +++ b/tests/CacheTest/CacheSkinPreviewTest.php @@ -9,7 +9,6 @@ use Storage; use App\Models\Texture; use App\Events\GetSkinPreview; use Illuminate\Http\UploadedFile; -use App\Listeners\CacheSkinPreview; use Illuminate\Foundation\Testing\DatabaseTransactions; class CacheSkinPreviewTest extends TestCase diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 2b2e36f4..e34baf31 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -2,7 +2,6 @@ namespace Tests; -use DB; use App\Models\User; use App\Models\Player; use App\Services\Facades\Option; diff --git a/tests/PlayerControllerTest.php b/tests/PlayerControllerTest.php index a1299045..2e805e43 100644 --- a/tests/PlayerControllerTest.php +++ b/tests/PlayerControllerTest.php @@ -305,7 +305,7 @@ class PlayerControllerTest extends TestCase $this->postJson('/user/player/bind', ['player' => 'abc']) ->assertJson([ 'errno' => 0, - 'msg' => trans('user.player.bind.success') + 'msg' => trans('user.player.bind.success'), ]); Event::assertDispatched(Events\CheckPlayerExists::class); Event::assertDispatched(Events\PlayerWillBeAdded::class); @@ -322,7 +322,7 @@ class PlayerControllerTest extends TestCase $this->postJson('/user/player/bind', ['player' => $player2->name]) ->assertJson([ 'errno' => 1, - 'msg' => trans('user.player.rename.repeated') + 'msg' => trans('user.player.rename.repeated'), ]); $this->postJson('/user/player/bind', ['player' => $player->name]) diff --git a/tests/ReportControllerTest.php b/tests/ReportControllerTest.php index 9c92c8ec..13c0d7cc 100644 --- a/tests/ReportControllerTest.php +++ b/tests/ReportControllerTest.php @@ -36,7 +36,7 @@ class ReportControllerTest extends TestCase $this->postJson('/skinlib/report', ['tid' => $texture->tid, 'reason' => 'reason']) ->assertJson([ 'errno' => 1, - 'msg' => trans('skinlib.upload.lack-score') + 'msg' => trans('skinlib.upload.lack-score'), ]); // Success @@ -44,7 +44,7 @@ class ReportControllerTest extends TestCase $this->postJson('/skinlib/report', ['tid' => $texture->tid, 'reason' => 'reason']) ->assertJson([ 'errno' => 0, - 'msg' => trans('skinlib.report.success') + 'msg' => trans('skinlib.report.success'), ]); $user->refresh(); $this->assertEquals(5, $user->score); @@ -58,7 +58,7 @@ class ReportControllerTest extends TestCase $this->postJson('/skinlib/report', ['tid' => $texture->tid, 'reason' => 'reason']) ->assertJson([ 'errno' => 1, - 'msg' => trans('skinlib.report.duplicate') + 'msg' => trans('skinlib.report.duplicate'), ]); } @@ -108,7 +108,7 @@ class ReportControllerTest extends TestCase 'status' => Report::PENDING, 'uploaderName' => $uploader->nickname, 'reporterName' => $reporter->nickname, - ]] + ]], ]); } @@ -148,7 +148,7 @@ class ReportControllerTest extends TestCase $this->postJson('/admin/reports', ['id' => $report->id, 'action' => 'reject']) ->assertJson([ 'errno' => 1, - 'msg' => trans('admin.report-reviewed') + 'msg' => trans('admin.report-reviewed'), ]); // Reject @@ -159,7 +159,7 @@ class ReportControllerTest extends TestCase ->assertJson([ 'errno' => 0, 'msg' => trans('general.op-success'), - 'status' => Report::REJECTED + 'status' => Report::REJECTED, ]); $report->refresh(); $reporter->refresh(); @@ -186,7 +186,7 @@ class ReportControllerTest extends TestCase ->assertJson([ 'errno' => 0, 'msg' => trans('general.op-success'), - 'status' => Report::RESOLVED + 'status' => Report::RESOLVED, ]); $report->refresh(); $reporter->refresh(); @@ -207,7 +207,7 @@ class ReportControllerTest extends TestCase ->assertJson([ 'errno' => 0, 'msg' => trans('general.op-success'), - 'status' => Report::RESOLVED + 'status' => Report::RESOLVED, ]); $reporter->refresh(); $this->assertEquals(User::BANNED, $uploader->permission); @@ -223,7 +223,7 @@ class ReportControllerTest extends TestCase $this->postJson('/admin/reports', ['id' => $report->id, 'action' => 'ban']) ->assertJson([ 'errno' => 1, - 'msg' => trans('admin.users.operations.no-permission') + 'msg' => trans('admin.users.operations.no-permission'), ]); $report->refresh(); $this->assertEquals(Report::PENDING, $report->status); diff --git a/tests/RulesTest/CaptchaTest.php b/tests/RulesTest/CaptchaTest.php index 33272636..5b6648ba 100644 --- a/tests/RulesTest/CaptchaTest.php +++ b/tests/RulesTest/CaptchaTest.php @@ -28,7 +28,7 @@ class CaptchaTest extends TestCase option(['recaptcha_secretkey' => 'secret']); $mock = new MockHandler([ new Response(403), - new Response(200, [], json_encode(['success' => true])) + new Response(200, [], json_encode(['success' => true])), ]); $handler = HandlerStack::create($mock); $client = new Client(['handler' => $handler]); diff --git a/tests/ServicesTest/HookTest.php b/tests/ServicesTest/HookTest.php index 47fd9728..7f7bf0d4 100644 --- a/tests/ServicesTest/HookTest.php +++ b/tests/ServicesTest/HookTest.php @@ -38,7 +38,8 @@ class HookTest extends TestCase public function testAddRoute() { Hook::addRoute(function ($route) { - $route->any('/test-hook', function () {}); + $route->any('/test-hook', function () { + }); }); event(new \App\Events\ConfigureRoutes(resolve(\Illuminate\Routing\Router::class))); $this->get('/test-hook')->assertSuccessful(); diff --git a/tests/SkinlibControllerTest.php b/tests/SkinlibControllerTest.php index 445b2bb3..19976187 100644 --- a/tests/SkinlibControllerTest.php +++ b/tests/SkinlibControllerTest.php @@ -693,7 +693,7 @@ class SkinlibControllerTest extends TestCase // Private texture $texture = factory(Texture::class)->create([ 'uploader' => $uploader->uid, - 'public' => false + 'public' => false, ]); $uploader->refresh(); $this->actingAs($uploader) diff --git a/tests/UpdateControllerTest.php b/tests/UpdateControllerTest.php index 33755477..8175c68f 100644 --- a/tests/UpdateControllerTest.php +++ b/tests/UpdateControllerTest.php @@ -2,15 +2,10 @@ namespace Tests; -use Cache; -use Exception; -use Carbon\Carbon; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use App\Services\PackageManager; -use Illuminate\Support\Facades\File; use Tests\Concerns\MocksGuzzleClient; -use Illuminate\Support\Facades\Storage; use GuzzleHttp\Exception\RequestException; use Illuminate\Foundation\Testing\DatabaseTransactions; diff --git a/tests/UserControllerTest.php b/tests/UserControllerTest.php index fdbe098e..b53f1db4 100644 --- a/tests/UserControllerTest.php +++ b/tests/UserControllerTest.php @@ -470,7 +470,7 @@ class UserControllerTest extends TestCase // Reset avatar $this->postJson('/user/profile/avatar', ['tid' => 0]) - ->assertJson(['errno' => 0,]); + ->assertJson(['errno' => 0]); $this->assertEquals(0, User::find($user->uid)->avatar); } }