diff --git a/src/app/Console/Command.php b/src/app/Console/Command.php new file mode 100644 --- /dev/null +++ b/src/app/Console/Command.php @@ -0,0 +1,38 @@ +first(); + } + + /** + * Find the user. + * + * @param string $user User ID or email + * + * @return \App\User|null + */ + public function getUser($user) + { + if (is_numeric($user)) { + return \App\User::find($user); + } + + return \App\User::where('email', \strtolower($user))->first(); + } +} diff --git a/src/app/Console/Commands/DBPing.php b/src/app/Console/Commands/DBPing.php --- a/src/app/Console/Commands/DBPing.php +++ b/src/app/Console/Commands/DBPing.php @@ -2,7 +2,7 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; +use App\Console\Command; use Illuminate\Support\Facades\DB; class DBPing extends Command @@ -21,16 +21,6 @@ */ protected $description = 'Ping the database [and wait for it to respond]'; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - /** * Execute the console command. * diff --git a/src/app/Console/Commands/DataCountries.php b/src/app/Console/Commands/DataCountries.php --- a/src/app/Console/Commands/DataCountries.php +++ b/src/app/Console/Commands/DataCountries.php @@ -2,7 +2,7 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; +use App\Console\Command; class DataCountries extends Command { diff --git a/src/app/Console/Commands/DiscountList.php b/src/app/Console/Commands/DiscountList.php --- a/src/app/Console/Commands/DiscountList.php +++ b/src/app/Console/Commands/DiscountList.php @@ -2,8 +2,8 @@ namespace App\Console\Commands; +use App\Console\Command; use App\Discount; -use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; class DiscountList extends Command @@ -22,16 +22,6 @@ */ protected $description = 'List available (active) discounts'; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - /** * Execute the console command. * diff --git a/src/app/Console/Commands/DomainAdd.php b/src/app/Console/Commands/Domain/Add.php rename from src/app/Console/Commands/DomainAdd.php rename to src/app/Console/Commands/Domain/Add.php --- a/src/app/Console/Commands/DomainAdd.php +++ b/src/app/Console/Commands/Domain/Add.php @@ -1,13 +1,13 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found."); return 1; } diff --git a/src/app/Console/Commands/DomainList.php b/src/app/Console/Commands/Domain/ListDomains.php rename from src/app/Console/Commands/DomainList.php rename to src/app/Console/Commands/Domain/ListDomains.php --- a/src/app/Console/Commands/DomainList.php +++ b/src/app/Console/Commands/Domain/ListDomains.php @@ -1,11 +1,11 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found."); return 1; } diff --git a/src/app/Console/Commands/DomainSetStatus.php b/src/app/Console/Commands/Domain/SetStatus.php rename from src/app/Console/Commands/DomainSetStatus.php rename to src/app/Console/Commands/Domain/SetStatus.php --- a/src/app/Console/Commands/DomainSetStatus.php +++ b/src/app/Console/Commands/Domain/SetStatus.php @@ -1,12 +1,12 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found."); return 1; } diff --git a/src/app/Console/Commands/DomainSetWallet.php b/src/app/Console/Commands/Domain/SetWallet.php rename from src/app/Console/Commands/DomainSetWallet.php rename to src/app/Console/Commands/Domain/SetWallet.php --- a/src/app/Console/Commands/DomainSetWallet.php +++ b/src/app/Console/Commands/Domain/SetWallet.php @@ -1,15 +1,15 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { $this->error("Domain not found."); diff --git a/src/app/Console/Commands/DomainStatus.php b/src/app/Console/Commands/Domain/Status.php rename from src/app/Console/Commands/DomainStatus.php rename to src/app/Console/Commands/Domain/Status.php --- a/src/app/Console/Commands/DomainStatus.php +++ b/src/app/Console/Commands/Domain/Status.php @@ -1,11 +1,11 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found."); return 1; } diff --git a/src/app/Console/Commands/DomainSuspend.php b/src/app/Console/Commands/Domain/Suspend.php rename from src/app/Console/Commands/DomainSuspend.php rename to src/app/Console/Commands/Domain/Suspend.php --- a/src/app/Console/Commands/DomainSuspend.php +++ b/src/app/Console/Commands/Domain/Suspend.php @@ -1,11 +1,11 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found."); return 1; } - $this->info("Found domain: {$domain->id}"); - $domain->suspend(); } } diff --git a/src/app/Console/Commands/DomainUnsuspend.php b/src/app/Console/Commands/Domain/Unsuspend.php rename from src/app/Console/Commands/DomainUnsuspend.php rename to src/app/Console/Commands/Domain/Unsuspend.php --- a/src/app/Console/Commands/DomainUnsuspend.php +++ b/src/app/Console/Commands/Domain/Unsuspend.php @@ -1,11 +1,11 @@ argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found."); return 1; } - $this->info("Found domain {$domain->id}"); - $domain->unsuspend(); } } diff --git a/src/app/Console/Commands/Job/DomainCreate.php b/src/app/Console/Commands/Job/DomainCreate.php --- a/src/app/Console/Commands/Job/DomainCreate.php +++ b/src/app/Console/Commands/Job/DomainCreate.php @@ -2,8 +2,7 @@ namespace App\Console\Commands\Job; -use App\Domain; -use Illuminate\Console\Command; +use App\Console\Command; class DomainCreate extends Command { @@ -28,9 +27,10 @@ */ public function handle() { - $domain = Domain::where('namespace', $this->argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found"); return 1; } diff --git a/src/app/Console/Commands/Job/DomainUpdate.php b/src/app/Console/Commands/Job/DomainUpdate.php --- a/src/app/Console/Commands/Job/DomainUpdate.php +++ b/src/app/Console/Commands/Job/DomainUpdate.php @@ -2,8 +2,7 @@ namespace App\Console\Commands\Job; -use App\Domain; -use Illuminate\Console\Command; +use App\Console\Command; class DomainUpdate extends Command { @@ -28,9 +27,10 @@ */ public function handle() { - $domain = Domain::where('namespace', $this->argument('domain'))->first(); + $domain = $this->getDomain($this->argument('domain')); if (!$domain) { + $this->error("Domain not found"); return 1; } diff --git a/src/app/Console/Commands/Job/UserCreate.php b/src/app/Console/Commands/Job/UserCreate.php --- a/src/app/Console/Commands/Job/UserCreate.php +++ b/src/app/Console/Commands/Job/UserCreate.php @@ -2,8 +2,7 @@ namespace App\Console\Commands\Job; -use App\User; -use Illuminate\Console\Command; +use App\Console\Command; class UserCreate extends Command { @@ -28,9 +27,10 @@ */ public function handle() { - $user = User::where('email', $this->argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found"); return 1; } diff --git a/src/app/Console/Commands/Job/UserUpdate.php b/src/app/Console/Commands/Job/UserUpdate.php --- a/src/app/Console/Commands/Job/UserUpdate.php +++ b/src/app/Console/Commands/Job/UserUpdate.php @@ -2,8 +2,7 @@ namespace App\Console\Commands\Job; -use App\User; -use Illuminate\Console\Command; +use App\Console\Command; class UserUpdate extends Command { @@ -28,9 +27,10 @@ */ public function handle() { - $user = User::where('email', $this->argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found"); return 1; } diff --git a/src/app/Console/Commands/Job/WalletCheck.php b/src/app/Console/Commands/Job/WalletCheck.php --- a/src/app/Console/Commands/Job/WalletCheck.php +++ b/src/app/Console/Commands/Job/WalletCheck.php @@ -2,8 +2,8 @@ namespace App\Console\Commands\Job; +use App\Console\Command; use App\Wallet; -use Illuminate\Console\Command; class WalletCheck extends Command { @@ -31,6 +31,7 @@ $wallet = Wallet::find($this->argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/MollieInfo.php b/src/app/Console/Commands/MollieInfo.php --- a/src/app/Console/Commands/MollieInfo.php +++ b/src/app/Console/Commands/MollieInfo.php @@ -2,8 +2,7 @@ namespace App\Console\Commands; -use App\User; -use Illuminate\Console\Command; +use App\Console\Command; class MollieInfo extends Command { @@ -29,14 +28,13 @@ public function handle() { if ($this->argument('user')) { - $user = User::where('email', $this->argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("Wallet not found"); return 1; } - $this->info("Found user: {$user->id}"); - $wallet = $user->wallets->first(); $provider = new \App\Providers\Payment\Mollie(); diff --git a/src/app/Console/Commands/PackageSkus.php b/src/app/Console/Commands/PackageSkus.php --- a/src/app/Console/Commands/PackageSkus.php +++ b/src/app/Console/Commands/PackageSkus.php @@ -2,8 +2,8 @@ namespace App\Console\Commands; +use App\Console\Command; use App\Package; -use Illuminate\Console\Command; class PackageSkus extends Command { @@ -21,16 +21,6 @@ */ protected $description = "List SKUs for packages."; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - /** * Execute the console command. * diff --git a/src/app/Console/Commands/PlanPackages.php b/src/app/Console/Commands/PlanPackages.php --- a/src/app/Console/Commands/PlanPackages.php +++ b/src/app/Console/Commands/PlanPackages.php @@ -2,8 +2,8 @@ namespace App\Console\Commands; +use App\Console\Command; use App\Plan; -use Illuminate\Console\Command; class PlanPackages extends Command { @@ -21,16 +21,6 @@ */ protected $description = "List packages for plans."; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - /** * Execute the console command. * diff --git a/src/app/Console/Commands/StripeInfo.php b/src/app/Console/Commands/StripeInfo.php --- a/src/app/Console/Commands/StripeInfo.php +++ b/src/app/Console/Commands/StripeInfo.php @@ -2,9 +2,9 @@ namespace App\Console\Commands; +use App\Console\Command; use App\Providers\PaymentProvider; use App\User; -use Illuminate\Console\Command; use Stripe as StripeAPI; class StripeInfo extends Command @@ -31,14 +31,13 @@ public function handle() { if ($this->argument('user')) { - $user = User::where('email', $this->argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found"); return 1; } - $this->info("Found user: {$user->id}"); - $wallet = $user->wallets->first(); $provider = PaymentProvider::factory('stripe'); diff --git a/src/app/Console/Commands/UserAddAlias.php b/src/app/Console/Commands/User/AddAlias.php rename from src/app/Console/Commands/UserAddAlias.php rename to src/app/Console/Commands/User/AddAlias.php --- a/src/app/Console/Commands/UserAddAlias.php +++ b/src/app/Console/Commands/User/AddAlias.php @@ -1,11 +1,11 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } diff --git a/src/app/Console/Commands/UserDelete.php b/src/app/Console/Commands/User/Delete.php rename from src/app/Console/Commands/UserDelete.php rename to src/app/Console/Commands/User/Delete.php --- a/src/app/Console/Commands/UserDelete.php +++ b/src/app/Console/Commands/User/Delete.php @@ -1,10 +1,10 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } diff --git a/src/app/Console/Commands/UserDiscount.php b/src/app/Console/Commands/User/Discount.php rename from src/app/Console/Commands/UserDiscount.php rename to src/app/Console/Commands/User/Discount.php --- a/src/app/Console/Commands/UserDiscount.php +++ b/src/app/Console/Commands/User/Discount.php @@ -1,10 +1,10 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } - $this->info("Found user {$user->id}"); - if ($this->argument('discount') === '0') { $discount = null; } else { $discount = \App\Discount::find($this->argument('discount')); if (!$discount) { + $this->error("Discount not found."); return 1; } } diff --git a/src/app/Console/Commands/UserDomains.php b/src/app/Console/Commands/User/Domains.php rename from src/app/Console/Commands/UserDomains.php rename to src/app/Console/Commands/User/Domains.php --- a/src/app/Console/Commands/UserDomains.php +++ b/src/app/Console/Commands/User/Domains.php @@ -1,20 +1,20 @@ argument('userid'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } diff --git a/src/app/Console/Commands/UserEntitlements.php b/src/app/Console/Commands/User/Entitlements.php rename from src/app/Console/Commands/UserEntitlements.php rename to src/app/Console/Commands/User/Entitlements.php --- a/src/app/Console/Commands/UserEntitlements.php +++ b/src/app/Console/Commands/User/Entitlements.php @@ -1,12 +1,12 @@ argument('userid'))->first(); + $user = $this->getUser($this->argument('userid')); if (!$user) { + $this->error("User not found."); return 1; } - $this->info("Found user: {$user->id}"); - $skus_counted = []; foreach ($user->entitlements as $entitlement) { diff --git a/src/app/Console/Commands/UserForceDelete.php b/src/app/Console/Commands/User/ForceDelete.php rename from src/app/Console/Commands/UserForceDelete.php rename to src/app/Console/Commands/User/ForceDelete.php --- a/src/app/Console/Commands/UserForceDelete.php +++ b/src/app/Console/Commands/User/ForceDelete.php @@ -1,11 +1,11 @@ where('email', $this->argument('user'))->first(); + $id = $this->argument('user'); + + if (is_numeric($id)) { + $user = \App\User::find($id); + } else { + $user = \App\User::withTrashed()->where('email', $id)->first(); + } if (!$user) { + $this->error("User not found."); return 1; } if (!$user->trashed()) { - $this->error('The user is not yet deleted'); + $this->error("The user is not yet deleted"); return 1; } diff --git a/src/app/Console/Commands/UserStatus.php b/src/app/Console/Commands/User/Status.php rename from src/app/Console/Commands/UserStatus.php rename to src/app/Console/Commands/User/Status.php --- a/src/app/Console/Commands/UserStatus.php +++ b/src/app/Console/Commands/User/Status.php @@ -1,11 +1,11 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } - $this->info("Found user: {$user->id}"); - $this->info($user->status); } } diff --git a/src/app/Console/Commands/UserSuspend.php b/src/app/Console/Commands/User/Suspend.php rename from src/app/Console/Commands/UserSuspend.php rename to src/app/Console/Commands/User/Suspend.php --- a/src/app/Console/Commands/UserSuspend.php +++ b/src/app/Console/Commands/User/Suspend.php @@ -1,11 +1,11 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } - $this->info("Found user: {$user->id}"); - $user->suspend(); } } diff --git a/src/app/Console/Commands/UserUnsuspend.php b/src/app/Console/Commands/User/Unsuspend.php rename from src/app/Console/Commands/UserUnsuspend.php rename to src/app/Console/Commands/User/Unsuspend.php --- a/src/app/Console/Commands/UserUnsuspend.php +++ b/src/app/Console/Commands/User/Unsuspend.php @@ -1,11 +1,11 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } - $this->info("Found user {$user->id}"); - $user->unsuspend(); } } diff --git a/src/app/Console/Commands/UserVerify.php b/src/app/Console/Commands/User/Verify.php rename from src/app/Console/Commands/UserVerify.php rename to src/app/Console/Commands/User/Verify.php --- a/src/app/Console/Commands/UserVerify.php +++ b/src/app/Console/Commands/User/Verify.php @@ -1,10 +1,10 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } - $this->info("Found user: {$user->id}"); - $job = new \App\Jobs\UserVerify($user); $job->handle(); } diff --git a/src/app/Console/Commands/UserWallets.php b/src/app/Console/Commands/User/Wallets.php rename from src/app/Console/Commands/UserWallets.php rename to src/app/Console/Commands/User/Wallets.php --- a/src/app/Console/Commands/UserWallets.php +++ b/src/app/Console/Commands/User/Wallets.php @@ -1,10 +1,10 @@ argument('user'))->first(); + $user = $this->getUser($this->argument('user')); if (!$user) { + $this->error("User not found."); return 1; } diff --git a/src/app/Console/Commands/WalletAddTransaction.php b/src/app/Console/Commands/Wallet/AddTransaction.php rename from src/app/Console/Commands/WalletAddTransaction.php rename to src/app/Console/Commands/Wallet/AddTransaction.php --- a/src/app/Console/Commands/WalletAddTransaction.php +++ b/src/app/Console/Commands/Wallet/AddTransaction.php @@ -1,10 +1,10 @@ argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletBalances.php b/src/app/Console/Commands/Wallet/Balances.php rename from src/app/Console/Commands/WalletBalances.php rename to src/app/Console/Commands/Wallet/Balances.php --- a/src/app/Console/Commands/WalletBalances.php +++ b/src/app/Console/Commands/Wallet/Balances.php @@ -1,10 +1,10 @@ owner) { + $this->error("Wallet not found (or account deleted)."); return 1; } diff --git a/src/app/Console/Commands/WalletExpected.php b/src/app/Console/Commands/Wallet/Expected.php rename from src/app/Console/Commands/WalletExpected.php rename to src/app/Console/Commands/Wallet/Expected.php --- a/src/app/Console/Commands/WalletExpected.php +++ b/src/app/Console/Commands/Wallet/Expected.php @@ -1,10 +1,10 @@ option('user')) { - $user = \App\User::where('email', $this->option('user')) - ->orWhere('id', $this->option('user'))->first(); + $user = $this->getUser($this->option('user')); if (!$user) { + $this->error("User not found"); return 1; } diff --git a/src/app/Console/Commands/WalletGetBalance.php b/src/app/Console/Commands/Wallet/GetBalance.php rename from src/app/Console/Commands/WalletGetBalance.php rename to src/app/Console/Commands/Wallet/GetBalance.php --- a/src/app/Console/Commands/WalletGetBalance.php +++ b/src/app/Console/Commands/Wallet/GetBalance.php @@ -1,10 +1,10 @@ argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletGetDiscount.php b/src/app/Console/Commands/Wallet/GetDiscount.php rename from src/app/Console/Commands/WalletGetDiscount.php rename to src/app/Console/Commands/Wallet/GetDiscount.php --- a/src/app/Console/Commands/WalletGetDiscount.php +++ b/src/app/Console/Commands/Wallet/GetDiscount.php @@ -1,10 +1,10 @@ argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletMandate.php b/src/app/Console/Commands/Wallet/Mandate.php rename from src/app/Console/Commands/WalletMandate.php rename to src/app/Console/Commands/Wallet/Mandate.php --- a/src/app/Console/Commands/WalletMandate.php +++ b/src/app/Console/Commands/Wallet/Mandate.php @@ -1,11 +1,11 @@ argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletSetBalance.php b/src/app/Console/Commands/Wallet/SetBalance.php rename from src/app/Console/Commands/WalletSetBalance.php rename to src/app/Console/Commands/Wallet/SetBalance.php --- a/src/app/Console/Commands/WalletSetBalance.php +++ b/src/app/Console/Commands/Wallet/SetBalance.php @@ -1,10 +1,10 @@ argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletSetDiscount.php b/src/app/Console/Commands/Wallet/SetDiscount.php rename from src/app/Console/Commands/WalletSetDiscount.php rename to src/app/Console/Commands/Wallet/SetDiscount.php --- a/src/app/Console/Commands/WalletSetDiscount.php +++ b/src/app/Console/Commands/Wallet/SetDiscount.php @@ -1,10 +1,10 @@ argument('wallet'))->first(); + $wallet = \App\Wallet::find($this->argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } @@ -51,6 +42,7 @@ $discount = \App\Discount::find($this->argument('discount')); if (!$discount) { + $this->error("Discount not found"); return 1; } diff --git a/src/app/Console/Commands/WalletTransactions.php b/src/app/Console/Commands/Wallet/Transactions.php rename from src/app/Console/Commands/WalletTransactions.php rename to src/app/Console/Commands/Wallet/Transactions.php --- a/src/app/Console/Commands/WalletTransactions.php +++ b/src/app/Console/Commands/Wallet/Transactions.php @@ -1,10 +1,10 @@ argument('wallet'))->first(); + $wallet = \App\Wallet::find($this->argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletUntil.php b/src/app/Console/Commands/Wallet/Until.php rename from src/app/Console/Commands/WalletUntil.php rename to src/app/Console/Commands/Wallet/Until.php --- a/src/app/Console/Commands/WalletUntil.php +++ b/src/app/Console/Commands/Wallet/Until.php @@ -1,10 +1,10 @@ argument('wallet')); if (!$wallet) { + $this->error("Wallet not found"); return 1; } diff --git a/src/app/Console/Commands/WalletDiscount.php b/src/app/Console/Commands/WalletDiscount.php deleted file mode 100644 --- a/src/app/Console/Commands/WalletDiscount.php +++ /dev/null @@ -1,62 +0,0 @@ -argument('wallet'))->first(); - - if (!$wallet) { - return 1; - } - - // FIXME: Using '0' for delete might be not that obvious - - if ($this->argument('discount') === '0') { - $wallet->discount()->dissociate(); - } else { - $discount = \App\Discount::find($this->argument('discount')); - - if (!$discount) { - return 1; - } - - $wallet->discount()->associate($discount); - } - - $wallet->save(); - } -} diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/AddTest.php rename from src/tests/Feature/Console/UserDiscountTest.php rename to src/tests/Feature/Console/Domain/AddTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/AddTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/DeleteTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/Domain/DeleteTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/DeleteTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/Domain/ListDomainsTest.php b/src/tests/Feature/Console/Domain/ListDomainsTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Domain/ListDomainsTest.php @@ -0,0 +1,19 @@ +artisan('domain:list') + ->assertExitCode(0); + + $this->markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/ListUsersTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/Domain/ListUsersTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/ListUsersTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/SetStatusTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/Domain/SetStatusTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/SetStatusTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/SetWalletTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/Domain/SetWalletTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/SetWalletTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/Domain/StatusTest.php b/src/tests/Feature/Console/Domain/StatusTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Domain/StatusTest.php @@ -0,0 +1,19 @@ +artisan('domain:status kolab.org') + ->assertExitCode(0); + + $this->markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/SuspendTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/Domain/SuspendTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/SuspendTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Domain/UnsuspendTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/Domain/UnsuspendTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Domain/UnsuspendTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/User/AddAliasTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/User/AddAliasTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/User/AddAliasTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/WalletDiscountTest.php b/src/tests/Feature/Console/User/DeleteTest.php rename from src/tests/Feature/Console/WalletDiscountTest.php rename to src/tests/Feature/Console/User/DeleteTest.php --- a/src/tests/Feature/Console/WalletDiscountTest.php +++ b/src/tests/Feature/Console/User/DeleteTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/User/DiscountTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/User/DiscountTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/User/DiscountTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDomainsTest.php b/src/tests/Feature/Console/User/DomainsTest.php rename from src/tests/Feature/Console/UserDomainsTest.php rename to src/tests/Feature/Console/User/DomainsTest.php --- a/src/tests/Feature/Console/UserDomainsTest.php +++ b/src/tests/Feature/Console/User/DomainsTest.php @@ -1,11 +1,14 @@ artisan('user:domains john@kolab.org') diff --git a/src/tests/Feature/Console/UserEntitlementsTest.php b/src/tests/Feature/Console/User/EntitlementsTest.php rename from src/tests/Feature/Console/UserEntitlementsTest.php rename to src/tests/Feature/Console/User/EntitlementsTest.php --- a/src/tests/Feature/Console/UserEntitlementsTest.php +++ b/src/tests/Feature/Console/User/EntitlementsTest.php @@ -1,11 +1,14 @@ artisan('user:entitlements john@kolab.org') diff --git a/src/tests/Feature/Console/UserForceDeleteTest.php b/src/tests/Feature/Console/User/ForceDeleteTest.php rename from src/tests/Feature/Console/UserForceDeleteTest.php rename to src/tests/Feature/Console/User/ForceDeleteTest.php --- a/src/tests/Feature/Console/UserForceDeleteTest.php +++ b/src/tests/Feature/Console/User/ForceDeleteTest.php @@ -1,11 +1,11 @@ artisan('user:status john@kolab.org') + ->assertExitCode(0); + + $this->markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/User/SuspendTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/User/SuspendTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/User/SuspendTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/User/UnsuspendTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/User/UnsuspendTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/User/UnsuspendTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/User/VerifyTest.php copy from src/tests/Feature/Console/UserDiscountTest.php copy to src/tests/Feature/Console/User/VerifyTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/User/VerifyTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/UserWalletsTest.php b/src/tests/Feature/Console/User/WalletsTest.php rename from src/tests/Feature/Console/UserWalletsTest.php rename to src/tests/Feature/Console/User/WalletsTest.php --- a/src/tests/Feature/Console/UserWalletsTest.php +++ b/src/tests/Feature/Console/User/WalletsTest.php @@ -1,11 +1,14 @@ artisan('user:wallets john@kolab.org') diff --git a/src/tests/Feature/Console/Wallet/AddTransactionTest.php b/src/tests/Feature/Console/Wallet/AddTransactionTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/AddTransactionTest.php @@ -0,0 +1,16 @@ +markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/Wallet/BalancesTest.php b/src/tests/Feature/Console/Wallet/BalancesTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/BalancesTest.php @@ -0,0 +1,19 @@ +artisan('wallet:balances') + ->assertExitCode(0); + + $this->markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/WalletChargeTest.php b/src/tests/Feature/Console/Wallet/ChargeTest.php rename from src/tests/Feature/Console/WalletChargeTest.php rename to src/tests/Feature/Console/Wallet/ChargeTest.php --- a/src/tests/Feature/Console/WalletChargeTest.php +++ b/src/tests/Feature/Console/Wallet/ChargeTest.php @@ -1,11 +1,11 @@ artisan('wallet:expected') + ->assertExitCode(0); + + $this->markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/Wallet/GetBalanceTest.php b/src/tests/Feature/Console/Wallet/GetBalanceTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/GetBalanceTest.php @@ -0,0 +1,16 @@ +markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/Wallet/GetDiscountTest.php b/src/tests/Feature/Console/Wallet/GetDiscountTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/GetDiscountTest.php @@ -0,0 +1,16 @@ +markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/UserDiscountTest.php b/src/tests/Feature/Console/Wallet/MandateTest.php rename from src/tests/Feature/Console/UserDiscountTest.php rename to src/tests/Feature/Console/Wallet/MandateTest.php --- a/src/tests/Feature/Console/UserDiscountTest.php +++ b/src/tests/Feature/Console/Wallet/MandateTest.php @@ -1,11 +1,14 @@ markTestIncomplete(); diff --git a/src/tests/Feature/Console/Wallet/SetBalanceTest.php b/src/tests/Feature/Console/Wallet/SetBalanceTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/SetBalanceTest.php @@ -0,0 +1,16 @@ +markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/Wallet/SetDiscountTest.php b/src/tests/Feature/Console/Wallet/SetDiscountTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/SetDiscountTest.php @@ -0,0 +1,16 @@ +markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/Wallet/TransactionsTest.php b/src/tests/Feature/Console/Wallet/TransactionsTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/TransactionsTest.php @@ -0,0 +1,16 @@ +markTestIncomplete(); + } +} diff --git a/src/tests/Feature/Console/Wallet/UntilTest.php b/src/tests/Feature/Console/Wallet/UntilTest.php new file mode 100644 --- /dev/null +++ b/src/tests/Feature/Console/Wallet/UntilTest.php @@ -0,0 +1,48 @@ +deleteTestUser('wallet-charge@kolabnow.com'); + } + + /** + * {@inheritDoc} + */ + public function tearDown(): void + { + $this->deleteTestUser('wallet-charge@kolabnow.com'); + + parent::tearDown(); + } + + /** + * Test command run for a specified wallet + */ + public function testHandleSingle(): void + { + $user = $this->getTestUser('wallet-charge@kolabnow.com'); + $wallet = $user->wallets()->first(); + + // Non-existing wallet + $this->artisan('wallet:until unknown') + ->expectsOutput("Wallet not found") + ->assertExitCode(1); + + // TODO + $this->artisan('wallet:until ' . $wallet->id) + ->assertExitCode(0); + + $this->markTestIncomplete(); + } +}