1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 22:24:03 +00:00

Test using --with-pending and the include_in_queries config value

This commit is contained in:
lukinovec 2022-10-05 10:23:40 +02:00
parent e3e85a0e88
commit 72f742e53d

View file

@ -239,6 +239,86 @@ test('link command works with a specified tenant', function() {
$this->assertDirectoryDoesNotExist(public_path("public-$tenantKey")); $this->assertDirectoryDoesNotExist(public_path("public-$tenantKey"));
}); });
test('passing with pending option as false makes tenant commands not include pending tenants', function() {
$tenants = collect([
Tenant::create(),
Tenant::create(),
Tenant::createPending(),
Tenant::createPending(),
]);
pest()->artisan('tenants:migrate --with-pending');
$artisan = pest()->artisan("tenants:run 'foo foo --b=bar --c=xyz' --with-pending=false");
$pendingTenants = $tenants->filter->pending();
$readyTenants = $tenants->reject->pending();
$pendingTenants->each(fn($tenant) => $artisan->doesntExpectOutputToContain("Tenant: {$tenant->getTenantKey()}"));
$readyTenants->each(fn($tenant) => $artisan->expectsOutputToContain("Tenant: {$tenant->getTenantKey()}"));
$artisan->assertExitCode(0);
});
test('passing with pending option as true makes tenant commands include pending tenants', function() {
$tenants = collect([
Tenant::create(),
Tenant::create(),
Tenant::createPending(),
Tenant::createPending(),
]);
pest()->artisan('tenants:migrate --with-pending');
$artisan = pest()->artisan("tenants:run 'foo foo --b=bar --c=xyz' --with-pending");
$tenants->each(fn($tenant) => $artisan->expectsOutputToContain("Tenant: {$tenant->getTenantKey()}"));
$artisan->assertExitCode(0);
});
test('not passing the with pending option makes tenant commands include the pending tenants if tenancy.pending.include_in_queries is true', function() {
config(['tenancy.pending.include_in_queries' => true]);
$tenants = collect([
Tenant::create(),
Tenant::create(),
Tenant::createPending(),
Tenant::createPending(),
]);
pest()->artisan('tenants:migrate --with-pending');
$artisan = pest()->artisan("tenants:run 'foo foo --b=bar --c=xyz'");
$tenants->each(fn($tenant) => $artisan->expectsOutputToContain("Tenant: {$tenant->getTenantKey()}"));
$artisan->assertExitCode(0);
});
test('not passing the with pending option makes tenant commands exclude the pending tenants if tenancy.pending.include_in_queries is false', function() {
config(['tenancy.pending.include_in_queries' => false]);
$tenants = collect([
Tenant::create(),
Tenant::create(),
Tenant::createPending(),
Tenant::createPending(),
]);
pest()->artisan('tenants:migrate --with-pending');
$artisan = pest()->artisan("tenants:run 'foo foo --b=bar --c=xyz'");
$pendingTenants = $tenants->filter->pending();
$readyTenants = $tenants->reject->pending();
$pendingTenants->each(fn($tenant) => $artisan->doesntExpectOutputToContain("Tenant: {$tenant->getTenantKey()}"));
$readyTenants->each(fn($tenant) => $artisan->expectsOutputToContain("Tenant: {$tenant->getTenantKey()}"));
$artisan->assertExitCode(0);
});
test('run command works when sub command asks questions and accepts arguments', function () { test('run command works when sub command asks questions and accepts arguments', function () {
$tenant = Tenant::create(); $tenant = Tenant::create();
$id = $tenant->getTenantKey(); $id = $tenant->getTenantKey();