Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added Factory Method for MockSpecification

  • Loading branch information...
1 parent 7835ab2 commit c7d62874ff9c1ed6f520e98cab2568c9bb933ec6 @giorgiosironi committed
Showing with 10 additions and 1 deletion.
  1. +10 −1 PHPUnit/Framework/TestCase.php
11 PHPUnit/Framework/TestCase.php
@@ -1044,7 +1044,7 @@ protected function setLocale()
* @throws InvalidArgumentException
* @since Method available since Release 3.0.0
- protected function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE)
+ public function getMock($originalClassName, $methods = array(), array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE)
$mockObject = PHPUnit_Framework_MockObject_Generator::getMock(
@@ -1062,6 +1062,15 @@ protected function getMock($originalClassName, $methods = array(), array $argume
+ * @param string
+ * @return PHPUnit_Framework_MockSpecification
+ */
+ protected function getMockSpecification($className)

Hi Giorgio,
Just read your blog post, and I like the idea of mock builder, why not call it PHPUnit_Framework_MockBuilder instead, since that is what it is?
Then the method name for getting it would be renamed to getMockBuilder.

@giorgiosironi Owner

It is probably the right name since it refers to the Builder pattern. However the code for mocks is all namespace in PHPUnit_Framework_Mock, so it would be PHPUnit_Framework_Mock_MockBuilder.

Good point, or even PHPUnit_Framework_Mock_Builder, maybe?

@giorgiosironi Owner

I followed the existing class names (PHPUnit_Framework_MockObject_MockObject) and named it PHPUnit_Framework_MockObject_MockBuilder. However no one sees the class name from the client code, it is simply $this->getMockBuilder() as you suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ {
+ return new PHPUnit_Framework_MockSpecification($this, $className);
+ }
+ /**
* Mocks the specified class and returns the name of the mocked class.
* @param string $originalClassName

0 comments on commit c7d6287

Please sign in to comment.
Something went wrong with that request. Please try again.