@param MockObject $mock
@param MethodStub $stub

@throws \PHPUnit\Framework\MockObject\RuntimeException
436636
protected function doDecorateWithMethod($mock, MethodStub $stub): void
    {
        $methodName = $stub->getName();
        $methodValue = $stub->getValue();

        $partial = $mock->expects(new AnyInvokedCount())->method($methodName);
        $methodValue instanceof \Throwable
            ? $partial->willThrowException($methodValue)
            : $partial->willReturn($methodValue);
    }
118609
final protected function checkMockType($mock)
    {
        $this->verifyMockType();

        if (!is_a($mock, $this->mockType)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Mock object must be an instance of "%s", "%s" given',
                    $this->mockType,
                    \gettype($mock)
                )
            );
        }
    }
456027
function mock($pattern,
		array $args=NULL,array $headers=NULL,$body=NULL) {
		if (!$args)
			$args=[];
		$types=['sync','ajax','cli'];
		preg_match('/([\|\w]+)\h+(?:@(\w+)(?:(\(.+?)\))*|([^\h]+))'.
			'(?:\h+\[('.implode('|',$types).')\])?/',$pattern,$parts);
		$verb=strtoupper($parts[1]);
		if ($parts[2]) {
			if (empty($this->hive['ALIASES'][$parts[2]]))
				user_error(sprintf(self::E_Named,$parts[2]),E_USER_ERROR);
			$parts[4]=$this->hive['ALIASES'][$parts[2]];
			$parts[4]=$this->build($parts[4],
				isset($parts[3])?$this->parse($parts[3]):[]);
		}
		if (empty($parts[4]))
			user_error(sprintf(self::E_Pattern,$pattern),E_USER_ERROR);
		$url=parse_url($parts[4]);
		parse_str(@$url['query'],$GLOBALS['_GET']);
		if (preg_match('/GET|HEAD/',$verb))
			$GLOBALS['_GET']=array_merge($GLOBALS['_GET'],$args);
		$GLOBALS['_POST']=$verb=='POST'?$args:[];
		$GLOBALS['_REQUEST']=array_merge($GLOBALS['_GET'],$GLOBALS['_POST']);
		foreach ($headers?:[] as $key=>$val)
			$_SERVER['HTTP_'.strtr(strtoupper($key),'-','_')]=$val;
		$this->hive['VERB']=$verb;
		$this->hive['PATH']=$url['path'];
		$this->hive['URI']=$this->hive['BASE'].$url['path'];
		if ($GLOBALS['_GET'])
			$this->hive['URI'].='?'.http_build_query($GLOBALS['_GET']);
		$this->hive['BODY']='';
		if (!preg_match('/GET|HEAD/',$verb))
			$this->hive['BODY']=$body?:http_build_query($args);
		$this->hive['AJAX']=isset($parts[5]) &&
			preg_match('/ajax/i',$parts[5]);
		$this->hive['CLI']=isset($parts[5]) &&
			preg_match('/cli/i',$parts[5]);
		return $this->run();
	}
475406
protected function beforeApplyOptions($stub)
	{
		$refModel = new ReflectionClass($this->model);
		$refIntermeidateModel = new ReflectionClass($this->defaultOptions['intermediate_model']);
		
		$model = $refIntermeidateModel->getShortName();
		
		if ($refModel->getNamespaceName() !== $refIntermeidateModel->getNamespaceName()) {
			$model = '\\'.$refIntermeidateModel->getName();
		}

		return str_replace('DummyIntermediateModel', $model, $stub);
	}
768183
protected function replaceClass($stub, $name)
    {
        $stub = parent::replaceClass($stub, $name);

        return str_replace('$dummy', '$' . strtolower($this->getNameInput()), $stub);
    }
346971
public function invoke(\PHPUnit_Framework_MockObject_Invocation $invocation)
    {
        $exception      = null;
        $hasReturnValue = false;

        $returnValue = next::caller();

        foreach ($this->matchers as $match) {
            try {
                if ($match->matches($invocation)) {
                    $value = $match->invoked($invocation);

                    if (!$hasReturnValue) {
                        $returnValue    = $value;
                        $hasReturnValue = true;
                    }
                }
            } catch (\Exception $e) {
                $exception = $e;
            }
        }

        if ($exception !== null) {
            throw $exception;
        }

        return $returnValue;
    }
263557
private function getMockedMethod(string $mockName): string
    {
        foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $trace) {
            if ($mockName === $trace['class']) {
                return $trace['function'];
            }
        }
    }
597565
protected function populate($name, $eventObjectTable, $actionTiming, $event, $stub)
    {
        $stub = str_replace('DummyClass', $this->getClassName($name), $stub);
        $stub = str_replace('DummyName', $name, $stub);
        $stub = str_replace('DummyEventObjectTable', $eventObjectTable, $stub);
        $stub = str_replace('DummyActionTiming', $actionTiming, $stub);
        $stub = str_replace('DummyEvent', $event, $stub);

        return $stub;
    }
943434
public function evaluateAnnotation(
        Request $request,
        Annotation $annotation,
        ReflectionMethod $method
    ) {
        /**
         * Annotation is only loaded if is typeof AnnotationEntity.
         */
        if ($annotation instanceof LoadEntity) {

            /**
             * Creating new instance of desired entity.
             */
            $entityNamespace = $this
                ->entityProvider
                ->evaluateEntityNamespace($annotation->getNamespace());

            /**
             * Tries to get a mapped instance of this entity. If not found,
             * return null.
             */
            $entity = $this->evaluateMapping($annotation, $entityNamespace);

            if (!$entity instanceof $entityNamespace) {
                $entity = $this
                    ->entityProvider
                    ->create($annotation);
            }

            /**
             * Persists entity if defined.
             */
            $this->resolvePersist($annotation, $entity);

            /**
             * If is decided this entity has to be persisted into manager.
             */
            $this->evaluateSetters(
                $request->attributes,
                $entity,
                $annotation->getSetters()
            );

            /**
             * Get the parameter name. If not defined, is set as defined in
             * parameters.
             */
            $parameterName = $annotation->getName()
                ?: $this->defaultName;

            $request->attributes->set(
                $parameterName,
                $entity
            );
        }
    }
223385
protected function replaceModelClass(&$stub, $name)
    {
        $names = explode('\\', $name);
        $class = array_pop($names);

        $stub = str_replace('DummyModelClass', $class, $stub);

        return $this;
    }
708930
protected function addExpectedMock($key, \PHPUnit_Framework_MockObject_MockObject $mock)
    {
        if (isset($this->expectedMocks[$key]) || isset($this->expectedMocksCollections[$key]) || isset($this->expectedValues[$key])) {
            throw new \LogicException(
                sprintf('The expected mock "%s" you are trying to add is already set as mock, mock collection or value.', $key)
            );
        }

        $this->expectedMocks[$key] = $mock;

        return $this;
    }
773742
protected function replaceClassName(&$stub)
    {
        $className = ucwords(camel_case($this->argument('name')));

        $stub = str_replace('{{class}}', $className, $stub);

        return $this;
    }
367102
protected function replaceTimestamp(&$stub, $timestamps)
    {
        $useTimestamps = $timestamps ? '' : "public \$timestamps = false;\n";

        $stub = str_replace('DummyTimestamp', $useTimestamps, $stub);

        return $this;
    }
153414
private String set(ChaincodeStub stub, List<String> args) {
        if (args.size() != 2) {
            throw new RuntimeException("Incorrect arguments. Expecting a key and a value");
        }
        stub.putStringState(args.get(0), args.get(1));
        return args.get(1);
    }
911051
private void init(StubAmp stub)
  {
    //BuildMessageAmp buildMessage = new BuildMessageAmp(this);

    OnInitMessage onInitMsg = new OnInitMessage(this);
      
    _queue.offer(onInitMsg);
    _queue.wake();
  }
1180999
private function addChainedMethodResponse($chainedMethodsBefore, $currentMethod, $action, $lastValue, $mockClassInstanceId)
    {
        $response = [];
        $rResponse = &$response;

        $currentMethodName = key($currentMethod);

        foreach ($chainedMethodsBefore as $chainedMethod)
        {
            $chainedMethodName = key($chainedMethod);
            $chainedMethodArgs = $chainedMethod[$chainedMethodName];

            $serializedChainedMethodArgs = serialize($chainedMethodArgs);
            $rResponse[$chainedMethodName][$serializedChainedMethodArgs] = [];
            $rResponse = &$rResponse[$chainedMethodName][$serializedChainedMethodArgs];
        }

        $rResponse[$currentMethodName][serialize(current($currentMethod))] = ['response' => ['action' => $action, 'value' => $lastValue, 'counter' => 0]];

        ShortifyPunit::addChainedResponse(array(get_class($this->mockClass) => [$mockClassInstanceId => $response]));
    }
408993
public function withMock($mock)
    {
        if (is_string($mock)) {
            $mock = new $mock;
        }

        $this->mock = $mock;

        return $this;
    }