Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Package's Status Checks #51

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename Package::isFailed() to Package::hasFailed()
gmazzap committed Aug 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 4e8e9100ce2d2db657d4bcea8a09bd6bf9835dbf
4 changes: 2 additions & 2 deletions src/Package.php
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ public function connect(Package $package): bool
}

// Don't connect, if already booted or boot failed
$failed = $this->isFailed();
$failed = $this->hasFailed();
if ($failed || $this->checkStatus(self::STATUS_INITIALIZED, '>=')) {
gmazzap marked this conversation as resolved.
Show resolved Hide resolved
$reason = $failed ? 'an errored package' : 'a package with a built container';
$status = $failed ? 'failed' : 'built_container';
@@ -634,7 +634,7 @@ public function statusIs(int $status): bool
/**
* @return bool
*/
public function isFailed(): bool
public function hasFailed(): bool
{
return $this->status === self::STATUS_FAILED;
}
10 changes: 5 additions & 5 deletions tests/unit/PackageTest.php
gmazzap marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -900,7 +900,7 @@ public function testFailureFlowWithFailureOnBootDebugModeOff(): void

static::assertFalse($package->boot());
static::assertTrue($package->statusIs(Package::STATUS_FAILED));
static::assertTrue($package->isFailed());
static::assertTrue($package->hasFailed());
}

/**
@@ -972,7 +972,7 @@ function (\Throwable $throwable) use ($exception, $package): void {
);

static::assertFalse($package->addModule($module1)->addModule($module2)->build()->boot());
static::assertTrue($package->isFailed());
static::assertTrue($package->hasFailed());
static::assertTrue($package->statusIs(Package::STATUS_FAILED));
}

@@ -1027,7 +1027,7 @@ function (\Throwable $throwable) use ($exception, $package): void {
static::assertFalse($package->connect($connected));
static::assertFalse($package->boot());
static::assertTrue($package->statusIs(Package::STATUS_FAILED));
static::assertTrue($package->isFailed());
static::assertTrue($package->hasFailed());
}

/**
@@ -1069,7 +1069,7 @@ function (\Throwable $throwable) use ($exception, $package): void {

static::assertFalse($package->build()->boot());
static::assertTrue($package->statusIs(Package::STATUS_FAILED));
static::assertTrue($package->isFailed());
static::assertTrue($package->hasFailed());
}

/**
@@ -1093,7 +1093,7 @@ public function testFailureFlowWithFailureOnBuildDebugModeOn(): void
static function (\Throwable $throwable) use ($exception, $package): void {
static::assertSame($exception, $throwable);
static::assertTrue($package->statusIs(Package::STATUS_FAILED));
static::assertTrue($package->isFailed());
static::assertTrue($package->hasFailed());
}
);