From 7afdc9e9ba8ca9ff38344983e069773ec9f67467 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Wed, 1 Apr 2020 15:34:06 +0800 Subject: [PATCH] add new command for update --- app/Console/Commands/UpdateCommand.php | 18 ++++++++++++ app/Console/Kernel.php | 15 ++++------ resources/misc/changelogs/en/5.0.0.md | 1 + resources/misc/changelogs/zh_CN/5.0.0.md | 1 + tests/CommandsTest/UpdateCommandTest.php | 35 ++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 app/Console/Commands/UpdateCommand.php create mode 100644 tests/CommandsTest/UpdateCommandTest.php diff --git a/app/Console/Commands/UpdateCommand.php b/app/Console/Commands/UpdateCommand.php new file mode 100644 index 00000000..bb612600 --- /dev/null +++ b/app/Console/Commands/UpdateCommand.php @@ -0,0 +1,18 @@ +call('App\Http\Controllers\UpdateController@update'); + $this->info(trans('setup.updates.success.title')); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 1ec2900c..83c11056 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -6,17 +6,12 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { - /** - * The Artisan commands provided by your application. - * - * @var array - */ protected $commands = [ \Laravel\Passport\Console\KeysCommand::class, - Commands\SaltRandomCommand::class, - Commands\BsInstallCommand::class, - Commands\PluginEnableCommand::class, - Commands\PluginDisableCommand::class, - Commands\OptionsCacheCommand::class, ]; + + protected function commands() + { + $this->load(__DIR__.'/Commands'); + } } diff --git a/resources/misc/changelogs/en/5.0.0.md b/resources/misc/changelogs/en/5.0.0.md index becdff3a..507102c8 100644 --- a/resources/misc/changelogs/en/5.0.0.md +++ b/resources/misc/changelogs/en/5.0.0.md @@ -27,6 +27,7 @@ - Added support of installing plugin by uploading archive. - Added support of installing plugin by submitting remote URL. - Added support of clicking on the uploader's nickname in skin library to view other uploads of that user. +- Added `php artisan update` command for updating by CLI. ## Tweaked diff --git a/resources/misc/changelogs/zh_CN/5.0.0.md b/resources/misc/changelogs/zh_CN/5.0.0.md index 44df5945..0a66c6e7 100644 --- a/resources/misc/changelogs/zh_CN/5.0.0.md +++ b/resources/misc/changelogs/zh_CN/5.0.0.md @@ -27,6 +27,7 @@ - 可通过上传压缩包来安装插件 - 可通过提交 URL 来安装插件 - 皮肤库中可通过点击上传者昵称来查看该用户的其它上传 +- 增加 `php artisan update` 命令以便通过命令行进行升级数据库 ## 调整 diff --git a/tests/CommandsTest/UpdateCommandTest.php b/tests/CommandsTest/UpdateCommandTest.php new file mode 100644 index 00000000..49d99405 --- /dev/null +++ b/tests/CommandsTest/UpdateCommandTest.php @@ -0,0 +1,35 @@ +mock(Filesystem::class, function ($mock) { + $mock->shouldReceive('exists') + ->with(storage_path('install.lock')) + ->andReturn(true); + + $mock->shouldReceive('put') + ->with(storage_path('install.lock'), '') + ->once() + ->andReturn(true); + + $mock->shouldReceive('files') + ->with(database_path('update_scripts')) + ->once() + ->andReturn([]); + }); + config(['app.version' => '100.0.0']); + + $this->artisan('update') + ->expectsOutput(trans('setup.updates.success.title')); + $this->assertEquals('100.0.0', option('version')); + } +}