intermediary commit of mock object madness
This commit is contained in:
parent
d5134b4ec8
commit
65fba62f5d
17
src/TUnit/framework/mock/InvocationTracker.php
Normal file
17
src/TUnit/framework/mock/InvocationTracker.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
class InvocationTracker {
|
||||
|
||||
protected $invocations;
|
||||
|
||||
public function __construct() {
|
||||
$this->invocations = array();
|
||||
}
|
||||
|
||||
public function registerInvocation(MockInvocation $invocation) {
|
||||
$this->invocations[] = $invocation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
23
src/TUnit/framework/mock/MockInvocation.php
Normal file
23
src/TUnit/framework/mock/MockInvocation.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
abstract class MockInvocation implements Verifiable {
|
||||
|
||||
protected $method;
|
||||
protected $args;
|
||||
|
||||
public function __construct($methodName, array $args) {
|
||||
$this->method = $methodName;
|
||||
$this->args = $args;
|
||||
}
|
||||
|
||||
public function getMethod() {
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function getArgs() {
|
||||
return $this->args;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -32,12 +32,12 @@
|
||||
);
|
||||
}
|
||||
|
||||
public static function registerInvocation($name, MockInvocation $invocation) {
|
||||
if (!isset(self::$registry[$name])) {
|
||||
public static function registerInvocation($className, $methodName, array $args) {
|
||||
if (!isset(self::$registry[$className])) {
|
||||
throw new LogicException('Unable to register invocation because the object does not exist in the registry');
|
||||
}
|
||||
|
||||
self::$registry[$name]->registerInvocation($invocation);
|
||||
self::$registry[$className]->registerInvocation(new MockInvocation($methodName, $args));
|
||||
}
|
||||
|
||||
public static function getTracker($name) {
|
||||
@ -50,7 +50,6 @@
|
||||
|
||||
public function addMethod($methodName, $callParent = false, $body = '') {
|
||||
$methodType = 'generic';
|
||||
|
||||
if ($this->referenceObject->hasMethod($methodName)) {
|
||||
$method = $this->referenceObject->getMethod($methodName);
|
||||
if (!$this->methodIsMockable($method))
|
||||
|
9
src/TUnit/framework/mock/Verifiable.php
Normal file
9
src/TUnit/framework/mock/Verifiable.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
interface Verifiable {
|
||||
|
||||
public function verify();
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Autoload manifest
|
||||
*
|
||||
* Autogenerated by manifester.php on 2009-06-13 19:56:43
|
||||
* Autogenerated by manifester.php on 2009-06-15 20:40:53
|
||||
*
|
||||
* @package TUnit
|
||||
* @version 0.1.0
|
||||
@ -30,7 +30,11 @@
|
||||
'IdenticalConstraint' => 'TUnit/framework/constraints/IdenticalConstraint.php',
|
||||
'IgnoredTest' => 'TUnit/framework/result/FailedTest.php',
|
||||
'IgnoredTestResult' => 'TUnit/framework/result/IgnoredTestResult.php',
|
||||
'InvocationTracker' => 'TUnit/framework/mock/InvocationTracker.php',
|
||||
'IssetConstraint' => 'TUnit/framework/constraints/SimpleConstraints.php',
|
||||
'MockInvocation' => 'TUnit/framework/mock/MockInvocation.php',
|
||||
'MockObject' => 'TUnit/framework/mock/MockObject.php',
|
||||
'MockObjectCreator' => 'TUnit/framework/mock/MockObject.php',
|
||||
'NotConstraint' => 'TUnit/framework/constraints/NotConstraint.php',
|
||||
'NullConstraint' => 'TUnit/framework/constraints/SimpleConstraints.php',
|
||||
'PassedTestResult' => 'TUnit/framework/result/PassedTestResult.php',
|
||||
@ -48,7 +52,8 @@
|
||||
'Testable' => 'TUnit/framework/test/Testable.php',
|
||||
'TrueConstraint' => 'TUnit/framework/constraints/SimpleConstraints.php',
|
||||
'Usage' => 'TUnit/util/cli.php',
|
||||
'Util' => 'TUnit/util/Util.php'
|
||||
'Util' => 'TUnit/util/Util.php',
|
||||
'Verifiable' => 'TUnit/framework/mock/Verifiable.php'
|
||||
);
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user