$prophecy = $this->prophesize(SomeClass::class); $prophecy->someMethod(42)->shouldBeCalled(); $object = $prophecy->reveal(); $object->someMethod(42);
$prophecy = $this->prophesize(SomeClass::class); $prophecy->someMethod(Argument::type('string'))->shouldBeCalled(); $object = $prophecy->reveal(); $object->someMethod('hello');
$constraint = function ($value) { return $value > 3; }; $prophecy = $this->prophesize(SomeClass::class); $prophecy->someMethod(Argument::that($constraint))->shouldBeCalled(); $object = $prophecy->reveal(); $object->someMethod(4);This test will pass if the `someMethod` method of `SomeClass` is called with an argument that satisfies the `$constraint`. These examples demonstrate the flexibility and power of the Argument class in PHP Prophecy. By combining it with other features of the library, such as object prophecies and method stubbing, you can create expressive and effective tests for your PHP code.