$mock = $this->getMockBuilder(SomeClass::class) ->setMethods(['foo']) ->getMock(); $data = ['key' => 'value']; $mock->expects($this->once()) ->method('foo') ->willReturn($data); $this->assertEquals($data, $mock->foo());
$mock = $this->getMockBuilder(SomeOtherClass::class) ->setMethods(['bar']) ->getMock(); $data = ['key' => 'value']; $mock->expects($this->once()) ->method('bar') ->with($data); $mock->bar($data);In this example, we create a mock object for the `SomeOtherClass` class and set the method `bar` to expect an array `$data` as an argument. We then call `$mock->bar($data)` to test that the method is called with the correct argument. The `PHPUnit_Framework_MockObject_MockObject` class is part of the PHPUnit package library, which is a testing framework for PHP.