reset registry between each test method

This commit is contained in:
tmont 2009-06-17 07:26:31 +00:00
parent a901f154c2
commit 7a8481283f
2 changed files with 5 additions and 2 deletions

View File

@ -38,7 +38,7 @@
throw new LogicException('Unable to register invocation because the object does not exist in the registry');
}
$count = self::getInvocationCount($className, $methodName);
$count = self::getInvocationCount($className, $methodName) + 1;
$expectation = self::$trackers[$className]->registerInvocation(new MockInvocation($className, $methodName, $args, $count));
return $expectation;
}
@ -52,7 +52,7 @@
}
private static function getInvocationCount($className, $methodName) {
$count = 1;
$count = 0;
foreach (self::$trackers[$className]->getInvocations() as $invocation) {
if ($invocation->getMethod() === $methodName) {
$count++;

View File

@ -15,6 +15,9 @@
}
public function run(array $listeners) {
//reset mock object registry
MockRegistry::reset();
foreach ($listeners as $listener) {
$listener->beforeTestMethod($this);
}