Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><strong>Note:</strong> <a href="https://twitter.com/s_bergmann/status/457816903881588736" rel="nofollow">the Test-Helper extension is superseded</a> by <a href="https://github.com/krakjoe/uopz" rel="nofollow">https://github.com/krakjoe/uopz</a></p> </blockquote> <p><a href="http://www.phpunit.de/manual/current/en/automating-tests.html" rel="nofollow">PHPUnit</a>'s Test Helper extension (PECL) allows <a href="http://sebastian-bergmann.de/archives/885-Stubbing-Hard-Coded-Dependencies.html" rel="nofollow">redefiniton/intercepting/stubbing/mocking of hardcoded dependencies</a> with your own implementations:</p> <pre><code>protected function setUp() { $this-&gt;getMock( 'Bar', /* name of class to mock */ array('doSomethingElse'), /* list of methods to mock */ array(), /* constructor arguments */ 'BarMock' /* name for mocked class */ ); set_new_overload(array($this, 'newCallback')); } </code></pre> <p>It also allows intercepting the exit statement and instance creation:</p> <ul> <li><a href="https://github.com/sebastianbergmann/php-test-helpers" rel="nofollow">https://github.com/sebastianbergmann/php-test-helpers</a></li> </ul> <p>For stubbing and mocking methods you simply use PHPUnit's regular mocking framework. See </p> <ul> <li><a href="http://www.phpunit.de/manual/current/en/test-doubles.html" rel="nofollow">http://www.phpunit.de/manual/current/en/test-doubles.html</a></li> </ul> <p>You can also use Mockery with PHPUnit:</p> <ul> <li><a href="https://github.com/padraic/mockery" rel="nofollow">https://github.com/padraic/mockery</a></li> </ul> <p>Another option would be to use <a href="http://antecedent.github.io/patchwork" rel="nofollow">http://antecedent.github.io/patchwork</a></p> <blockquote> <p>Patchwork is a PHP library that makes it possible to redefine user-defined functions and methods at runtime, loosely replicating the functionality <code>runkit_function_redefine</code> in pure PHP 5.3 code, which, among other things, enables you to replace static and private methods with test doubles.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload