1. Go to this page and download the library: Download zalas/phpunit-doubles 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/ */
use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ObjectProphecy;
use Zalas\PHPUnit\Doubles\TestCase\ProphecyTestDoubles;
class DiscworldTest extends TestCase
{
use ProphecyTestDoubles;
/**
* @var Vimes|ObjectProphecy
*/
private $vimes;
/**
* @var Nobby|Fred|ObjectProphecy
*/
private $nobbyAndFred;
public function test_it_hires_new_recruits_for_nightwatch()
{
$discworld = new Discworld($this->vimes->reveal(), $this->nobbyAndFred->reveal());
$discworld->createNightWatch();
$this->vimes->recruit($this->nobbyAndFred)->shouldHaveBeenCalled();
}
}
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Zalas\PHPUnit\Doubles\TestCase\PHPUnitTestDoubles;
class DiscworldTest extends TestCase
{
use PHPUnitTestDoubles;
/**
* @var Vimes|MockObject
*/
private $vimes;
/**
* @var Nobby|MockObject
*/
private $nobbyAndFred;
public function test_it_hires_new_recruits_for_nightwatch()
{
$discworld = new Discworld($this->vimes, $this->nobby);
$this->vimes->expects($this->once())
->method('recruit')
->with($this->nobby);
$discworld->createNightWatch();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.