We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you replace $that by $this in the closure of the following, the test will fail.
At runtime, the type of $this is \Prophecy\Prophecy\ObjectProphecy and the type of $that is MyTest.
<?php declare(strict_types=1); // Requires phpunit/phpunit, phpspec/prophecy and phpspec/prophecy-phpunit namespace foo; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; class MyTarget { public function run(string $input): string { return $input; } } class MyTest extends TestCase { use ProphecyTrait; private array $stuff = ['foo' => 'bar']; public function testMyMock(): void { $prophecy = $this->prophesize(MyTarget::class); $that = $this; $prophecy->run(Argument::type('string'))->will( function (array $args) use ($that): string { return $that->stuff[$args[0]] ?? $args[0]; } ); $target = $prophecy->reveal(); $result = $target->run('foo'); self::assertSame('bar', $result); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If you replace $that by $this in the closure of the following, the test will fail.
At runtime, the type of $this is \Prophecy\Prophecy\ObjectProphecy and the type of $that is MyTest.
The text was updated successfully, but these errors were encountered: