Skip to content

Commit 03b282e

Browse files
committed
Fix Issues
Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent 06674db commit 03b282e

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class OpenCode extends CodeEnvironment implements Agent, McpClient
155155
{
156156
// Your implementation goes here
157157
}
158-
````
158+
```
159159

160160
### Registering the Custom Code Environment
161161

src/BoostManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Laravel\Boost;
66

7+
use InvalidArgumentException;
78
use Laravel\Boost\Install\CodeEnvironment\ClaudeCode;
89
use Laravel\Boost\Install\CodeEnvironment\CodeEnvironment;
910
use Laravel\Boost\Install\CodeEnvironment\Codex;
@@ -30,7 +31,7 @@ class BoostManager
3031
public function registerCodeEnvironment(string $key, string $className): void
3132
{
3233
if (array_key_exists($key, $this->codeEnvironments)) {
33-
return;
34+
throw new InvalidArgumentException("Code environment '{$key}' is already registered");
3435
}
3536

3637
$this->codeEnvironments[$key] = $className;

tests/Unit/BoostManagerTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Laravel\Boost\Install\CodeEnvironment\VSCode;
1212
use Tests\Unit\Install\ExampleCodeEnvironment;
1313

14-
it('return default code environments', function (): void {
14+
it('returns default code environments', function (): void {
1515
$manager = new BoostManager;
1616
$registered = $manager->getCodeEnvironments();
1717

@@ -49,14 +49,17 @@
4949
->and($registered)->toHaveKey('phpstorm');
5050
});
5151

52-
it('does not overwrite default code environments', function (): void {
52+
it('throws an exception when registering a duplicate key', function (): void {
5353
$manager = new BoostManager;
54-
$manager->registerCodeEnvironment('phpstorm', PHPStorm::class);
55-
$manager->registerCodeEnvironment('phpstorm', ExampleCodeEnvironment::class);
5654

57-
$registered = $manager->getCodeEnvironments();
55+
expect(fn () => $manager->registerCodeEnvironment('phpstorm', ExampleCodeEnvironment::class))
56+
->toThrow(InvalidArgumentException::class, "Code environment 'phpstorm' is already registered");
57+
});
58+
59+
it('throws exception when registering custom environment with a duplicate key', function (): void {
60+
$manager = new BoostManager;
61+
$manager->registerCodeEnvironment('custom', ExampleCodeEnvironment::class);
5862

59-
expect($registered)->toHaveKey('phpstorm')
60-
->and($registered['phpstorm'])->toBe(PHPStorm::class)
61-
->and($registered['phpstorm'])->not()->toBe(ExampleCodeEnvironment::class);
63+
expect(fn () => $manager->registerCodeEnvironment('custom', ExampleCodeEnvironment::class))
64+
->toThrow(InvalidArgumentException::class, "Code environment 'custom' is already registered");
6265
});

0 commit comments

Comments
 (0)