Skip to content

Commit

Permalink
Refactor: Replace RuntimeException with FormulaException
Browse files Browse the repository at this point in the history
Updated exception handling in GenFormulaTest.php by replacing RuntimeException with FormulaException. This change improves clarity and consistency in how exceptions are managed within the class.
  • Loading branch information
koriym committed Nov 14, 2024
1 parent 88dc90c commit 4d91be2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/GenFormulaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace BEAR\Cli;

use BEAR\AppMeta\Meta;
use BEAR\Cli\Exception\RuntimeException;
use BEAR\Cli\Exception\FormulaException;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

Expand Down Expand Up @@ -90,7 +90,7 @@ public function detectMainBranch(string $repoUrl): string
};
$genFormula = new GenFormula($gitCommand);

$this->expectException(RuntimeException::class);
$this->expectException(FormulaException::class);
$this->expectExceptionMessage('Git remote URL is not configured');

$genFormula($this->meta);
Expand All @@ -101,7 +101,7 @@ public function testThrowsExceptionWhenGetRemoteUrlFails(): void
$gitCommand = new class implements GitCommandInterface {
public function getRemoteUrl(): never
{
throw new \RuntimeException('Command failed');
throw new FormulaException('Command failed');
}

public function detectMainBranch(string $repoUrl): string
Expand All @@ -111,7 +111,7 @@ public function detectMainBranch(string $repoUrl): string
};
$genFormula = new GenFormula($gitCommand);

$this->expectException(RuntimeException::class);
$this->expectException(FormulaException::class);
$this->expectExceptionMessage('Failed to get Git remote URL: Command failed');

$genFormula($this->meta);
Expand All @@ -127,12 +127,12 @@ public function getRemoteUrl(): string

public function detectMainBranch(string $repoUrl): never
{
throw new \RuntimeException('Branch detection failed');
throw new FormulaException('Branch detection failed');
}
};
$genFormula = new GenFormula($gitCommand);

$this->expectException(RuntimeException::class);
$this->expectException(FormulaException::class);
$this->expectExceptionMessage('Failed to detect main branch: Branch detection failed');

$genFormula($this->meta);
Expand All @@ -153,7 +153,7 @@ public function detectMainBranch(string $repoUrl): string
};
$genFormula = new GenFormula($gitCommand);

$this->expectException(RuntimeException::class);
$this->expectException(FormulaException::class);
$this->expectExceptionMessage('Invalid GitHub URL format');

$genFormula($this->meta);
Expand Down

0 comments on commit 4d91be2

Please sign in to comment.