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 a65bf75 commit ff3039f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Attributes/RequiresDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(
public ?string $connection = null,
public bool $default = true
) {
if (is_array($driver) && $default === true) {
if (\is_array($driver) && $default === true) {
throw new InvalidArgumentException('Unable to validate default connection when given an array of database drivers');
}
}
Expand All @@ -43,31 +43,31 @@ public function handle($app, Closure $action): void

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

$drivers = Arr::wrap($this->driver);
$usingCorrectConnection = false;

foreach (Arr::wrap($this->driver) as $driver) {
foreach ($drivers as $driver) {
if ($connection->getDriverName() === $driver) {
$usingCorrectConnection = true;
}
}


if ($usingCorrectConnection === false) {
\call_user_func(
$action,
'markTestSkipped',
[\sprintf('Requires %s to use [%s] database connection', $connection->getName(), Arr::join($driver, ','))]
[\sprintf('Requires %s to use [%s] database connection', $connection->getName(), Arr::join($drivers, ','))]
);
}

if (
! is_null($this->versionRequirement)
! \is_null($this->versionRequirement)
&& preg_match('/(?P<operator>[<>=!]{0,2})\s*(?P<version>[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m', $this->versionRequirement, $matches)
) {
if (empty($matches['operator'])) {
Expand Down

0 comments on commit ff3039f

Please sign in to comment.