diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 0f665dfe..b6233352 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -233,6 +233,7 @@ class AuthController extends Controller { $builder->build(100, 34); session(['captcha' => $builder->getPhrase()]); + return response($builder->output(), 200, [ 'Content-Type' => 'image/jpeg', 'Cache-Control' => 'no-store', diff --git a/app/Http/Controllers/PluginController.php b/app/Http/Controllers/PluginController.php index ee76662b..7bf8983a 100644 --- a/app/Http/Controllers/PluginController.php +++ b/app/Http/Controllers/PluginController.php @@ -39,15 +39,18 @@ class PluginController extends Controller if (! $detail['version']) { $plugin = $plugins->get($name); $name = $plugin ? trans($plugin->title) : $name; + return trans('admin.plugins.operations.unsatisfied.disabled', compact('name')); } else { $title = trans($plugins->get($name)->title); + return trans('admin.plugins.operations.unsatisfied.version', compact('title', 'constraint')); } })->values()->all(); $conflicts = $result['conflicts']->map(function ($detail, $name) use ($plugins) { $title = trans($plugins->get($name)->title); + return trans('admin.plugins.operations.unsatisfied.conflict', compact('title')); })->values()->all(); diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 9ca67916..40fd3c04 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -165,6 +165,7 @@ class SetupController extends Controller collect($filesystem->files(database_path('update_scripts'))) ->filter(function (SplFileInfo $file) { $name = $file->getFilenameWithoutExtension(); + return preg_match('/^\d+\.\d+\.\d+$/', $name) > 0 && Comparator::greaterThanOrEqualTo($name, option('version')); }) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 1e396eb3..f4aaa527 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -47,7 +47,7 @@ class UserController extends Controller 'score-to' => $to, 'return-score' => option('return_score') ? trans('user.score-intro.will-return-score') - : trans('user.score-intro.no-return-score') + : trans('user.score-intro.no-return-score'), ])); return view('user.index')->with([ diff --git a/app/Http/Middleware/CheckInstallation.php b/app/Http/Middleware/CheckInstallation.php index 19ab0076..ed2ec608 100644 --- a/app/Http/Middleware/CheckInstallation.php +++ b/app/Http/Middleware/CheckInstallation.php @@ -3,7 +3,6 @@ namespace App\Http\Middleware; use Illuminate\Filesystem\Filesystem; -use App\Http\Controllers\SetupController; class CheckInstallation { diff --git a/app/Models/User.php b/app/Models/User.php index 17a3ad16..34f95f04 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,12 +2,10 @@ namespace App\Models; -use Illuminate\Support\Arr; use Laravel\Passport\HasApiTokens; use App\Models\Concerns\HasPassword; use Tymon\JWTAuth\Contracts\JWTSubject; use Illuminate\Notifications\Notifiable; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable implements JWTSubject diff --git a/app/Rules/Captcha.php b/app/Rules/Captcha.php index df2130eb..8f65f643 100644 --- a/app/Rules/Captcha.php +++ b/app/Rules/Captcha.php @@ -37,6 +37,7 @@ class Captcha implements Rule } $builder = new CaptchaBuilder(session()->pull('captcha')); + return $builder->testPhrase($value); } diff --git a/app/Services/Option.php b/app/Services/Option.php index cbe4931b..7a50a1bf 100644 --- a/app/Services/Option.php +++ b/app/Services/Option.php @@ -16,6 +16,7 @@ class Option $cachePath = storage_path('options/cache.php'); if ($filesystem->exists($cachePath)) { $this->items = collect($filesystem->getRequire($cachePath)); + return; } diff --git a/app/Services/Translations/Yaml.php b/app/Services/Translations/Yaml.php index 9e130b8e..47b23b84 100644 --- a/app/Services/Translations/Yaml.php +++ b/app/Services/Translations/Yaml.php @@ -26,6 +26,7 @@ class Yaml implements TranslationLoader public function loadYaml(string $path): array { $key = 'yaml-trans-'.md5($path).'-'.filemtime($path); + return $this->cache->rememberForever($key, function () use ($path) { return YamlParser::parseFile($path); }); diff --git a/routes/web.php b/routes/web.php index d96b3320..fd7e9aa8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -157,7 +157,7 @@ Route::group(['middleware' => ['authorize', 'admin'], 'prefix' => 'admin'], func }); }); -/** +/* * Setup and Update */ Route::group(['prefix' => 'setup'], function () { diff --git a/tests/AdminControllerTest.php b/tests/AdminControllerTest.php index 43a69e00..b8b8cd04 100644 --- a/tests/AdminControllerTest.php +++ b/tests/AdminControllerTest.php @@ -123,7 +123,7 @@ class AdminControllerTest extends TestCase $this->mock(\App\Services\PluginManager::class, function ($mock) { $mock->shouldReceive('getEnabledPlugins') ->andReturn(collect([ - 'a' => new Plugin('', ['title' => 'MyPlugin', 'version' => '0.0.0']) + 'a' => new Plugin('', ['title' => 'MyPlugin', 'version' => '0.0.0']), ])); }); diff --git a/tests/BrowserKitTestCase.php b/tests/BrowserKitTestCase.php index f1d8b96b..afaff10d 100644 --- a/tests/BrowserKitTestCase.php +++ b/tests/BrowserKitTestCase.php @@ -2,7 +2,6 @@ namespace Tests; -use DB; use Artisan; use Laravel\BrowserKitTesting\TestCase; diff --git a/tests/CommandsTest/BsInstallCommandTest.php b/tests/CommandsTest/BsInstallCommandTest.php index 28989a97..00ff324b 100644 --- a/tests/CommandsTest/BsInstallCommandTest.php +++ b/tests/CommandsTest/BsInstallCommandTest.php @@ -2,7 +2,6 @@ namespace Tests; -use Schema; use App\Models\User; use Illuminate\Filesystem\Filesystem; use Illuminate\Foundation\Testing\DatabaseTransactions; diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index 8cb04d11..17e74abd 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -7,7 +7,6 @@ use App\Models\User; use App\Models\Player; use App\Services\Facades\Option; use Illuminate\Filesystem\Filesystem; -use Illuminate\Support\Facades\Schema; use Illuminate\Foundation\Testing\DatabaseTransactions; class MiddlewareTest extends TestCase diff --git a/tests/ModelsTest/UserTest.php b/tests/ModelsTest/UserTest.php index 7d0e5429..613f4499 100644 --- a/tests/ModelsTest/UserTest.php +++ b/tests/ModelsTest/UserTest.php @@ -2,11 +2,8 @@ namespace Tests; -use Schema; -use Carbon\Carbon; use App\Models\User; use App\Models\Player; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Testing\DatabaseTransactions; class UserTest extends TestCase diff --git a/tests/PlayerControllerTest.php b/tests/PlayerControllerTest.php index 8dbe6180..9ca6d244 100644 --- a/tests/PlayerControllerTest.php +++ b/tests/PlayerControllerTest.php @@ -194,6 +194,7 @@ class PlayerControllerTest extends TestCase $pid = $player->pid; $filter->add('user_can_rename_player', function ($can, $player, $newName) { $this->assertEquals('new', $newName); + return new Rejection('rejected'); }); $name = factory(Player::class)->create()->name; @@ -219,12 +220,14 @@ class PlayerControllerTest extends TestCase [$player, $newName] = $payload; $this->assertEquals($pid, $player->pid); $this->assertEquals('new_name', $newName); + return true; }); Event::assertDispatched('player.renamed', function ($event, $payload) use ($pid) { [$player, $oldName] = $payload; $this->assertEquals($pid, $player->pid); $this->assertNotEquals('new_name', $oldName); + return true; }); diff --git a/tests/PluginControllerTest.php b/tests/PluginControllerTest.php index 3bf84c1b..34ccafcb 100644 --- a/tests/PluginControllerTest.php +++ b/tests/PluginControllerTest.php @@ -97,7 +97,7 @@ class PluginControllerTest extends TestCase ->with('whatever') ->once() ->andReturn(null); - $mock->shouldReceive('get') + $mock->shouldReceive('get') ->with('conf') ->once() ->andReturn(new Plugin('', ['title' => 'conf'])); diff --git a/tests/ServicesTest/FilterTest.php b/tests/ServicesTest/FilterTest.php index 17c697a5..13b58865 100644 --- a/tests/ServicesTest/FilterTest.php +++ b/tests/ServicesTest/FilterTest.php @@ -9,8 +9,10 @@ class FilterTest extends TestCase public function testAdd() { $filter = new Filter(); - $filter->add('hook', function () {}); - $filter->add('hook', function () {}, 10); + $filter->add('hook', function () { + }); + $filter->add('hook', function () { + }, 10); $this->assertCount(2, $filter->getListeners('hook')); } @@ -21,6 +23,7 @@ class FilterTest extends TestCase $filter->add('hook', function ($value, $addition) { $this->assertEquals('add', $addition); + return $value.'_medium'; }); $filter->add('hook', function ($value) { @@ -38,7 +41,8 @@ class FilterTest extends TestCase $filter->remove('hook'); $this->assertCount(0, $filter->getListeners('hook')); - $filter->add('hook', function () {}); + $filter->add('hook', function () { + }); $this->assertCount(1, $filter->getListeners('hook')); $filter->remove('hook'); $this->assertCount(0, $filter->getListeners('hook')); diff --git a/tests/ServicesTest/OptionFormTest.php b/tests/ServicesTest/OptionFormTest.php index 5415b58f..32a26580 100644 --- a/tests/ServicesTest/OptionFormTest.php +++ b/tests/ServicesTest/OptionFormTest.php @@ -2,7 +2,6 @@ namespace Tests; -use Illuminate\Support\Str; use App\Services\OptionForm; use Symfony\Component\DomCrawler\Crawler; diff --git a/tests/ServicesTest/PluginManagerTest.php b/tests/ServicesTest/PluginManagerTest.php index f3495861..5b86bea7 100644 --- a/tests/ServicesTest/PluginManagerTest.php +++ b/tests/ServicesTest/PluginManagerTest.php @@ -368,6 +368,7 @@ class PluginManagerTest extends TestCase resolve(PluginManager::class)->boot(); Event::assertDispatched(Events\PluginBootFailed::class, function ($event) { $this->assertEquals('mayaka', $event->plugin->name); + return true; }); diff --git a/tests/TestCase.php b/tests/TestCase.php index bad4e36b..de43ef4b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace Tests; -use DB; use Artisan; class TestCase extends \Illuminate\Foundation\Testing\TestCase diff --git a/tests/UserControllerTest.php b/tests/UserControllerTest.php index bcdc126e..1760584c 100644 --- a/tests/UserControllerTest.php +++ b/tests/UserControllerTest.php @@ -233,6 +233,7 @@ class UserControllerTest extends TestCase $filter->add('user_can_edit_profile', function ($can, $action, $addition) { $this->assertEquals('nope', $action); $this->assertEquals([], $addition); + return new Rejection('rejected'); }); $this->actingAs($user) @@ -252,6 +253,7 @@ class UserControllerTest extends TestCase $this->assertEquals($uid, $user->uid); $this->assertEquals('', $action); $this->assertEquals([], $addition); + return true; }); @@ -292,6 +294,7 @@ class UserControllerTest extends TestCase $this->assertEquals($uid, $user->uid); $this->assertEquals('nickname', $action); $this->assertEquals(['new_nickname' => 'nickname'], $addition); + return true; }); Event::assertDispatched(Events\UserProfileUpdated::class); @@ -356,6 +359,7 @@ class UserControllerTest extends TestCase 'current_password' => '12345678', 'new_password' => '87654321', ], $addition); + return true; }); Event::assertDispatched(Events\EncryptUserPassword::class); @@ -430,6 +434,7 @@ class UserControllerTest extends TestCase 'new_email' => 'a@b.c', 'password' => '87654321', ], $addition); + return true; }); $this->assertEquals('a@b.c', User::find($user->uid)->email); @@ -480,10 +485,12 @@ class UserControllerTest extends TestCase ]); Event::assertDispatched('user.deleting', function ($eventName, $payload) use ($uid) { $this->assertEquals($uid, $payload[0]->uid); + return true; }); Event::assertDispatched('user.deleted', function ($eventName, $payload) use ($uid) { $this->assertEquals($uid, $payload[0]->uid); + return true; }); $this->assertNull(User::find($user->uid)); @@ -547,6 +554,7 @@ class UserControllerTest extends TestCase [$user, $tid] = $payload; $this->assertEquals($uid, $user->uid); $this->assertEquals($steve->tid, $tid); + return true; } ); @@ -556,6 +564,7 @@ class UserControllerTest extends TestCase [$user, $tid] = $payload; $this->assertEquals($uid, $user->uid); $this->assertEquals($steve->tid, $tid); + return true; } ); @@ -571,6 +580,7 @@ class UserControllerTest extends TestCase [$user, $tid] = $payload; $this->assertEquals($uid, $user->uid); $this->assertEquals(0, $tid); + return true; } ); @@ -580,6 +590,7 @@ class UserControllerTest extends TestCase $filter->add('user_can_update_avatar', function ($can, $user, $tid) use ($uid, $steve) { $this->assertEquals($uid, $user->uid); $this->assertEquals($steve->tid, $tid); + return new Rejection('rejected'); }); $this->actingAs($user)