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;
 }
示例#2
0
 /**
  * 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;
 }