Mock external boundaries, not private methods or simple data objects: ~~~php $repository = $this->createMock(UserRepository::class); $repository->expects($this->once()) ->method('findById') ->with(42) ->willReturn($user); $service = new UserService($repository); ~~~ Assert public behavior, avoid over-mocking internals, and use an in-memory database or transaction for database integration tests.
Installs into .claude/skills of the current project.
Are you the author of Php Testing?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-php-testing-230fe524)
Mock external boundaries, not private methods or simple data objects:
~~~php
$repository = $this->createMock(UserRepository::class);
$repository->expects($this->once())
->method('findById')
->with(42)
->willReturn($user);
$service = new UserService($repository);
~~~
Assert public behavior, avoid over-mocking internals, and use an in-memory database or transaction for database integration tests.