My function, prepare (), has a definition:
preparing a private function (& $ data, $ conditions = null, $ ConditionsRequired = false)
When I test it
public function testNoExceptionIsRaisedForValidPrepareWithConditionsAndConditionsRequiredArguments() { $method = new ReflectionMethod('DB_Service', 'prepare'); $method->setAccessible(TRUE); $dbs = new DB_Service(new Config(), array('admin', 'etl')); $data = array('message' => '', 'sql' => array('full_query' => "")); $method->invoke($dbs, $data, array('conditionKey' => 'conditionValue'), TRUE); }
picks up (and interrupts my test)
ReflectionException: a call to the DB_Service :: prepare () method failed
However this
public function testNoExceptionIsRaisedForValidPrepareWithConditionsAndConditionsRequiredArguments() { $method = new ReflectionMethod('DB_Service', 'prepare'); $method->setAccessible(TRUE); $dbs = new DB_Service(new Config(), array('admin', 'etl'));
works fine and the test was successful.
Why does declaring a variable and then passing does not work, but just creating it in a method call works? I think this has something to do with how invoke () works, but I can't figure that out.
source share