Exemplo n.º 1
0
 protected function checkPreEventCanChangeArguments($method, array $args, array $expectedArgs)
 {
     $internalMethod = 'internal' . ucfirst($method);
     $eventName = $method . '.pre';
     // init mock
     $this->_storage = $this->getMockForAbstractAdapter(array($internalMethod));
     $this->_storage->getEventManager()->attach($eventName, function ($event) use($expectedArgs) {
         $params = $event->getParams();
         foreach ($expectedArgs as $k => $v) {
             $params[$k] = $v;
         }
     });
     // set expected arguments of internal method call
     $tmp = $this->_storage->expects($this->once())->method($internalMethod);
     $equals = array();
     foreach ($expectedArgs as $v) {
         $equals[] = $this->equalTo($v);
     }
     call_user_func_array(array($tmp, 'with'), $equals);
     // run
     call_user_func_array(array($this->_storage, $method), $args);
 }