@@ -36,39 +36,40 @@ function specify($specification, \Closure $callable = null, $params = [])
36
36
$ name = $ this ->getName ();
37
37
$ this ->setName ($ this ->getName ().' | ' .$ specification );
38
38
39
- // copy current object properties
40
39
$ properties = get_object_vars ($ this );
41
- foreach ($ properties as $ property => $ val ) {
42
- if ($ this ->specifyConfig ->propertyIgnored ($ property )) continue ;
43
- if ($ this ->specifyConfig ->classIgnored ($ val )) continue ;
44
-
45
- if ($ this ->specifyConfig ->propertyIsShallowCloned ($ property )) {
46
- if (is_object ($ val )) {
47
- $ this ->$ property = clone $ val ;
48
- }
49
- }
50
- if ($ this ->specifyConfig ->propertyIsDeeplyCloned ($ property )) {
51
- $ this ->$ property = $ this ->copier ->copy ($ val );
52
- }
53
- }
54
-
55
40
56
41
// prepare for execution
57
42
$ throws = $ this ->getSpecifyExpectedException ($ params );
58
43
$ examples = $ this ->getSpecifyExamples ($ params );
59
44
60
45
foreach ($ examples as $ example ) {
46
+ // copy current object properties
47
+ foreach ($ properties as $ property => $ val ) {
48
+ if ($ this ->specifyConfig ->propertyIgnored ($ property )) continue ;
49
+ if ($ this ->specifyConfig ->classIgnored ($ val )) continue ;
50
+
51
+ if ($ this ->specifyConfig ->propertyIsShallowCloned ($ property )) {
52
+ if (is_object ($ val )) {
53
+ $ this ->$ property = clone $ val ;
54
+ }
55
+ }
56
+ if ($ this ->specifyConfig ->propertyIsDeeplyCloned ($ property )) {
57
+ $ this ->$ property = $ this ->copier ->copy ($ val );
58
+ }
59
+ }
60
+
61
61
if ($ this ->beforeSpecify instanceof \Closure) $ this ->beforeSpecify ->__invoke ();
62
62
$ this ->specifyExecute ($ test , $ throws , $ example );
63
63
64
- // restore class properties
64
+ // restore object properties
65
65
foreach ($ properties as $ property => $ val ) {
66
66
if (in_array ($ property , $ this ->specifyConfig ->ignore )) continue ;
67
67
$ this ->$ property = $ val ;
68
68
}
69
69
if ($ this ->afterSpecify instanceof \Closure) $ this ->afterSpecify ->__invoke ();
70
70
}
71
71
72
+ // restore test name
72
73
$ this ->setName ($ name );
73
74
}
74
75
@@ -80,7 +81,7 @@ function specify($specification, \Closure $callable = null, $params = [])
80
81
private function getSpecifyExamples ($ params )
81
82
{
82
83
if (isset ($ params ['examples ' ])) {
83
- if (!is_array ($ params ['examples ' ])) throw new \RuntimeException ("Examples should be array " );
84
+ if (!is_array ($ params ['examples ' ])) throw new \RuntimeException ("Examples should be an array " );
84
85
return $ params ['examples ' ];
85
86
}
86
87
return [[]];
0 commit comments