Closed
Description
The easiest way to create mock objects outside of a test case is through PHPUnit\Framework\MockObject\Generator::getMock()
. This method does not return intersection types, like PHPUnit\Framework\MockObject\MockBuilder::getMock()
and PHPUnit\Framework\TestCase::createMock()
does.
Example:
interface A {}
function foo(): A
{
$generator = new PHPUnit\Framework\MockObject\Generator();
return $generator->getMock(A::class);
}
------ -------------------------------------------------------------------------
Line test.php
------ -------------------------------------------------------------------------
5 Function foo() should return A but returns
PHPUnit\Framework\MockObject\MockObject.
------ -------------------------------------------------------------------------
Metadata
Metadata
Assignees
Labels
No labels