mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 15:54:03 +00:00
Fix asset tests
This commit is contained in:
parent
bd08979e0c
commit
75f00a58dd
5 changed files with 10 additions and 12 deletions
|
|
@ -11,11 +11,11 @@ use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
class FilesystemTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
protected $originalPaths = [];
|
|
||||||
|
|
||||||
/** @var Application */
|
/** @var Application */
|
||||||
protected $app;
|
protected $app;
|
||||||
|
|
||||||
|
protected $originalPaths = [];
|
||||||
|
|
||||||
public function __construct(Application $app)
|
public function __construct(Application $app)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
class RedisTenancyBootstrapper implements TenancyBootstrapper
|
class RedisTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
/** @var string[string] Original prefixes of connections */
|
/** @var array<string, string> Original prefixes of connections */
|
||||||
protected $originalPrefixes = [];
|
public $originalPrefixes = [];
|
||||||
|
|
||||||
/** @var Application */
|
/** @var Application */
|
||||||
protected $app;
|
protected $app;
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,6 @@ class TenancyServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
});
|
});
|
||||||
$this->app['url']->macro('getForcedRoot', function () {
|
|
||||||
return $this->forcedRoot;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,11 @@ if (! \function_exists('tenant')) {
|
||||||
if (! \function_exists('tenant_asset')) {
|
if (! \function_exists('tenant_asset')) {
|
||||||
function tenant_asset($asset)
|
function tenant_asset($asset)
|
||||||
{
|
{
|
||||||
return route('stancl.tenancy.asset', ['asset' => $asset]);
|
return route('stancl.tenancy.asset', ['path' => $asset]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! \function_exists('global_asset')) {
|
if (! \function_exists('global_asset')) {
|
||||||
// todo test this
|
|
||||||
function global_asset($asset)
|
function global_asset($asset)
|
||||||
{
|
{
|
||||||
return app('globalUrl')->asset($asset);
|
return app('globalUrl')->asset($asset);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ class TenantAssetTest extends TestCase
|
||||||
/** @test */
|
/** @test */
|
||||||
public function asset_can_be_accessed_using_the_url_returned_by_the_tenant_asset_helper()
|
public function asset_can_be_accessed_using_the_url_returned_by_the_tenant_asset_helper()
|
||||||
{
|
{
|
||||||
Tenant::create('foo.localhost');
|
Tenant::create('localhost');
|
||||||
tenancy()->init('foo.localhost');
|
tenancy()->init('localhost');
|
||||||
|
|
||||||
$filename = 'testfile' . $this->randomString(10);
|
$filename = 'testfile' . $this->randomString(10);
|
||||||
\Storage::disk('public')->put($filename, 'bar');
|
\Storage::disk('public')->put($filename, 'bar');
|
||||||
|
|
@ -23,8 +23,10 @@ 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();
|
|
||||||
$this->assertFileExists($path);
|
$this->assertFileExists($path);
|
||||||
|
$response = $this->get(tenant_asset($filename));
|
||||||
|
|
||||||
|
$response->assertSuccessful();
|
||||||
|
|
||||||
$f = fopen($path, 'r');
|
$f = fopen($path, 'r');
|
||||||
$content = fread($f, filesize($path));
|
$content = fread($f, filesize($path));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue