|
4 | 4 |
|
5 | 5 | namespace Tests\Unit\Install\Mcp; |
6 | 6 |
|
| 7 | +use Illuminate\Contracts\Filesystem\Filesystem; |
7 | 8 | use Illuminate\Support\Facades\File; |
8 | 9 | use Illuminate\Support\Str; |
9 | 10 | use Laravel\Boost\Install\Mcp\FileWriter; |
10 | 11 | use Mockery; |
11 | 12 | use ReflectionClass; |
12 | 13 |
|
13 | | -beforeEach(function (): void { |
14 | | - Mockery::close(); |
15 | | -}); |
16 | | - |
17 | 14 | test('constructor sets file path', function (): void { |
18 | 15 | $writer = new FileWriter('/path/to/mcp.json'); |
19 | 16 | expect($writer)->toBeInstanceOf(FileWriter::class); |
|
283 | 280 | test("injecting twice into existing JSON 5 doesn't cause duplicates", function (): void { |
284 | 281 | $capturedContent = ''; |
285 | 282 |
|
286 | | - File::clearResolvedInstances(); |
287 | | - File::partialMock(); |
| 283 | + File::swap(Mockery::mock(Filesystem::class)); |
288 | 284 |
|
289 | 285 | File::shouldReceive('ensureDirectoryExists')->once(); |
290 | 286 | File::shouldReceive('exists')->andReturn(true); |
|
313 | 309 |
|
314 | 310 | $newContent = $capturedContent; |
315 | 311 |
|
316 | | - File::clearResolvedInstances(); |
317 | | - File::partialMock(); |
| 312 | + File::swap(Mockery::mock(Filesystem::class)); |
318 | 313 |
|
319 | 314 | File::shouldReceive('ensureDirectoryExists')->once(); |
320 | 315 | File::shouldReceive('exists')->andReturn(true); |
|
388 | 383 | function mockFileOperations(bool $fileExists = false, string $content = '{}', bool $writeSuccess = true, ?string &$capturedPath = null, ?string &$capturedContent = null): void |
389 | 384 | { |
390 | 385 | // Clear any existing File facade mock |
391 | | - File::clearResolvedInstances(); |
392 | | - File::partialMock(); |
| 386 | + File::swap(Mockery::mock(Filesystem::class)); |
393 | 387 |
|
394 | 388 | File::shouldReceive('ensureDirectoryExists')->once(); |
395 | 389 | File::shouldReceive('exists')->andReturn($fileExists); |
|
0 commit comments