Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Mocking fluent interfaces #51

Closed
wants to merge 1 commit into from

2 participants

@kriswallsmith

Along with a coming pull request to the mock objects repo, this will make it easy to mock a fluent interface.

$mock
  ->expects($this->any())
  ->method('setName')
  ->will($this->returnSelf());
@kriswallsmith

Thanks!

@sebastianbergmann

Pulled, thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +13 −0 PHPUnit/Framework/TestCase.php
View
13 PHPUnit/Framework/TestCase.php
@@ -1305,6 +1305,19 @@ public static function returnCallback($callback)
}
/**
+ * Returns the current object.
+ *
+ * This method is useful when mocking a fluent interface.
+ *
+ * @return PHPUnit_Framework_MockObject_Stub_ReturnSelf
+ * @since Method available since Release 3.5.2
+ */
+ public static function returnSelf()
+ {
+ return new PHPUnit_Framework_MockObject_Stub_ReturnSelf();
+ }
+
+ /**
*
*
* @param Exception $exception
Something went wrong with that request. Please try again.