diff --git a/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php b/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php --- a/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php +++ b/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php @@ -6,7 +6,7 @@ class CreateCommand extends ObjectCreateCommand { - protected $cacheKeys = ['wallet_settings_%wallet_id%']; + protected $cacheKeys = ['app\wallet_settings_%wallet_id%']; protected $commandPrefix = 'scalpel'; protected $objectClass = \App\WalletSetting::class; protected $objectName = 'wallet-setting'; diff --git a/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php b/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php --- a/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php +++ b/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php @@ -6,7 +6,7 @@ class UpdateCommand extends ObjectUpdateCommand { - protected $cacheKeys = ['wallet_settings_%wallet_id%']; + protected $cacheKeys = ['app\wallet_settings_%wallet_id%']; protected $commandPrefix = 'scalpel'; protected $objectClass = \App\WalletSetting::class; protected $objectName = 'wallet-setting'; diff --git a/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php b/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php @@ -0,0 +1,23 @@ +getTestUser('john@kolab.org'); + $wallet = $user->wallets->first(); + $wallet->setSetting('test', null); + + $this->artisan("scalpel:wallet-setting:create --key=test --value=init --wallet_id={$wallet->id}") + ->assertExitCode(0); + + $setting = $wallet->settings()->where('key', 'test')->first(); + + $this->assertSame('init', $setting->fresh()->value); + $this->assertSame('init', $wallet->fresh()->getSetting('test')); + } +} diff --git a/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php b/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php @@ -0,0 +1,27 @@ +getTestUser('john@kolab.org'); + $wallet = $user->wallets->first(); + $wallet->setSetting('test', 'init'); + + $this->artisan("scalpel:wallet-setting:update unknown --value=test") + ->assertExitCode(1) + ->expectsOutput("No such wallet-setting unknown"); + + $setting = $wallet->settings()->where('key', 'test')->first(); + + $this->artisan("scalpel:wallet-setting:update {$setting->id} --value=test") + ->assertExitCode(0); + + $this->assertSame('test', $setting->fresh()->value); + $this->assertSame('test', $wallet->fresh()->getSetting('test')); + } +}