Improve UX of plugin-related Artisan commands
This commit is contained in:
parent
bf778e9405
commit
eeec2e0435
|
|
@ -28,6 +28,12 @@ class PluginDisableCommand extends Command
|
|||
*/
|
||||
public function handle(PluginManager $plugins)
|
||||
{
|
||||
$plugins->disable($this->argument('name'));
|
||||
$plugin = $plugins->get($this->argument('name'));
|
||||
if ($plugin) {
|
||||
$plugins->disable($this->argument('name'));
|
||||
$this->info(trans('admin.plugins.operations.disabled', ['plugin' => $plugin->title]));
|
||||
} else {
|
||||
$this->warn(trans('admin.plugins.operations.not-found'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@ class PluginEnableCommand extends Command
|
|||
*/
|
||||
public function handle(PluginManager $plugins)
|
||||
{
|
||||
$plugins->enable($this->argument('name'));
|
||||
$plugin = $plugins->get($this->argument('name'));
|
||||
if ($plugin) {
|
||||
$plugins->enable($this->argument('name'));
|
||||
$this->info(trans('admin.plugins.operations.enabled', ['plugin' => $plugin->title]));
|
||||
} else {
|
||||
$this->warn(trans('admin.plugins.operations.not-found'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests;
|
||||
|
||||
use App\Services\Plugin;
|
||||
use App\Services\PluginManager;
|
||||
|
||||
class PluginDisableCommandTest extends TestCase
|
||||
|
|
@ -9,8 +10,17 @@ class PluginDisableCommandTest extends TestCase
|
|||
public function testDisablePlugin()
|
||||
{
|
||||
$this->mock(PluginManager::class, function ($mock) {
|
||||
$mock->shouldReceive('get')->with('nope')->once()->andReturn(null);
|
||||
$mock->shouldReceive('get')
|
||||
->with('my-plugin')
|
||||
->once()
|
||||
->andReturn(new Plugin('', ['title' => 'My Plugin']));
|
||||
$mock->shouldReceive('disable')->with('my-plugin')->once();
|
||||
});
|
||||
$this->artisan('plugin:disable my-plugin');
|
||||
|
||||
$this->artisan('plugin:disable nope')
|
||||
->expectsOutput(trans('admin.plugins.operations.not-found'));
|
||||
$this->artisan('plugin:disable my-plugin')
|
||||
->expectsOutput(trans('admin.plugins.operations.disabled', ['plugin' => 'My Plugin']));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests;
|
||||
|
||||
use App\Services\Plugin;
|
||||
use App\Services\PluginManager;
|
||||
|
||||
class PluginEnableCommandTest extends TestCase
|
||||
|
|
@ -9,8 +10,17 @@ class PluginEnableCommandTest extends TestCase
|
|||
public function testEnablePlugin()
|
||||
{
|
||||
$this->mock(PluginManager::class, function ($mock) {
|
||||
$mock->shouldReceive('get')->with('nope')->once()->andReturn(null);
|
||||
$mock->shouldReceive('get')
|
||||
->with('my-plugin')
|
||||
->once()
|
||||
->andReturn(new Plugin('', ['title' => 'My Plugin']));
|
||||
$mock->shouldReceive('enable')->with('my-plugin')->once();
|
||||
});
|
||||
$this->artisan('plugin:enable my-plugin');
|
||||
|
||||
$this->artisan('plugin:enable nope')
|
||||
->expectsOutput(trans('admin.plugins.operations.not-found'));
|
||||
$this->artisan('plugin:enable my-plugin')
|
||||
->expectsOutput(trans('admin.plugins.operations.enabled', ['plugin' => 'My Plugin']));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user