mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 04:54:03 +00:00
Test that tenants:run parses the arguments correctly
This commit is contained in:
parent
1750297225
commit
f283f37733
3 changed files with 47 additions and 0 deletions
|
|
@ -389,6 +389,21 @@ test('run command works when sub command asks questions and accepts arguments',
|
||||||
expect($user->email)->toBe('email@localhost');
|
expect($user->email)->toBe('email@localhost');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('run command accepts arguments and options correctly', function() {
|
||||||
|
$tenant = Tenant::create();
|
||||||
|
$id = $tenant->getTenantKey();
|
||||||
|
|
||||||
|
// Use unquoted single-word arguments and quoted arguments with spaces
|
||||||
|
pest()->artisan("tenants:run \"bar username 'email@localhost' adsfg123 'some Arg' --option='some option'\" --tenants=$id")
|
||||||
|
->expectsOutputToContain("Tenant: $id.")
|
||||||
|
->expectsOutput("Name: username")
|
||||||
|
->expectsOutput("Email: email@localhost")
|
||||||
|
->expectsOutput("Password: adsfg123")
|
||||||
|
->expectsOutput("Argument: some Arg")
|
||||||
|
->expectsOutput("Option: some option")
|
||||||
|
->assertExitCode(0);
|
||||||
|
});
|
||||||
|
|
||||||
test('migrate fresh command only deletes tenant databases if drop_tenant_databases_on_migrate_fresh is true', function (bool $dropTenantDBsOnMigrateFresh) {
|
test('migrate fresh command only deletes tenant databases if drop_tenant_databases_on_migrate_fresh is true', function (bool $dropTenantDBsOnMigrateFresh) {
|
||||||
Event::listen(DeletingTenant::class,
|
Event::listen(DeletingTenant::class,
|
||||||
JobPipeline::make([DeleteDomains::class])->send(function (DeletingTenant $event) {
|
JobPipeline::make([DeleteDomains::class])->send(function (DeletingTenant $event) {
|
||||||
|
|
|
||||||
31
tests/Etc/Console/AnotherExampleCommand.php
Normal file
31
tests/Etc/Console/AnotherExampleCommand.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Tests\Etc\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class AnotherExampleCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'bar {name} {email} {password} {arg} {--option=}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->line('Name: ' . $this->argument('name'));
|
||||||
|
$this->line('Email: ' . $this->argument('email'));
|
||||||
|
$this->line('Password: ' . $this->argument('password'));
|
||||||
|
$this->line('Argument: ' . $this->argument('arg'));
|
||||||
|
$this->line('Option: ' . $this->option('option'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ class ConsoleKernel extends Kernel
|
||||||
{
|
{
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
ExampleCommand::class,
|
ExampleCommand::class,
|
||||||
|
AnotherExampleCommand::class,
|
||||||
ExampleQuestionCommand::class,
|
ExampleQuestionCommand::class,
|
||||||
AddUserCommand::class,
|
AddUserCommand::class,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue