mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 11:14:04 +00:00
Apply fixes from StyleCI
This commit is contained in:
parent
417330decd
commit
84890cdd1e
20 changed files with 73 additions and 73 deletions
|
|
@ -18,7 +18,7 @@ class CacheManager extends BaseCacheManager
|
|||
$names = $parameters[0];
|
||||
$names = (array) $names; // cache()->tags('foo') https://laravel.com/docs/5.7/cache#removing-tagged-cache-items
|
||||
|
||||
return $this->store()->tags(array_merge($tags, $names));
|
||||
return $this->store()->tags(\array_merge($tags, $names));
|
||||
}
|
||||
|
||||
return $this->store()->tags($tags)->$method(...$parameters);
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ class Install extends Command
|
|||
]);
|
||||
$this->info('✔️ Created config/tenancy.php');
|
||||
|
||||
file_put_contents(app_path('Http/Kernel.php'), str_replace(
|
||||
\file_put_contents(app_path('Http/Kernel.php'), \str_replace(
|
||||
'protected $middlewarePriority = [',
|
||||
"protected \$middlewarePriority = [\n \Stancl\Tenancy\Middleware\InitializeTenancy::class,",
|
||||
file_get_contents(app_path('Http/Kernel.php'))
|
||||
\file_get_contents(app_path('Http/Kernel.php'))
|
||||
));
|
||||
$this->info('✔️ Set middleware priority');
|
||||
|
||||
file_put_contents(base_path('routes/tenant.php'),
|
||||
\file_put_contents(base_path('routes/tenant.php'),
|
||||
"<?php
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Run extends Command
|
|||
|
||||
$callback = function ($prefix = '') {
|
||||
return function ($arguments, $argument) use ($prefix) {
|
||||
[$key, $value] = explode('=', $argument, 2);
|
||||
[$key, $value] = \explode('=', $argument, 2);
|
||||
$arguments[$prefix . $key] = $value;
|
||||
|
||||
return $arguments;
|
||||
|
|
@ -48,13 +48,13 @@ class Run extends Command
|
|||
};
|
||||
|
||||
// Turns ['foo=bar', 'abc=xyz=zzz'] into ['foo' => 'bar', 'abc' => 'xyz=zzz']
|
||||
$arguments = array_reduce($this->option('argument'), $callback(), []);
|
||||
$arguments = \array_reduce($this->option('argument'), $callback(), []);
|
||||
|
||||
// Turns ['foo=bar', 'abc=xyz=zzz'] into ['--foo' => 'bar', '--abc' => 'xyz=zzz']
|
||||
$options = array_reduce($this->option('option'), $callback('--'), []);
|
||||
$options = \array_reduce($this->option('option'), $callback('--'), []);
|
||||
|
||||
// Run command
|
||||
$this->call($this->argument('commandname'), array_merge($arguments, $options));
|
||||
$this->call($this->argument('commandname'), \array_merge($arguments, $options));
|
||||
|
||||
tenancy()->end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ final class DatabaseManager
|
|||
|
||||
$databaseManagers = config('tenancy.database_managers');
|
||||
|
||||
if (! array_key_exists($driver, $databaseManagers)) {
|
||||
if (! \array_key_exists($driver, $databaseManagers)) {
|
||||
throw new \Exception("Database could not be created: no database manager for driver $driver is registered.");
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ final class DatabaseManager
|
|||
|
||||
$databaseManagers = config('tenancy.database_managers');
|
||||
|
||||
if (! array_key_exists($driver, $databaseManagers)) {
|
||||
if (! \array_key_exists($driver, $databaseManagers)) {
|
||||
throw new \Exception("Database could not be deleted: no database manager for driver $driver is registered.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class RedisStorageDriver implements StorageDriver
|
|||
return $this->redis->hgetall("tenants:$uuid");
|
||||
}
|
||||
|
||||
return array_combine($fields, $this->redis->hmget("tenants:$uuid", $fields));
|
||||
return \array_combine($fields, $this->redis->hmget("tenants:$uuid", $fields));
|
||||
}
|
||||
|
||||
public function getTenantIdByDomain(string $domain): ?string
|
||||
|
|
@ -48,7 +48,7 @@ class RedisStorageDriver implements StorageDriver
|
|||
public function createTenant(string $domain, string $uuid): array
|
||||
{
|
||||
$this->redis->hmset("domains:$domain", 'tenant_id', $uuid);
|
||||
$this->redis->hmset("tenants:$uuid", 'uuid', json_encode($uuid), 'domain', json_encode($domain));
|
||||
$this->redis->hmset("tenants:$uuid", 'uuid', \json_encode($uuid), 'domain', \json_encode($domain));
|
||||
|
||||
return $this->redis->hgetall("tenants:$uuid");
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class RedisStorageDriver implements StorageDriver
|
|||
public function deleteTenant(string $id): bool
|
||||
{
|
||||
try {
|
||||
$domain = json_decode($this->getTenantById($id)['domain']);
|
||||
$domain = \json_decode($this->getTenantById($id)['domain']);
|
||||
} catch (\Throwable $th) {
|
||||
throw new \Exception("No tenant with UUID $id exists.");
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ class RedisStorageDriver implements StorageDriver
|
|||
|
||||
public function getAllTenants(array $uuids = []): array
|
||||
{
|
||||
$hashes = array_map(function ($hash) {
|
||||
$hashes = \array_map(function ($hash) {
|
||||
return "tenants:{$hash}";
|
||||
}, $uuids);
|
||||
|
||||
|
|
@ -91,13 +91,13 @@ class RedisStorageDriver implements StorageDriver
|
|||
$all_keys = $this->redis->scan(null, 'MATCH', $redis_prefix . 'tenants:*')[1];
|
||||
}
|
||||
|
||||
$hashes = array_map(function ($key) use ($redis_prefix) {
|
||||
$hashes = \array_map(function ($key) use ($redis_prefix) {
|
||||
// Left strip $redis_prefix from $key
|
||||
return substr($key, strlen($redis_prefix));
|
||||
return \substr($key, \strlen($redis_prefix));
|
||||
}, $all_keys);
|
||||
}
|
||||
|
||||
return array_map(function ($tenant) {
|
||||
return \array_map(function ($tenant) {
|
||||
return $this->redis->hgetall($tenant);
|
||||
}, $hashes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ class Tenant extends Model
|
|||
public static function decodeData($tenant)
|
||||
{
|
||||
$tenant = $tenant instanceof self ? (array) $tenant->attributes : $tenant;
|
||||
$decoded = json_decode($tenant[$dataColumn = static::dataColumn()], true);
|
||||
$decoded = \json_decode($tenant[$dataColumn = static::dataColumn()], true);
|
||||
|
||||
foreach ($decoded as $key => $value) {
|
||||
$tenant[$key] = $value;
|
||||
}
|
||||
|
||||
// If $tenant[$dataColumn] has been overriden by a value, don't delete the key.
|
||||
if (! array_key_exists($dataColumn, $decoded)) {
|
||||
if (! \array_key_exists($dataColumn, $decoded)) {
|
||||
unset($tenant[$dataColumn]);
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class Tenant extends Model
|
|||
|
||||
public function getFromData(string $key)
|
||||
{
|
||||
$this->dataArray = $this->dataArray ?? json_decode($this->{$this->dataColumn()}, true);
|
||||
$this->dataArray = $this->dataArray ?? \json_decode($this->{$this->dataColumn()}, true);
|
||||
|
||||
return $this->dataArray[$key] ?? null;
|
||||
}
|
||||
|
|
@ -83,18 +83,18 @@ class Tenant extends Model
|
|||
/** @todo In v2, this should return an associative array. */
|
||||
public function getMany(array $keys): array
|
||||
{
|
||||
return array_map([$this, 'get'], $keys);
|
||||
return \array_map([$this, 'get'], $keys);
|
||||
}
|
||||
|
||||
public function put(string $key, $value)
|
||||
{
|
||||
if (array_key_exists($key, $this->customColumns())) {
|
||||
if (\array_key_exists($key, $this->customColumns())) {
|
||||
$this->update([$key => $value]);
|
||||
} else {
|
||||
$obj = json_decode($this->{$this->dataColumn()});
|
||||
$obj = \json_decode($this->{$this->dataColumn()});
|
||||
$obj->$key = $value;
|
||||
|
||||
$this->update([$this->dataColumn() => json_encode($obj)]);
|
||||
$this->update([$this->dataColumn() => \json_encode($obj)]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class SQLiteDatabaseManager implements TenantDatabaseManager
|
|||
public function createDatabase(string $name): bool
|
||||
{
|
||||
try {
|
||||
return fclose(fopen(database_path($name), 'w'));
|
||||
return \fclose(\fopen(database_path($name), 'w'));
|
||||
} catch (\Throwable $th) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ class SQLiteDatabaseManager implements TenantDatabaseManager
|
|||
public function deleteDatabase(string $name): bool
|
||||
{
|
||||
try {
|
||||
return unlink(database_path($name));
|
||||
return \unlink(database_path($name));
|
||||
} catch (\Throwable $th) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ final class TenantManager
|
|||
|
||||
$tenant = $this->storage->identifyTenant($domain);
|
||||
|
||||
if (! $tenant || ! array_key_exists('uuid', $tenant) || ! $tenant['uuid']) {
|
||||
if (! $tenant || ! \array_key_exists('uuid', $tenant) || ! $tenant['uuid']) {
|
||||
throw new \Exception("Tenant could not be identified on domain {$domain}.");
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ final class TenantManager
|
|||
if ($data) {
|
||||
$this->put($data, null, $tenant['uuid']);
|
||||
|
||||
$tenant = array_merge($tenant, $data);
|
||||
$tenant = \array_merge($tenant, $data);
|
||||
}
|
||||
|
||||
$this->database->create($this->getDatabaseName($tenant));
|
||||
|
|
@ -175,7 +175,7 @@ final class TenantManager
|
|||
|
||||
$uuid = $this->getIdByDomain($domain);
|
||||
|
||||
if (is_null($uuid)) {
|
||||
if (\is_null($uuid)) {
|
||||
throw new \Exception("Tenant with domain $domain could not be identified.");
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ final class TenantManager
|
|||
$tenants = $this->storage->getAllTenants($uuids);
|
||||
|
||||
if ($this->useJson()) {
|
||||
$tenants = array_map(function ($tenant_array) {
|
||||
$tenants = \array_map(function ($tenant_array) {
|
||||
return $this->jsonDecodeArrayValues($tenant_array);
|
||||
}, $tenants);
|
||||
}
|
||||
|
|
@ -273,8 +273,8 @@ final class TenantManager
|
|||
{
|
||||
$uuid = $uuid ?: $this->tenant['uuid'];
|
||||
|
||||
if (array_key_exists('uuid', $this->tenant) && $uuid === $this->tenant['uuid'] &&
|
||||
array_key_exists($key, $this->tenant) && ! is_array($key)) {
|
||||
if (\array_key_exists('uuid', $this->tenant) && $uuid === $this->tenant['uuid'] &&
|
||||
\array_key_exists($key, $this->tenant) && ! \is_array($key)) {
|
||||
return $this->tenant[$key];
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ final class TenantManager
|
|||
return $this->jsonDecodeArrayValues($this->storage->getMany($uuid, $key));
|
||||
}
|
||||
|
||||
return json_decode($this->storage->get($uuid, $key), true);
|
||||
return \json_decode($this->storage->get($uuid, $key), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -295,10 +295,10 @@ final class TenantManager
|
|||
*/
|
||||
public function put($key, $value = null, string $uuid = null)
|
||||
{
|
||||
if (in_array($key, ['uuid', 'domain'], true) || (
|
||||
is_array($key) && (
|
||||
in_array('uuid', array_keys($key), true) ||
|
||||
in_array('domain', array_keys($key), true)
|
||||
if (\in_array($key, ['uuid', 'domain'], true) || (
|
||||
\is_array($key) && (
|
||||
\in_array('uuid', \array_keys($key), true) ||
|
||||
\in_array('domain', \array_keys($key), true)
|
||||
)
|
||||
)) {
|
||||
throw new CannotChangeUuidOrDomainException;
|
||||
|
|
@ -319,7 +319,7 @@ final class TenantManager
|
|||
}
|
||||
|
||||
if (! \is_null($value)) {
|
||||
return $target[$key] = json_decode($this->storage->put($uuid, $key, json_encode($value)), true);
|
||||
return $target[$key] = \json_decode($this->storage->put($uuid, $key, \json_encode($value)), true);
|
||||
}
|
||||
|
||||
if (! \is_array($key)) {
|
||||
|
|
@ -328,7 +328,7 @@ final class TenantManager
|
|||
|
||||
foreach ($key as $k => $v) {
|
||||
$target[$k] = $v;
|
||||
$key[$k] = json_encode($v);
|
||||
$key[$k] = \json_encode($v);
|
||||
}
|
||||
|
||||
return $this->jsonDecodeArrayValues($this->storage->putMany($uuid, $key));
|
||||
|
|
@ -349,8 +349,8 @@ final class TenantManager
|
|||
|
||||
protected function jsonDecodeArrayValues(array $array)
|
||||
{
|
||||
array_walk($array, function (&$value, $key) {
|
||||
$value = json_decode($value, true);
|
||||
\array_walk($array, function (&$value, $key) {
|
||||
$value = \json_decode($value, true);
|
||||
});
|
||||
|
||||
return $array;
|
||||
|
|
@ -358,7 +358,7 @@ final class TenantManager
|
|||
|
||||
public function useJson()
|
||||
{
|
||||
if (property_exists($this->storage, 'useJson') && $this->storage->useJson === false) {
|
||||
if (\property_exists($this->storage, 'useJson') && $this->storage->useJson === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TenantRouteServiceProvider extends RouteServiceProvider
|
|||
public function map()
|
||||
{
|
||||
if (! \in_array(request()->getHost(), $this->app['config']['tenancy.exempt_domains'] ?? [])
|
||||
&& file_exists(base_path('routes/tenant.php'))) {
|
||||
&& \file_exists(base_path('routes/tenant.php'))) {
|
||||
Route::middleware(['web', 'tenancy'])
|
||||
->namespace($this->app['config']['tenant_route_namespace'] ?? 'App\Http\Controllers')
|
||||
->group(base_path('routes/tenant.php'));
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ trait BootstrapsTenancy
|
|||
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
|
||||
$old['disks'][$disk] = Storage::disk($disk)->getAdapter()->getPathPrefix();
|
||||
|
||||
if ($root = str_replace('%storage_path%', storage_path(), $this->app['config']["tenancy.filesystem.root_override.{$disk}"])) {
|
||||
if ($root = \str_replace('%storage_path%', storage_path(), $this->app['config']["tenancy.filesystem.root_override.{$disk}"])) {
|
||||
Storage::disk($disk)->getAdapter()->setPathPrefix($root);
|
||||
} else {
|
||||
$root = $this->app['config']["filesystems.disks.{$disk}.root"];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ trait HasATenantsOption
|
|||
{
|
||||
protected function getOptions()
|
||||
{
|
||||
return array_merge([
|
||||
return \array_merge([
|
||||
['tenants', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, '', null],
|
||||
], parent::getOptions());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ trait TenantManagerEvents
|
|||
*/
|
||||
public function event(string $name): Collection
|
||||
{
|
||||
return array_reduce($this->listeners[$name], function ($prevents, $listener) {
|
||||
return \array_reduce($this->listeners[$name], function ($prevents, $listener) {
|
||||
return $prevents->merge($listener($this) ?? []);
|
||||
}, collect([]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use Stancl\Tenancy\TenantManager;
|
||||
|
||||
if (! function_exists('tenancy')) {
|
||||
if (! \function_exists('tenancy')) {
|
||||
function tenancy($key = null)
|
||||
{
|
||||
if ($key) {
|
||||
|
|
@ -13,14 +13,14 @@ if (! function_exists('tenancy')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! function_exists('tenant')) {
|
||||
if (! \function_exists('tenant')) {
|
||||
function tenant($key = null)
|
||||
{
|
||||
return tenancy($key);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('tenant_asset')) {
|
||||
if (! \function_exists('tenant_asset')) {
|
||||
function tenant_asset($asset)
|
||||
{
|
||||
return route('stancl.tenancy.asset', ['asset' => $asset]);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class BootstrapsTenancyTest extends TestCase
|
|||
$current_path_prefix = \Storage::disk($disk)->getAdapter()->getPathPrefix();
|
||||
|
||||
if ($override = config("tenancy.filesystem.root_override.{$disk}")) {
|
||||
$correct_path_prefix = str_replace('%storage_path%', storage_path(), $override);
|
||||
$correct_path_prefix = \str_replace('%storage_path%', storage_path(), $override);
|
||||
} else {
|
||||
if ($base = $old_storage_facade_roots[$disk]) {
|
||||
$correct_path_prefix = $base . "/$suffix/";
|
||||
|
|
|
|||
|
|
@ -117,14 +117,14 @@ class CommandsTest extends TestCase
|
|||
/** @test */
|
||||
public function install_command_works()
|
||||
{
|
||||
if (! is_dir($dir = app_path('Http'))) {
|
||||
mkdir($dir, 0777, true);
|
||||
if (! \is_dir($dir = app_path('Http'))) {
|
||||
\mkdir($dir, 0777, true);
|
||||
}
|
||||
if (! is_dir($dir = base_path('routes'))) {
|
||||
mkdir($dir, 0777, true);
|
||||
if (! \is_dir($dir = base_path('routes'))) {
|
||||
\mkdir($dir, 0777, true);
|
||||
}
|
||||
|
||||
file_put_contents(app_path('Http/Kernel.php'), "<?php
|
||||
\file_put_contents(app_path('Http/Kernel.php'), "<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class ReidentificationTest extends TestCase
|
|||
$current_path_prefix = \Storage::disk($disk)->getAdapter()->getPathPrefix();
|
||||
|
||||
if ($override = config("tenancy.filesystem.root_override.{$disk}")) {
|
||||
$correct_path_prefix = str_replace('%storage_path%', storage_path(), $override);
|
||||
$correct_path_prefix = \str_replace('%storage_path%', storage_path(), $override);
|
||||
} else {
|
||||
if ($base = $originals[$disk]) {
|
||||
$correct_path_prefix = $base . "/$suffix/";
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ class TenantAssetTest extends TestCase
|
|||
$this->get(tenant_asset($filename))->assertSuccessful();
|
||||
$this->assertFileExists($path);
|
||||
|
||||
$f = fopen($path, 'r');
|
||||
$content = fread($f, filesize($path));
|
||||
fclose($f);
|
||||
$f = \fopen($path, 'r');
|
||||
$content = \fread($f, \filesize($path));
|
||||
\fclose($f);
|
||||
|
||||
$this->assertSame('bar', $content);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class TenantDatabaseManagerTest extends TestCase
|
|||
|
||||
config()->set('database.default', 'pgsql');
|
||||
|
||||
$db_name = strtolower('testdatabase' . $this->randomString(10));
|
||||
$db_name = \strtolower('testdatabase' . $this->randomString(10));
|
||||
$this->assertTrue(app(DatabaseManager::class)->create($db_name, 'pgsql'));
|
||||
$this->assertNotEmpty(DB::select("SELECT datname FROM pg_database WHERE datname = '$db_name'"));
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ class TenantDatabaseManagerTest extends TestCase
|
|||
|
||||
config()->set('database.default', 'pgsql');
|
||||
|
||||
$db_name = strtolower('testdatabase' . $this->randomString(10));
|
||||
$db_name = \strtolower('testdatabase' . $this->randomString(10));
|
||||
|
||||
$databaseManagers = config('tenancy.database_managers');
|
||||
$job = new QueuedTenantDatabaseCreator(app($databaseManagers['pgsql']), $db_name);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class TenantStorageTest extends TestCase
|
|||
{
|
||||
$keys = ['foo', 'abc'];
|
||||
$vals = ['bar', 'xyz'];
|
||||
$data = array_combine($keys, $vals);
|
||||
$data = \array_combine($keys, $vals);
|
||||
|
||||
tenancy()->put($data);
|
||||
dd(tenant()->get($keys));
|
||||
|
|
@ -76,13 +76,13 @@ class TenantStorageTest extends TestCase
|
|||
|
||||
$keys = ['foo', 'abc'];
|
||||
$vals = ['bar', 'xyz'];
|
||||
$data = array_combine($keys, $vals);
|
||||
$data = \array_combine($keys, $vals);
|
||||
|
||||
tenancy()->put($data, null, $uuid);
|
||||
|
||||
$this->assertSame($vals, tenancy()->get($keys, $uuid));
|
||||
$this->assertNotSame($vals, tenancy()->get($keys));
|
||||
$this->assertFalse(array_intersect($data, tenant()->tenant) == $data); // assert array not subset
|
||||
$this->assertFalse(\array_intersect($data, tenant()->tenant) == $data); // assert array not subset
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
@ -130,15 +130,15 @@ class TenantStorageTest extends TestCase
|
|||
public function data_is_stored_with_correct_data_types()
|
||||
{
|
||||
tenancy()->put('someBool', false);
|
||||
$this->assertSame('boolean', gettype(tenancy()->get('someBool')));
|
||||
$this->assertSame('boolean', \gettype(tenancy()->get('someBool')));
|
||||
|
||||
tenancy()->put('someInt', 5);
|
||||
$this->assertSame('integer', gettype(tenancy()->get('someInt')));
|
||||
$this->assertSame('integer', \gettype(tenancy()->get('someInt')));
|
||||
|
||||
tenancy()->put('someDouble', 11.40);
|
||||
$this->assertSame('double', gettype(tenancy()->get('someDouble')));
|
||||
$this->assertSame('double', \gettype(tenancy()->get('someDouble')));
|
||||
|
||||
tenancy()->put('string', 'foo');
|
||||
$this->assertSame('string', gettype(tenancy()->get('string')));
|
||||
$this->assertSame('string', \gettype(tenancy()->get('string')));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
Redis::connection('cache')->flushdb();
|
||||
|
||||
$this->loadMigrationsFrom([
|
||||
'--path' => realpath(__DIR__ . '/../assets/migrations'),
|
||||
'--path' => \realpath(__DIR__ . '/../assets/migrations'),
|
||||
'--database' => 'central',
|
||||
]);
|
||||
config(['database.default' => 'sqlite']); // fix issue caused by loadMigrationsFrom
|
||||
|
|
@ -63,11 +63,11 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
*/
|
||||
protected function getEnvironmentSetUp($app)
|
||||
{
|
||||
if (file_exists(__DIR__ . '/../.env')) {
|
||||
if (\file_exists(__DIR__ . '/../.env')) {
|
||||
\Dotenv\Dotenv::create(__DIR__ . '/..')->load();
|
||||
}
|
||||
|
||||
fclose(fopen(database_path('central.sqlite'), 'w'));
|
||||
\fclose(\fopen(database_path('central.sqlite'), 'w'));
|
||||
|
||||
$app['config']->set([
|
||||
'database.redis.cache.host' => env('TENANCY_TEST_REDIS_HOST', '127.0.0.1'),
|
||||
|
|
@ -160,7 +160,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
|
||||
public function randomString(int $length = 10)
|
||||
{
|
||||
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
|
||||
return \substr(\str_shuffle(\str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', \ceil($length / \strlen($x)))), 1, $length);
|
||||
}
|
||||
|
||||
public function isContainerized()
|
||||
|
|
@ -170,6 +170,6 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
|
||||
public function assertArrayIsSubset($subset, $array, string $message = ''): void
|
||||
{
|
||||
parent::assertTrue(array_intersect($subset, $array) == $subset, $message);
|
||||
parent::assertTrue(\array_intersect($subset, $array) == $subset, $message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue