mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-14 02:54:03 +00:00
Facade tests
This commit is contained in:
parent
c9903cd43c
commit
f0dd99f099
5 changed files with 20 additions and 7 deletions
|
|
@ -14,7 +14,7 @@ class TenantFacade extends Facade
|
||||||
return Tenant::class;
|
return Tenant::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo test this
|
// todo2 test this
|
||||||
public static function create($domains, array $data): Tenant
|
public static function create($domains, array $data): Tenant
|
||||||
{
|
{
|
||||||
return Tenant::create($domains, $data);
|
return Tenant::create($domains, $data);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Storage;
|
||||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||||
use Stancl\Tenancy\Tenant;
|
use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
// todo better solution than tenant_asset?
|
// todo2 better solution than tenant_asset?
|
||||||
|
|
||||||
class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,18 @@ declare(strict_types=1);
|
||||||
namespace Stancl\Tenancy\Tests;
|
namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Tenant;
|
use Tenant;
|
||||||
|
use Tenancy;
|
||||||
|
|
||||||
class FacadeTest extends TestCase
|
class FacadeTest extends TestCase
|
||||||
{
|
{
|
||||||
/** @test */
|
/** @test */
|
||||||
public function tenant_manager_can_be_accessed_using_the_Tenant_facade()
|
public function tenant_manager_can_be_accessed_using_the_Tenancy_facade()
|
||||||
|
{
|
||||||
|
$this->assertSame(tenancy()->getTenant(), Tenancy::getTenant());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function tenant_storage_can_be_accessed_using_the_Tenant_facade()
|
||||||
{
|
{
|
||||||
tenant()->put('foo', 'bar');
|
tenant()->put('foo', 'bar');
|
||||||
Tenant::put('abc', 'xyz');
|
Tenant::put('abc', 'xyz');
|
||||||
|
|
@ -17,4 +24,10 @@ class FacadeTest extends TestCase
|
||||||
$this->assertSame('bar', Tenant::get('foo'));
|
$this->assertSame('bar', Tenant::get('foo'));
|
||||||
$this->assertSame('xyz', Tenant::get('abc'));
|
$this->assertSame('xyz', Tenant::get('abc'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function tenant_can_be_created_using_the_Tenant_facade()
|
||||||
|
{
|
||||||
|
$this->assertSame('bar', Tenant::create(['foo.localhost'], ['foo' => 'bar'])->foo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ class TenantAssetTest extends TestCase
|
||||||
|
|
||||||
// response()->file() returns BinaryFileResponse whose content is
|
// response()->file() returns BinaryFileResponse whose content is
|
||||||
// inaccessible via getContent, so ->assertSee() can't be used
|
// inaccessible via getContent, so ->assertSee() can't be used
|
||||||
// $this->get(tenant_asset($filename))->assertSuccessful(); // todo commented assertions
|
// $this->get(tenant_asset($filename))->assertSuccessful(); // todo2 commented assertions
|
||||||
// $this->assertFileExists($path); // todo commented assertions
|
// $this->assertFileExists($path); // todo2 commented assertions
|
||||||
|
|
||||||
$f = fopen($path, 'r');
|
$f = fopen($path, 'r');
|
||||||
$content = fread($f, filesize($path));
|
$content = fread($f, filesize($path));
|
||||||
fclose($f);
|
fclose($f);
|
||||||
|
|
||||||
// $this->assertSame('bar', $content); // todo commented assertions
|
// $this->assertSame('bar', $content); // todo2 commented assertions
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class TenantDatabaseManagerTest extends TestCase
|
||||||
$this->markTestSkipped('As to not bloat your computer with test databases, this test is not run by default.');
|
$this->markTestSkipped('As to not bloat your computer with test databases, this test is not run by default.');
|
||||||
}
|
}
|
||||||
|
|
||||||
config()->set('database.default', $driver); // todo the DB creator would not work for MySQL when sqlite is used for the central DB
|
config()->set('database.default', $driver); // todo2 the DB creator would not work for MySQL when sqlite is used for the central DB
|
||||||
|
|
||||||
$name = 'db' . $this->randomString();
|
$name = 'db' . $this->randomString();
|
||||||
$this->assertFalse(app($databaseManager)->databaseExists($name));
|
$this->assertFalse(app($databaseManager)->databaseExists($name));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue