mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 14:14:04 +00:00
Fix assert: run createDatabase() outside assert()
assert() calls, including assert(foo()), can be entirely compiled out depending on the INI settings described here: https://www.php.net/manual/en/function.assert.php That in turn means even side effects of foo() can be entirely compiled out. Therefore, to ensure the call actually runs, we need to run it before the assert(), store its return value, and only then make assertions about the return value.
This commit is contained in:
parent
6049ade20e
commit
91f6c61fcd
1 changed files with 2 additions and 1 deletions
|
|
@ -40,7 +40,8 @@ class CreateDatabase implements ShouldQueue
|
|||
|
||||
try {
|
||||
$databaseManager->ensureTenantCanBeCreated($this->tenant);
|
||||
assert($this->tenant->database()->manager()->createDatabase($this->tenant) === true);
|
||||
$databaseCreated = $this->tenant->database()->manager()->createDatabase($this->tenant);
|
||||
assert($databaseCreated);
|
||||
|
||||
event(new DatabaseCreated($this->tenant));
|
||||
} catch (TenantDatabaseAlreadyExistsException | TenantDatabaseUserAlreadyExistsException $e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue