Mock the external service at the container boundary: ```php $payment = $this->mock(PaymentService::class); $payment->shouldReceive('charge') ->once() ->with(100) ->andReturnTrue(); $response = $this->post('/checkout', ['amount' => 100]); $response->assertSuccessful(); ``` Use `$this->spy()` when you need behavior verification without strict interaction expectations. Tests must not make real network calls: bind a mock, fake the transport, or use a local stub. Assert both the HTTP outcome and t...
Installs into .claude/skills of the current project.
Are you the author of Laravel Testing?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-laravel-testing-2ecd2076)
Mock the external service at the container boundary:
```php
$payment = $this->mock(PaymentService::class);
$payment->shouldReceive('charge')
->once()
->with(100)
->andReturnTrue();
$response = $this->post('/checkout', ['amount' => 100]);
$response->assertSuccessful();
```
Use `$this->spy()` when you need behavior verification without strict interaction expectations. Tests must not make real network calls: bind a mock, fake the transport, or use a local stub. Assert both the HTTP outcome and the important interaction, and keep external-service tests deterministic and isolated with `RefreshDatabase` where persistence is involved.