protected function getOriginalCallback()
 {
     // no ability to call original constructor
     if ($this->functionName === '__construct') {
         return null;
     }
     if (!empty($this->object)) {
         // regular method call
         $savedName = WikiaMockProxy::SAVED_PREFIX . $this->functionName;
         //			$callback = array( $this->object, method_exists( $this->object, $savedName ) ? $savedName : $this->functionName );
         $callback = array($this->object, $savedName);
     } else {
         if (!empty($this->className)) {
             // static method call
             $savedName = WikiaMockProxy::SAVED_PREFIX . $this->functionName;
             //			$callback = array( $this->className, method_exists( $this->className, $savedName ) ? $savedName : $this->functionName );
             $callback = array($this->className, $savedName);
         } else {
             // global function call
             list($namespace, $baseName) = WikiaMockProxy::parseGlobalFunctionName($this->functionName);
             $savedName = $namespace . WikiaMockProxy::SAVED_PREFIX . $baseName;
             //			$callback = function_exists( $savedName ) ? $savedName : $this->functionName;
             $callback = $savedName;
         }
     }
     return $callback;
 }
 public static function overload($className)
 {
     /** @var $action WikiaMockProxyAction */
     if (self::$instance && ($action = self::$instance->retrieve(self::CLASS_CONSTRUCTOR, $className)) && $action->isActive()) {
         $type = $action->getEventType();
         $id = $action->getEventId();
         try {
             $value = self::$instance->execute($type, $id, array());
         } catch (Exception $e) {
             echo "WikiaMockProxy::overload: caught exception: {$e->getMessage()}\n";
             echo $e->getTraceAsString();
             echo "\n";
             $value = $className;
         }
         return $value;
     }
     return $className;
 }
 /**
  * Get a PHPUnit mock associated with global function
  *
  * @param $functionName string Global function name
  * @return PHPUnit_Framework_MockObject_MockObject Mock
  */
 protected function getGlobalFunctionMock($functionName)
 {
     list($namespace, $baseName) = WikiaMockProxy::parseGlobalFunctionName($functionName);
     $mock = $this->getMock('stdClass', array($baseName));
     $this->getMockProxy()->getGlobalFunction($functionName)->willCall(array($mock, $baseName));
     return $mock;
 }
 /**
  * Configure the action to always call a given callback whenever it's executed
  *
  * @param $callback callable Callback
  */
 public function willCall(callable $callback)
 {
     $this->action = self::ACTION_CALL;
     $this->data = $callback;
     $this->parent->notify($this);
 }