|
6 | 6 |
|
7 | 7 | trait Specify {
|
8 | 8 |
|
9 |
| - private $beforeSpecify; |
10 |
| - private $afterSpecify; |
| 9 | + private $beforeSpecify = array(); |
| 10 | + private $afterSpecify = array(); |
11 | 11 |
|
12 | 12 | /**
|
13 | 13 | * @var Specify\Config
|
@@ -46,15 +46,23 @@ function specify($specification, \Closure $callable = null, $params = [])
|
46 | 46 | // copy current object properties
|
47 | 47 | $this->specifyCloneProperties($properties);
|
48 | 48 |
|
49 |
| - if ($this->beforeSpecify instanceof \Closure) $this->beforeSpecify->__invoke(); |
| 49 | + if (!empty($this->beforeSpecify) && is_array($this->beforeSpecify)) { |
| 50 | + foreach ($this->beforeSpecify as $closure) { |
| 51 | + if ($closure instanceof \Closure) $closure->__invoke(); |
| 52 | + } |
| 53 | + } |
50 | 54 | $this->specifyExecute($test, $throws, $example);
|
51 | 55 |
|
52 | 56 | // restore object properties
|
53 | 57 | foreach ($properties as $property => $val) {
|
54 | 58 | if ($this->specifyConfig->propertyIgnored($property)) continue;
|
55 | 59 | $this->$property = $val;
|
56 | 60 | }
|
57 |
| - if ($this->afterSpecify instanceof \Closure) $this->afterSpecify->__invoke(); |
| 61 | + if (!empty($this->afterSpecify) && is_array($this->afterSpecify)) { |
| 62 | + foreach ($this->afterSpecify as $closure) { |
| 63 | + if ($closure instanceof \Closure) $closure->__invoke(); |
| 64 | + } |
| 65 | + } |
58 | 66 | }
|
59 | 67 |
|
60 | 68 | // restore test name
|
@@ -126,17 +134,17 @@ public function specifyConfig()
|
126 | 134 |
|
127 | 135 | function beforeSpecify(\Closure $callable = null)
|
128 | 136 | {
|
129 |
| - $this->beforeSpecify = $callable->bindTo($this); |
| 137 | + $this->beforeSpecify[] = $callable->bindTo($this); |
130 | 138 | }
|
131 | 139 |
|
132 | 140 | function afterSpecify(\Closure $callable = null)
|
133 | 141 | {
|
134 |
| - $this->afterSpecify = $callable->bindTo($this); |
| 142 | + $this->afterSpecify[] = $callable->bindTo($this); |
135 | 143 | }
|
136 | 144 |
|
137 | 145 | function cleanSpecify()
|
138 | 146 | {
|
139 |
| - $this->beforeSpecify = $this->afterSpecify = null; |
| 147 | + $this->beforeSpecify = $this->afterSpecify = array(); |
140 | 148 | }
|
141 | 149 |
|
142 | 150 | /**
|
|
0 commit comments