Skip to content

Commit

Permalink
revered back stacked stub support :(
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Jun 23, 2016
1 parent e15b716 commit 0d6b6b1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Expand Up @@ -5,7 +5,6 @@
* **Updated to Go AOP Framework 2.0**
* PHP7 (with typehints) supported
* Minimal PHP version is PHP 5.6
* [Stacked functions support](https://github.com/Codeception/AspectMock/blob/master/docs/Test.md#Stacked-Calls-Support) for mocked methods. You can register a chain of methods as a stub, and to control their execution. By @torreytsui See https://github.com/Codeception/AspectMock/pull/91

#### 1.0.0

Expand Down
35 changes: 0 additions & 35 deletions src/AspectMock/Test.php
Expand Up @@ -84,41 +84,6 @@ class Test {
* ?>
* ```
*
* #### Stacked Calls Support
*
* Since 2.0 you can register multiple functions inside stib which will be executed in chain.
* You can pass control to next function in a stack by returning `__AM_CONTINUE__` constant:
*
* ```php
* class User {
* public function getGroup() { return 'guest'; }
* }
* $user = new User;
* ```
*
* So, it is for conflicted stubs, when a test double (e.g., getGroup) has been redefined.
*
* ```php
* $stub1 = function () {
* return 'user';
* };
* $stub2 = function ($supersede = false) {
* return $supersede ? 'root' : __AM_CONTINUE__;
* };
* test::double('User', ['getGroup' => $stub1]);
* test::double('User', ['getGroup' => $stub2]);
*
* ```
*
* The idea basically is to allow a chain of responsibility passing through every conflicted stubs until a result returns. Use stack structure so that the latest defined stub will gain highest priority.
* So, the result will look like this:
*
* ```php
* $user->getGroup(true) // => root (handled by $stub2)
* $user->getGroup() // => user (handled by $stub2 and then $stub1)
* ```
* The $user->getGroup() // => user first handled by $stub2 and it gives up control by returning __AM_CONTINUE__, $stub1 then take place and return "user". If $stub1 return __AM_CONTINUE__, it will return control to the real object, as every stub has returned __AM_CONTINUE__.
*
* @api
* @param string|object $classOrObject
* @param array $params [ 'methodName' => 'returnValue' ]
Expand Down

0 comments on commit 0d6b6b1

Please sign in to comment.