$mock = $this->getMockBuilder('ClassName') ->getMock();
$mock->expects($this->any()) ->method('foo') ->willReturn('bar'); $this->assertEquals('bar', $mock->foo());In this example, the mock object is instructed to return 'bar' when the method 'foo' is called. The code then asserts that the returned value is indeed 'bar'. PHPUnit_Framework_MockObject_MockObject is part of the PHPUnit library, which is a widely used testing framework for PHP.