@@ -44,19 +44,7 @@ function specify($specification, \Closure $callable = null, $params = [])
4444
4545 foreach ($ examples as $ example ) {
4646 // 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- }
47+ $ this ->specifyCloneProperties ($ properties );
6048
6149 if ($ this ->beforeSpecify instanceof \Closure) $ this ->beforeSpecify ->__invoke ();
6250 $ this ->specifyExecute ($ test , $ throws , $ example );
@@ -125,7 +113,7 @@ private function specifyExecute($test, $throws = false, $examples = array())
125113 $ this ->assertTrue (true , 'exception handled ' );
126114 } else {
127115 $ f = new \PHPUnit_Framework_AssertionFailedError ("exception ' $ throws' was not thrown as expected " );
128- $ result ->addFailure (clone ($ this ), $ f , $ result ->time ());
116+ $ result ->addFailure (clone ($ this ), $ f , $ result ->time ());
129117 }
130118 }
131119 }
@@ -148,7 +136,32 @@ function afterSpecify(\Closure $callable = null)
148136 function cleanSpecify ()
149137 {
150138 $ this ->beforeSpecify = $ this ->afterSpecify = null ;
151- }
139+ }
152140
141+ /**
142+ * @param $properties
143+ * @return array
144+ */
145+ private function specifyCloneProperties ($ properties )
146+ {
147+ foreach ($ properties as $ property => $ val ) {
148+ if ($ this ->specifyConfig ->propertyIgnored ($ property )) {
149+ continue ;
150+ }
151+ if ($ this ->specifyConfig ->classIgnored ($ val )) {
152+ continue ;
153+ }
153154
155+ if ($ this ->specifyConfig ->propertyIsShallowCloned ($ property )) {
156+ if (is_object ($ val )) {
157+ $ this ->$ property = clone $ val ;
158+ } else {
159+ $ this ->$ property = $ val ;
160+ }
161+ }
162+ if ($ this ->specifyConfig ->propertyIsDeeplyCloned ($ property )) {
163+ $ this ->$ property = $ this ->copier ->copy ($ val );
164+ }
165+ }
166+ }
154167}
0 commit comments