Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Sep 23, 2024
1 parent abcfda4 commit fc3744d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Attributes/RequiresDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class RequiresDatabase implements ActionableContract
public function __construct(
public string $driver,
public ?string $versionRequirement = null,
public ?string $connection = null,
public bool $default = true
) {
//
Expand All @@ -34,10 +35,14 @@ public function __construct(
*/
public function handle($app, Closure $action): void
{
$connection = DB::connection($this->driver);
$connection = DB::connection($this->connection);

if ($this->default === true && (DB::connection() !== $connection)) {
\call_user_func($action, 'markTestSkipped', [\sprintf('Requires %s as the default database connection', $connection->getName())]);
if ($connection->getDriverName() !== $this->driver) {
if ($this->default === true) {
\call_user_func($action, 'markTestSkipped', [\sprintf('Requires %s as the default database connection', $connection->getName())]);
} else {
\call_user_func($action, 'markTestSkipped', [\sprintf('Requires %s to use %s database connection', $connection->getName(), $this->driver)]);
}
}

if (
Expand Down

0 comments on commit fc3744d

Please sign in to comment.