Skip to content

Commit 0d6b6b1

Browse files
committed
revered back stacked stub support :(
1 parent e15b716 commit 0d6b6b1

File tree

2 files changed

+0
-36
lines changed

2 files changed

+0
-36
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* **Updated to Go AOP Framework 2.0**
66
* PHP7 (with typehints) supported
77
* Minimal PHP version is PHP 5.6
8-
* [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
98

109
#### 1.0.0
1110

src/AspectMock/Test.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,41 +84,6 @@ class Test {
8484
* ?>
8585
* ```
8686
*
87-
* #### Stacked Calls Support
88-
*
89-
* Since 2.0 you can register multiple functions inside stib which will be executed in chain.
90-
* You can pass control to next function in a stack by returning `__AM_CONTINUE__` constant:
91-
*
92-
* ```php
93-
* class User {
94-
* public function getGroup() { return 'guest'; }
95-
* }
96-
* $user = new User;
97-
* ```
98-
*
99-
* So, it is for conflicted stubs, when a test double (e.g., getGroup) has been redefined.
100-
*
101-
* ```php
102-
* $stub1 = function () {
103-
* return 'user';
104-
* };
105-
* $stub2 = function ($supersede = false) {
106-
* return $supersede ? 'root' : __AM_CONTINUE__;
107-
* };
108-
* test::double('User', ['getGroup' => $stub1]);
109-
* test::double('User', ['getGroup' => $stub2]);
110-
*
111-
* ```
112-
*
113-
* 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.
114-
* So, the result will look like this:
115-
*
116-
* ```php
117-
* $user->getGroup(true) // => root (handled by $stub2)
118-
* $user->getGroup() // => user (handled by $stub2 and then $stub1)
119-
* ```
120-
* 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__.
121-
*
12287
* @api
12388
* @param string|object $classOrObject
12489
* @param array $params [ 'methodName' => 'returnValue' ]

0 commit comments

Comments
 (0)