Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHPUnit Mocking Closures
// Closure can't be mocked because it's a final class.
// Mock another class instead and add __invoke to it.
$mockClosure = $this->getMockBuilder(\stdClass::class)
->willReturn('Hello, World!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment