Skip to content

Commit 6f4b689

Browse files
authored
Merge pull request #232 from felipeArnold/convert-multiple-expectations-into-chain
tests: convert multiple expectations into chain
2 parents 6bcab8b + 3d49472 commit 6f4b689

File tree

8 files changed

+38
-38
lines changed

8 files changed

+38
-38
lines changed

tests/Feature/BoostServiceProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
$provider->register();
3131
$provider->boot(app('router'));
3232

33-
expect(app()->bound(Laravel\Roster\Roster::class))->toBeTrue();
34-
expect(config('logging.channels.browser'))->not->toBeNull();
33+
expect(app()->bound(Laravel\Roster\Roster::class))->toBeTrue()
34+
->and(config('logging.channels.browser'))->not->toBeNull();
3535
});
3636
});
3737

tests/Feature/Mcp/ToolExecutorTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
expect(false)->toBeTrue("Tool execution failed with error: {$errorText}");
2424
}
2525

26-
expect($result->isError)->toBeFalse();
27-
expect($result->content)->toBeArray();
26+
expect($result->isError)->toBeFalse()
27+
->and($result->content)->toBeArray();
2828

2929
// The content should contain the app name (which should be "Laravel" in testbench)
3030
$textContent = $result->content[0]->text ?? '';
@@ -48,15 +48,15 @@
4848
$result1 = $executor->execute(Tinker::class, ['code' => 'return getmypid();']);
4949
$result2 = $executor->execute(Tinker::class, ['code' => 'return getmypid();']);
5050

51-
expect($result1->isError)->toBeFalse();
52-
expect($result2->isError)->toBeFalse();
51+
expect($result1->isError)->toBeFalse()
52+
->and($result2->isError)->toBeFalse();
5353

5454
$pid1 = json_decode($result1->content[0]->text, true)['result'];
5555
$pid2 = json_decode($result2->content[0]->text, true)['result'];
5656

57-
expect($pid1)->toBeInt()->not->toBe(getmypid());
58-
expect($pid2)->toBeInt()->not->toBe(getmypid());
59-
expect($pid1)->not()->toBe($pid2);
57+
expect($pid1)->toBeInt()->not->toBe(getmypid())
58+
->and($pid2)->toBeInt()->not->toBe(getmypid())
59+
->and($pid1)->not()->toBe($pid2);
6060
});
6161

6262
test('subprocess sees modified autoloaded code changes', function () {
@@ -92,8 +92,8 @@
9292
$result2 = $executor->execute(GetConfig::class, ['key' => 'app.name']);
9393
$response2 = json_decode($result2->content[0]->text, true);
9494

95-
expect($result2->isError)->toBeFalse();
96-
expect($response2['value'])->toBe('MODIFIED_BY_TEST'); // Using updated code, not cached
95+
expect($result2->isError)->toBeFalse()
96+
->and($response2['value'])->toBe('MODIFIED_BY_TEST'); // Using updated code, not cached
9797
} finally {
9898
$cleanup();
9999
}

tests/Feature/Mcp/ToolRegistryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
});
1212

1313
test('can check if tool is allowed', function () {
14-
expect(ToolRegistry::isToolAllowed(ApplicationInfo::class))->toBeTrue();
15-
expect(ToolRegistry::isToolAllowed('NonExistentTool'))->toBeFalse();
14+
expect(ToolRegistry::isToolAllowed(ApplicationInfo::class))->toBeTrue()
15+
->and(ToolRegistry::isToolAllowed('NonExistentTool'))->toBeFalse();
1616
});
1717

1818
test('can get tool names', function () {

tests/Unit/Install/CodeEnvironment/CodeEnvironmentTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ public function mcpConfigPath(): string
327327

328328
$result = $environment->installMcp('test-key', 'test-command', ['arg1'], ['ENV' => 'value']);
329329

330-
expect($result)->toBe(true);
331-
expect($capturedPath)->toBe($environment->mcpConfigPath());
332-
expect($capturedContent)->toBe($expectedContent);
330+
expect($result)->toBe(true)
331+
->and($capturedPath)->toBe($environment->mcpConfigPath())
332+
->and($capturedContent)->toBe($expectedContent);
333333
});
334334

335335
test('installFileMcp updates existing config file', function () {

tests/Unit/Install/CodeEnvironmentsDetectorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@
225225

226226
$detected = $this->detector->discoverProjectInstalledCodeEnvironments($tempDir);
227227

228-
expect($detected)->toContain('vscode');
229-
expect($detected)->toContain('cursor');
230-
expect($detected)->toContain('claudecode');
231-
expect(count($detected))->toBeGreaterThanOrEqual(3);
228+
expect($detected)->toContain('vscode')
229+
->and($detected)->toContain('cursor')
230+
->and($detected)->toContain('claudecode')
231+
->and(count($detected))->toBeGreaterThanOrEqual(3);
232232

233233
// Cleanup
234234
rmdir($tempDir.'/.vscode');

tests/Unit/Install/Detection/DirectoryDetectionStrategyTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@
185185
expect($isAbsolutePathMethod->invoke($this->strategy, '/usr/local/bin'))->toBeTrue();
186186

187187
// Windows absolute paths
188-
expect($isAbsolutePathMethod->invoke($this->strategy, 'C:\\Program Files'))->toBeTrue();
189-
expect($isAbsolutePathMethod->invoke($this->strategy, 'D:\\test'))->toBeTrue();
188+
expect($isAbsolutePathMethod->invoke($this->strategy, 'C:\\Program Files'))->toBeTrue()
189+
->and($isAbsolutePathMethod->invoke($this->strategy, 'D:\\test'))->toBeTrue();
190190

191191
// Relative paths
192-
expect($isAbsolutePathMethod->invoke($this->strategy, 'relative/path'))->toBeFalse();
193-
expect($isAbsolutePathMethod->invoke($this->strategy, './relative'))->toBeFalse();
194-
expect($isAbsolutePathMethod->invoke($this->strategy, '../relative'))->toBeFalse();
192+
expect($isAbsolutePathMethod->invoke($this->strategy, 'relative/path'))->toBeFalse()
193+
->and($isAbsolutePathMethod->invoke($this->strategy, './relative'))->toBeFalse()
194+
->and($isAbsolutePathMethod->invoke($this->strategy, '../relative'))->toBeFalse();
195195
});
196196

197197
function removeDirectory(string $dir): void

tests/Unit/Install/GuidelineWriterTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
$writer = new GuidelineWriter($agent);
2727
$writer->write('test guidelines');
2828

29-
expect(is_dir(dirname($filePath)))->toBeTrue();
30-
expect(file_exists($filePath))->toBeTrue();
29+
expect(is_dir(dirname($filePath)))->toBeTrue()
30+
->and(file_exists($filePath))->toBeTrue();
3131

3232
// Cleanup
3333
unlink($filePath);
@@ -238,14 +238,14 @@
238238
$content = file_get_contents($tempFile);
239239

240240
// Verify guidelines were replaced in-place
241-
expect($content)->toContain('<laravel-boost-guidelines>');
242-
expect($content)->toContain('updated guidelines from boost');
241+
expect($content)->toContain('<laravel-boost-guidelines>')
242+
->and($content)->toContain('updated guidelines from boost');
243243

244244
// Verify user content after guidelines is preserved
245-
expect($content)->toContain('# User Added Section');
246-
expect($content)->toContain('This content was added by the user after the guidelines.');
247-
expect($content)->toContain('## Another user section');
248-
expect($content)->toContain('More content here.');
245+
expect($content)->toContain('# User Added Section')
246+
->and($content)->toContain('This content was added by the user after the guidelines.')
247+
->and($content)->toContain('## Another user section')
248+
->and($content)->toContain('More content here.');
249249

250250
// Verify exact structure
251251
expect($content)->toBe("# My Project\n\n<laravel-boost-guidelines>\nupdated guidelines from boost\n</laravel-boost-guidelines>\n\n# User Added Section\nThis content was added by the user after the guidelines.\n\n## Another user section\nMore content here.");

tests/Unit/Install/Mcp/FileWriterTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,11 @@
372372
->addServer('boost', 'php', ['artisan', 'boost:mcp'])
373373
->save();
374374

375-
expect($result)->toBeTrue();
376-
expect($writtenContent)->toContain('"boost"'); // New server added
377-
expect($writtenContent)->toContain('existing-server'); // Existing server preserved
378-
expect($writtenContent)->toContain('// Trailing comma here'); // Comments preserved
379-
expect($writtenContent)->toContain('arg1'); // Existing args preserved
375+
expect($result)->toBeTrue()
376+
->and($writtenContent)->toContain('"boost"') // New server added
377+
->and($writtenContent)->toContain('existing-server') // Existing server preserved
378+
->and($writtenContent)->toContain('// Trailing comma here') // Comments preserved
379+
->and($writtenContent)->toContain('arg1'); // Existing args preserved
380380
});
381381

382382
test('detectIndentation works correctly with various patterns', function (string $content, int $position, int $expected, string $description) {

0 commit comments

Comments
 (0)