Page MenuHomePhorge

No OneTemporary

diff --git a/src/app/Console/Commands/User/WalletsCommand.php b/src/app/Console/Commands/User/WalletsCommand.php
index 065b5305..120a7a60 100644
--- a/src/app/Console/Commands/User/WalletsCommand.php
+++ b/src/app/Console/Commands/User/WalletsCommand.php
@@ -1,41 +1,13 @@
<?php
namespace App\Console\Commands\User;
-use App\Console\Command;
+use App\Console\ObjectRelationListCommand;
-class WalletsCommand extends Command
+class WalletsCommand extends ObjectRelationListCommand
{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'user:wallets {user}';
-
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = "List a user's wallets.";
-
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $user = $this->getUser($this->argument('user'));
-
- if (!$user) {
- $this->error("User not found.");
- return 1;
- }
-
- foreach ($user->wallets as $wallet) {
- $this->info("{$wallet->id} {$wallet->description}");
- }
- }
+ protected $objectClass = \App\User::class;
+ protected $objectName = 'user';
+ protected $objectTitle = 'email';
+ protected $objectRelation = 'wallets';
}
diff --git a/src/tests/Feature/Console/User/WalletsTest.php b/src/tests/Feature/Console/User/WalletsTest.php
index c3c6f29b..66939f68 100644
--- a/src/tests/Feature/Console/User/WalletsTest.php
+++ b/src/tests/Feature/Console/User/WalletsTest.php
@@ -1,29 +1,31 @@
<?php
namespace Tests\Feature\Console\User;
use Tests\TestCase;
class WalletsTest extends TestCase
{
/**
* Test command runs
*/
public function testHandle(): void
{
$code = \Artisan::call("user:wallets unknown");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
- $this->assertSame("User not found.", $output);
+ $this->assertSame("No such user unknown", $output);
$user = $this->getTestUser('john@kolab.org');
$wallet = $user->wallets()->first();
+ $wallet->balance = -100;
+ $wallet->save();
- $code = \Artisan::call("user:wallets john@kolab.org");
+ $code = \Artisan::call("user:wallets john@kolab.org --attr=balance --attr=user_id");
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertSame(trim("{$wallet->id} {$wallet->description}"), $output);
+ $this->assertSame("{$wallet->id} {$wallet->balance} {$user->id}", $output);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jan 18, 10:07 PM (14 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
120018
Default Alt Text
(2 KB)

Event Timeline