Permalink
Browse files

- Optionally call __autoload() for the class or interface that is to be

  mocked.
  • Loading branch information...
1 parent 46b2004 commit fc9820a3252621aeec03fb5932cdb85ffca8cfaf @sebastianbergmann committed Mar 26, 2007
Showing with 9 additions and 6 deletions.
  1. +5 −4 PHPUnit/Framework/MockObject/Mock.php
  2. +4 −2 PHPUnit/Framework/TestCase.php
@@ -93,7 +93,7 @@ class PHPUnit_Framework_MockObject_Mock
public $className;
public $methods;
- public function __construct($className, array $methods = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE)
+ public function __construct($className, array $methods = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = FALSE)
{
if ($mockClassName === '') {
do {
@@ -111,7 +111,7 @@ public function __construct($className, array $methods = array(), $mockClassName
);
}
- if (empty($methods) && (class_exists($className, FALSE) || interface_exists($className, FALSE))) {
+ if (empty($methods) && (class_exists($className, $callAutoload) || interface_exists($className, $callAutoload))) {
$methods = get_class_methods($className);
}
@@ -122,14 +122,15 @@ public function __construct($className, array $methods = array(), $mockClassName
$this->callOriginalClone = $callOriginalClone;
}
- public static function generate($className, array $methods = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE)
+ public static function generate($className, array $methods = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = FALSE)
{
$mock = new PHPUnit_Framework_MockObject_Mock(
$className,
$methods,
$mockClassName,
$callOriginalConstructor,
- $callOriginalClone
+ $callOriginalClone,
+ $callAutoload
);
$mock->generateClass();
@@ -389,11 +389,12 @@ protected function iniSet($varName, $newValue)
* @param string $mockClassName
* @param boolean $callOriginalConstructor
* @param boolean $callOriginalClone
+ * @param boolean $callAutoload
* @return object
* @access protected
* @since Method available since Release 3.0.0
*/
- protected function getMock($className, array $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE)
+ protected function getMock($className, array $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = FALSE)
{
if (!is_string($className) || !is_string($mockClassName)) {
throw new InvalidArgumentException;
@@ -404,7 +405,8 @@ protected function getMock($className, array $methods = array(), array $argument
$methods,
$mockClassName,
$callOriginalConstructor,
- $callOriginalClone
+ $callOriginalClone,
+ $callAutoload
);
$mockClass = new ReflectionClass($mock->mockClassName);

0 comments on commit fc9820a

Please sign in to comment.