2017 © Pedro Peláez
 

library phpunit-mockfunction

PHPUnit extension to Mock PHP internal functions using Runkit.

image

qubit05/phpunit-mockfunction

PHPUnit extension to Mock PHP internal functions using Runkit.

  • Monday, April 22, 2013
  • by qubit05
  • Repository
  • 1 Watchers
  • 1 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 24 % Grown

The README.md

PHPUnit Mock Function

PHPUnit extension to Mock PHP internal functions using Runkit., (*1)

Requirements

*This is an optional requirement. Runkit doesn't currently support the override of internal functions (exit, die etc)., (*2)

Installation

Using composer, add the following to the composer.json file:, (*3)

{
   "require": {
       "qubit05/phpunit-mockfunction": "1.*"
   }
}

Example

ExampleClass.php, (*4)

<?php
class ExampleClass
{
    public function doExample()
    {
        return date();
    }
}

ExampleClassTest.php, (*5)

<?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., (*6)

The Versions

22/04 2013

dev-master

9999999-dev

PHPUnit extension to Mock PHP internal functions using Runkit.

  Sources   Download

MIT

The Requires

  • ext-runkit *

 

by James Dempster
by Luke Richards

mock function phpunit testing runkit

22/04 2013

1.0.1

1.0.1.0

PHPUnit extension to Mock PHP internal functions using Runkit.

  Sources   Download

MIT

The Requires

  • ext-runkit *

 

by James Dempster
by Luke Richards

mock function phpunit testing runkit

22/04 2013

1.0.0

1.0.0.0

PHPUnit extension to Mock PHP internal functions using Runkit.

  Sources   Download

by James Dempster
by Luke Richards

mock function phpunit testing