PHP code example of console-helpers / prophecy-phpunit
1. Go to this page and download the library: Download console-helpers/prophecy-phpunit library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
console-helpers / prophecy-phpunit example snippets
namespace App;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use App\Security\Hasher;
use App\Entity\User;
class UserTest extends TestCase
{
use ProphecyTrait;
public function testPasswordHashing()
{
$hasher = $this->prophesize(Hasher::class);
$user = new User($hasher->reveal());
$hasher->generateHash($user, 'qwerty')->willReturn('hashed_pass');
$user->setPassword('qwerty');
$this->assertEquals('hashed_pass', $user->getPassword());
}
}