|
11 | 11 | use Laravel\Boost\Install\CodeEnvironment\VSCode;
|
12 | 12 | use Tests\Unit\Install\ExampleCodeEnvironment;
|
13 | 13 |
|
14 |
| -it('return default code environments', function (): void { |
| 14 | +it('returns default code environments', function (): void { |
15 | 15 | $manager = new BoostManager;
|
16 | 16 | $registered = $manager->getCodeEnvironments();
|
17 | 17 |
|
|
49 | 49 | ->and($registered)->toHaveKey('phpstorm');
|
50 | 50 | });
|
51 | 51 |
|
52 |
| -it('does not overwrite default code environments', function (): void { |
| 52 | +it('throws an exception when registering a duplicate key', function (): void { |
53 | 53 | $manager = new BoostManager;
|
54 |
| - $manager->registerCodeEnvironment('phpstorm', PHPStorm::class); |
55 |
| - $manager->registerCodeEnvironment('phpstorm', ExampleCodeEnvironment::class); |
56 | 54 |
|
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); |
58 | 62 |
|
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"); |
62 | 65 | });
|
0 commit comments