$mock = $this->getMockBuilder('Calculator') ->getMock(); $mock->expects($this->once()) ->method('calculate') ->with($this->equalTo(2), $this->equalTo(3)) ->will($this->returnValue(5));
$mock = $this->getMockBuilder('BankAccount') ->getMock(); $mock->expects($this->once()) ->method('withdraw') ->with($this->equalTo(50.00)) ->will($this->returnValue(TRUE));In this example, we create a mock object for a "BankAccount" class using the getMockBuilder method. We then use expects to set up an expectation that the "withdraw" method will be called once with an argument of 50.00. We specify that the method should return TRUE. Overall, the PHPUnit_Framework_MockObject_MockObject class and its related methods provide a powerful set of tools for creating mock objects and setting up expectations for testing.