console-helpers/prophecy-phpunit
PHPUnit integration helpers for Prophecy, providing convenience traits and utilities to streamline mock creation, prophecy assertions, and cleanup in your test suite. Designed to reduce boilerplate and keep Prophecy-based unit tests tidy and consistent.
Mockery or native PHPUnit), but this package standardizes its usage within PHPUnit test cases. Useful for teams enforcing PHPUnit as the sole testing framework.Mockery (if used) may reduce the need for this package unless Prophecy’s features (e.g., willReturnCallback()) are explicitly required.console-helpers/prophecy-phpunit) and minimal configuration (extend PHPUnit’s test case class or use traits).createMock() or Mockery for testing container-bound classes.Mockery or PHPUnit’s native mocks.RefreshDatabase or MigrateFresh, Prophecy mocks won’t interfere, but mixing mocking strategies (e.g., Prophecy + Mockery) could cause confusion.willReturnCallback(), argument matching), or are PHPUnit’s mocks sufficient?Mockery or coexist? If replacing, assess impact on existing tests.TestCase via trait extension.DatabaseTransactions, RefreshDatabase, etc.Mockery or PHPUnit mocks incrementally.use ConsoleHelpers\Prophecy\TestCase;
class UserServiceTest extends TestCase {
public function testSomething() {
$mock = $this->prophesize(UserRepository::class);
$mock->find(1)->willReturn(new User());
// ...
}
}
TestCase globally or use a trait in all test files.Mockery or PHPUnit mocks if Prophecy is adopted universally.phpunit.xml configuration.composer require --dev console-helpers/prophecy-phpunit
TestCase or create a base test class:
use ConsoleHelpers\Prophecy\TestCase as ProphecyTestCase;
abstract class BaseTestCase extends ProphecyTestCase { ... }
createMock() with $this->prophesize().verify()).CONTRIBUTING.md section on mocking standards.TestCase trait.Mockery (team familiarization needed).willReturnCallback()).phpunit --parallel) remains unaffected.setUp() hook to verify all prophecies.Mockery). Use composer why-not to check.Mockery conflicts).How can I help you explore Laravel packages today?