add new command for update

This commit is contained in:
Pig Fang 2020-04-01 15:34:06 +08:00
parent 31bd48eec7
commit 7afdc9e9ba
5 changed files with 60 additions and 10 deletions

View File

@ -0,0 +1,18 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class UpdateCommand extends Command
{
protected $signature = 'update';
protected $description = 'Execute update.';
public function handle()
{
app()->call('App\Http\Controllers\UpdateController@update');
$this->info(trans('setup.updates.success.title'));
}
}

View File

@ -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');
}
}

View File

@ -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

View File

@ -27,6 +27,7 @@
- 可通过上传压缩包来安装插件
- 可通过提交 URL 来安装插件
- 皮肤库中可通过点击上传者昵称来查看该用户的其它上传
- 增加 `php artisan update` 命令以便通过命令行进行升级数据库
## 调整

View File

@ -0,0 +1,35 @@
<?php
namespace Tests;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class UpdateCommandTest extends TestCase
{
use DatabaseTransactions;
public function testUpdate()
{
$this->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'));
}
}