mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:44:04 +00:00
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Stancl\Tenancy\Tests;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Stancl\Tenancy\Tests\TestCase;
|
|
use Stancl\JobPipeline\JobPipeline;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Stancl\Tenancy\Jobs\CreateDatabase;
|
|
use Stancl\Tenancy\Events\TenantCreated;
|
|
use Stancl\Tenancy\Jobs\MigrateDatabase;
|
|
|
|
uses(TestCase::class)->in(__DIR__);
|
|
|
|
function withTenantDatabases(bool $migrate = false)
|
|
{
|
|
Event::listen(TenantCreated::class, JobPipeline::make($migrate
|
|
? [CreateDatabase::class]
|
|
: [CreateDatabase::class, MigrateDatabase::class]
|
|
)->send(function (TenantCreated $event) {
|
|
return $event->tenant;
|
|
})->toListener());
|
|
}
|
|
|
|
function withCacheTables()
|
|
{
|
|
Schema::create('cache', function (Blueprint $table) {
|
|
$table->string('key')->primary();
|
|
$table->mediumText('value');
|
|
$table->integer('expiration');
|
|
});
|
|
|
|
Schema::create('cache_locks', function (Blueprint $table) {
|
|
$table->string('key')->primary();
|
|
$table->string('owner');
|
|
$table->integer('expiration');
|
|
});
|
|
}
|
|
|
|
function pest(): TestCase
|
|
{
|
|
return \Pest\TestSuite::getInstance()->test;
|
|
}
|