// Create a mock object $mockObject = Mockery::mock('MyClass'); // Set an expectation that the mock object's foo method will be called // with a string argument "bar" $mockObject->shouldReceive('foo') ->once() ->with(Mockery::mustBe('bar')); // Call the foo method with the expected argument $mockObject->foo('bar'); // Assert that the expectation was met Mockery::close();
// Define a function that takes an array argument function myFunction(array $myArray) { // Do something with the array } // Create a mock object to test the function $mockObject = Mockery::mock('MyClass'); // Set an expectation that the mock object's myFunction method will be called // with an array argument that contains 'foo' and 'bar' $mockObject->shouldReceive('myFunction') ->once() ->with(Mockery::mustBe(['foo', 'bar'])); // Call the function with an array containing 'foo' and 'bar' myFunction(['foo', 'bar']); // Assert that the expectation was met Mockery::close();In this example, the mustBe method is used to specify that the myFunction method should be called with an array argument that contains 'foo' and 'bar'. The function is then called with an array containing 'foo' and 'bar', satisfying the expectation and causing the test to pass. Package name: mockery/mockery