mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:44:03 +00:00
[2.3.1] Fix exit codes in TenantAwareCommand (#336)
* Fix exit codes in TenantAwareCommand * Cast result to int * Assert exit code 0
This commit is contained in:
parent
4b46c65b2f
commit
5dc80473d3
2 changed files with 10 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
trait TenantAwareCommand
|
trait TenantAwareCommand
|
||||||
{
|
{
|
||||||
/** @return mixed|void */
|
/** @return int */
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$tenants = $this->getTenants();
|
$tenants = $this->getTenants();
|
||||||
|
|
@ -21,13 +21,18 @@ trait TenantAwareCommand
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$exitCode = 0;
|
||||||
foreach ($tenants as $tenant) {
|
foreach ($tenants as $tenant) {
|
||||||
$tenant->run(function () {
|
$result = (int) $tenant->run(function () {
|
||||||
$this->laravel->call([$this, 'handle']);
|
return $this->laravel->call([$this, 'handle']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($result !== 0) {
|
||||||
|
$exitCode = $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return $exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class TenantAwareCommandTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->artisan('user:add')
|
$this->artisan('user:add')
|
||||||
->assertExitCode(1);
|
->assertExitCode(0);
|
||||||
|
|
||||||
tenancy()->initializeTenancy($tenant1);
|
tenancy()->initializeTenancy($tenant1);
|
||||||
$this->assertNotEmpty(\DB::table('users')->get());
|
$this->assertNotEmpty(\DB::table('users')->get());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue