@@ -125,61 +125,6 @@ protected function buildAccessibleProxy($className)
125125 return $ accessibleClassName ;
126126 }
127127
128- /**
129- * Helper function to call protected or private methods
130- *
131- * @param object $object The object to be invoked
132- * @param string $name the name of the method to call
133- * @param mixed $arguments
134- * @return mixed
135- */
136- protected function callInaccessibleMethod ($ object , $ name , ...$ arguments )
137- {
138- $ reflectionObject = new \ReflectionObject ($ object );
139- $ reflectionMethod = $ reflectionObject ->getMethod ($ name );
140- $ reflectionMethod ->setAccessible (true );
141- return $ reflectionMethod ->invokeArgs ($ object , $ arguments );
142- }
143-
144- /**
145- * Injects $dependency into property $name of $target
146- *
147- * This is a convenience method for setting a protected or private property in
148- * a test subject for the purpose of injecting a dependency.
149- *
150- * @param object $target The instance which needs the dependency
151- * @param string $name Name of the property to be injected
152- * @param mixed $dependency The dependency to inject – usually an object but can also be any other type
153- * @return void
154- * @throws \RuntimeException
155- * @throws \InvalidArgumentException
156- */
157- protected function inject ($ target , $ name , $ dependency )
158- {
159- if (!is_object ($ target )) {
160- throw new \InvalidArgumentException ('Wrong type for argument $target, must be object. ' , 1476107338 );
161- }
162-
163- $ objectReflection = new \ReflectionObject ($ target );
164- $ methodNamePart = strtoupper ($ name [0 ]) . substr ($ name , 1 );
165- if ($ objectReflection ->hasMethod ('set ' . $ methodNamePart )) {
166- $ methodName = 'set ' . $ methodNamePart ;
167- $ target ->$ methodName ($ dependency );
168- } elseif ($ objectReflection ->hasMethod ('inject ' . $ methodNamePart )) {
169- $ methodName = 'inject ' . $ methodNamePart ;
170- $ target ->$ methodName ($ dependency );
171- } elseif ($ objectReflection ->hasProperty ($ name )) {
172- $ property = $ objectReflection ->getProperty ($ name );
173- $ property ->setAccessible (true );
174- $ property ->setValue ($ target , $ dependency );
175- } else {
176- throw new \RuntimeException (
177- 'Could not inject ' . $ name . ' into object of type ' . get_class ($ target ),
178- 1476107339
179- );
180- }
181- }
182-
183128 /**
184129 * Create and return a unique id optionally prepended by a given string
185130 *
0 commit comments