Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting started with "Enhance PHP"
    primarykey
    data
    text
    <p>I am looking to incorporate a testing framework into a project I am building and came across <a href="https://github.com/Enhance-PHP/Enhance-PHP/wiki" rel="nofollow">Enhance PHP</a> which I like but I am having some difficulty finding relevant information on-line since "enhance php" is such a commonly used phrase.</p> <p>Has anyone worked with this framework that might be able to point me toward some helpful guide? Have you worked with a unit test framework that you think is amazingly better?</p> <p>Thanks in advance.</p> <p>In response to Gotzofter, this is the class to be tested:</p> <pre><code>&lt;?php include_once('EnhanceTestFramework.php'); class ExampleClass { private $OtherClass; function __construct($mock = null) { if ($mock == null) $this-&gt;OtherClass = new OtherExampleClass(); else $this-&gt;OtherClass = $mock; } public function doSomething() { return $this-&gt;OtherClass-&gt;getSomething(1, 'Arg2'); } } class OtherExampleClass { public function getSomething() { return "Something"; } } class ExampleClassTests extends \Enhance\TestFixture { public function setUp() { } public function tearDown() { } public function verifyWithAMock() { $mock = \Enhance\MockFactory::createMock('OtherExampleClass'); $mock-&gt;addExpectation( \Enhance\Expect::method('getSomething') -&gt;with(1, 'Arg2') -&gt;returns('Something') -&gt;times(1) ); $target = new ExampleClass($mock); $result = $target-&gt;doSomething(); \Enhance\Assert::areIdentical("Something", $result); $mock-&gt;verifyExpectations(); } } \Enhance\Core::runTests(); </code></pre> <p>look at my constructor for ExampleClass.</p> <p>Because enhance-php's site example injects the $mock object by calling new ExampleClass($mock), I am forced to change my ExampleClass constructor to handle a $mock as an input parameter.</p> <p>Do I have to handle this for all classes that I want to subject to unit testing with the framework?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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