1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:34:04 +00:00

Facade tests

This commit is contained in:
Samuel Štancl 2019-09-19 20:41:00 +02:00
parent c9903cd43c
commit f0dd99f099
5 changed files with 20 additions and 7 deletions

View file

@ -14,7 +14,7 @@ class TenantFacade extends Facade
return Tenant::class;
}
// todo test this
// todo2 test this
public static function create($domains, array $data): Tenant
{
return Tenant::create($domains, $data);

View file

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Storage;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Tenant;
// todo better solution than tenant_asset?
// todo2 better solution than tenant_asset?
class FilesystemTenancyBootstrapper implements TenancyBootstrapper
{

View file

@ -5,11 +5,18 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
use Tenant;
use Tenancy;
class FacadeTest extends TestCase
{
/** @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('abc', 'xyz');
@ -17,4 +24,10 @@ class FacadeTest extends TestCase
$this->assertSame('bar', Tenant::get('foo'));
$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);
}
}

View file

@ -15,14 +15,14 @@ class TenantAssetTest extends TestCase
// response()->file() returns BinaryFileResponse whose content is
// inaccessible via getContent, so ->assertSee() can't be used
// $this->get(tenant_asset($filename))->assertSuccessful(); // todo commented assertions
// $this->assertFileExists($path); // todo commented assertions
// $this->get(tenant_asset($filename))->assertSuccessful(); // todo2 commented assertions
// $this->assertFileExists($path); // todo2 commented assertions
$f = fopen($path, 'r');
$content = fread($f, filesize($path));
fclose($f);
// $this->assertSame('bar', $content); // todo commented assertions
// $this->assertSame('bar', $content); // todo2 commented assertions
$this->assertTrue(true);
}
}

View file

@ -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.');
}
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();
$this->assertFalse(app($databaseManager)->databaseExists($name));