Integrating Prophecy in PHPUnit test cases
Prophecy PhpUnit integrates the Prophecy mocking library with PHPUnit to provide an easier mocking in your testsuite.
Prophecy PhpUnit requires PHP 7.3 or greater. Prophecy PhpUnit requires PHPUnit 9.1 or greater. Older versions of PHPUnit are providing the Prophecy integration themselves.
composer require --dev phpspec/prophecy-phpunitYou can read more about Composer on its official webpage.
The trait ProphecyTrait provides a method prophesize($classOrInterface = null) to use Prophecy.
For the usage of the Prophecy doubles, please refer to the Prophecy documentation.
Below is a usage example:
prophesize(Hasher::class);
$user = new User($hasher->reveal());
$hasher->generateHash($user, 'qwerty')->willReturn('hashed_pass');
$user->setPassword('qwerty');
$this->assertEquals('hashed_pass', $user->getPassword());
}
}No open issues yet, or sync has not completed.