mnapoli/phpunit-easymock
A lightweight bridge between PHPUnit and EasyMock for PHP. Quickly create, replay, and verify mocks from your test cases with minimal boilerplate, helping you write clear unit tests using the familiar EasyMock-style workflow.
Install via Composer: composer require --dev mnapoli/phpunit-easymock. The package provides a simple, fluent API to generate mock objects without boilerplate—ideal for writing fast, isolated unit tests. Start by using EasyMock::make() to create mocks of interfaces or classes. For example:
$mock = EasyMock::make(Service::class);
$mock->method('doSomething')->willReturn('result');
The first use case is typically mocking dependencies in your tests to isolate the unit under test—replacing real services with controllable, inspectable stand-ins.
->method('foo')->with('bar')->willReturn('baz')) for readability.EasyMock::partialMock() to mock only specific methods while retaining real implementations of others.->property('name')->willReturn('value').method() is case-sensitive—'getUserId' ≠ 'getuserid'.willReturn() or similar, method calls may trigger actual logic—always assert or stub side-effectful methods explicitly.->verbose() to see detailed expectations failures in test output.EasyMock\Builder if your project has recurring mocking conventions (e.g., mocking API clients with identical base setup).How can I help you explore Laravel packages today?