Download the PHP package qubit05/phpunit-mockfunction without Composer
On this page you can find all versions of the php package qubit05/phpunit-mockfunction. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package phpunit-mockfunction
PHPUnit Mock Function
PHPUnit extension to Mock PHP internal functions using Runkit.
Requirements
*This is an optional requirement. Runkit doesn't currently support the override of internal functions (exit, die etc).
Installation
Using composer, add the following to the composer.json file:
{
"require": {
"qubit05/phpunit-mockfunction": "1.*"
}
}
Example
ExampleClass.php
<?php
class ExampleClass
{
public function doExample()
{
return date();
}
}
ExampleClassTest.php
<?php
class ExampleClassTest extends \PHPUnit_Framework_TestCase
{
public function testExample()
{
$param = 'Y-m-d H:i:s';
$value = 'non date value';
$mockFunction = new PHPUnit_Extensions_MockFunction('date', $this);
$mockFunction->expects($this->once())
->with($this->equalTo($param))
->will($this->returnValue($value));
$exampleClass = new ExampleClass();
$this->assertEquals($value, $exampleClass->doExample($param));
}
}
Acknowledgement
When this class was created, some inspiration was taken from tcz/phpunit-mockfunction. The two classes are similar but not the same.
All versions of phpunit-mockfunction with dependencies
PHP Build Version
Package Version
Requires
ext-runkit Version
*
The package qubit05/phpunit-mockfunction contains the following files
Loading the files please wait ....