PHP code example of eltrino / phpunit-mockannotations
1. Go to this page and download the library: Download eltrino/phpunit-mockannotations 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/ */
eltrino / phpunit-mockannotations example snippets
namespace Lib\Tests;
use Lib\Generator;
use Lib\ConfigInterface;
use Eltrino\PHPUnit\MockAnnotations\MockAnnotations;
use PHPUnit\Framework\TestCase;
class GeneratorTest extends TestCase
{
/**
* @Mock Lib\ConfigInterface
*/
private $config;
protected function setUp()
{
MockAnnotations::init($this);
}
public function testProcess()
{
$config
->expects($this->once())
->method('getOption')
->with($this->equalTo('title'))
->will($this->returnValue('option_value'));
$generator = new Generator($this->config);
$result = $generator->process();
$this->assertIsNotNull($result);
}
}