I am just starting a new job and they would like me to start creating test
cases to incorporate into the project development. I would like to use Enhance
PHP [1] as it does not require an 'installation' and seems to be popular on
stackoverflow. But, since it's so new, I'm having trouble finding good guides
online with sample usages. I followed the all of the guides but am having a
hard time getting the "Mock" stuff working correctly. It could be that I just
don't really know what's going on as this is all fairly new to me...
Here is what I have:
<?php
include_once('EnhanceTestFramework.php');
class ExampleClass
{
private $OtherClass;
function __construct()
{
$this->OtherClass = new OtherExampleClass;
}
public function doSomething()
{
return $this->OtherClass->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->addExpectation(
\Enhance\Expect::method('getSomething')
->with(1, 'Arg2')
->returns('Something')
->times(1)
);
$target = new ExampleClass($mock);
$result = $target->doSomething();
\Enhance\Assert::areIdentical("Something", $result);
$mock->verifyExpectations();
}
}
\Enhance\Core::runTests();
?>
which, when run, gives me this result:
verifyWithAMock - Failed - Expectation failed
OtherExampleClass->getSomething(1, Arg2) Expected #1 Called #0
What is it that I am missing?
Thanks for the help,
Aaron
1 - http://www.enhance-php.com/
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net