mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:14:02 +00:00
Fix tests
This commit is contained in:
parent
3cd97bdcab
commit
cd53ff120d
4 changed files with 6 additions and 6 deletions
|
|
@ -25,7 +25,7 @@ return [
|
|||
// 'localhost',
|
||||
],
|
||||
'database' => [
|
||||
'based_on' => 'mysql', // The connection that will be used as a base for the dynamically created tenant connection.
|
||||
'based_on' => null, // The connection that will be used as a base for the dynamically created tenant connection. // todo2 test this
|
||||
'prefix' => 'tenant',
|
||||
'suffix' => '',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Migrate extends MigrateCommand
|
|||
// See Illuminate\Database\Migrations\DatabaseMigrationRepository::getConnection.
|
||||
// Database connections are cached by Illuminate\Database\ConnectionResolver.
|
||||
$this->input->setOption('database', 'tenant');
|
||||
tenancy()->initialize($tenant); // todo2 test that this works with multiple tenants with MySQL
|
||||
tenancy()->initialize($tenant); // todo3 test that this works with multiple tenants with MySQL
|
||||
|
||||
// Migrate
|
||||
parent::handle();
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class DatabaseManager
|
|||
*/
|
||||
public function getBaseConnection(string $connectionName): string
|
||||
{
|
||||
return $connectionName
|
||||
return ($connectionName !== 'tenant' ? $connectionName : null) // 'tenant' is not a specific connection, it's the default
|
||||
?? $this->app['config']['tenancy.database.based_on']
|
||||
?? $this->originalDefaultConnectionName; // tenancy.database.based_on === null => use the default connection
|
||||
}
|
||||
|
|
@ -87,9 +87,9 @@ class DatabaseManager
|
|||
* Get the driver of a database connection.
|
||||
*
|
||||
* @param string $connectionName
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDriver(string $connectionName): string
|
||||
public function getDriver(string $connectionName): ?string
|
||||
{
|
||||
return $this->app['config']["database.connections.$connectionName.driver"];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Stancl\Tenancy\Tenant;
|
|||
|
||||
class DatabaseStorageDriver implements StorageDriver
|
||||
{
|
||||
// todo2 write tests verifying that data is decoded and added to the array
|
||||
// todo4 write tests verifying that data is decoded and added to the array
|
||||
|
||||
/** @var Application */
|
||||
protected $app;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue