コード例 #1
0
 /**
  * @param string     $methodName
  * @param array      $arguments
  * @param InputValue $returnInputValue
  *
  * @return InvocationSpec
  */
 private function convertOne($methodName, array $arguments, InputValue $returnInputValue)
 {
     $convertedArguments = [];
     foreach ($arguments as $arg) {
         $convertedArguments[] = $this->valueTransformer->translateObjectsAndResourceToString($arg, true);
     }
     $returnValue = $returnInputValue->getValue();
     $convertedReturnValue = $this->valueTransformer->translateObjectsAndResourceToString($returnValue, true);
     $spec = new InvocationSpec($methodName, $convertedArguments, $convertedReturnValue);
     return $spec;
 }
コード例 #2
0
 /**
  * Generate and return the statement for setting up one
  * mocked object method invocation expectation.
  *
  * @param Method     $methodObj
  * @param array      $arguments
  * @param InputValue $returnValue
  *
  * @return string
  */
 public function renderOneMethodExpectation(Method $methodObj, array $arguments, InputValue $returnValue)
 {
     $methodName = $methodObj->getName();
     $argString = $this->mockedMethodInvocationArgumentsRenderer->renderMockedMethodArguments($arguments);
     $expectationStatements = "\$shmock->{$methodName}({$argString});";
     // @TODO (ryang 9/12/14) : can we make this decision purely based on the $value?
     // If no return value still specify return null?
     // If the method has no return value
     // don't generate the return value mock statement.
     if (!$returnValue->isVoid()) {
         $returnValueAsString = $returnValue->getExpression();
         $returnValueCallStatement = "\$mock->return_value({$returnValueAsString});";
         $expectationStatements = "/** @var \$mock \\Shmock\\Spec */\n" . "\$mock = {$expectationStatements}\n" . "{$returnValueCallStatement}";
     }
     return $expectationStatements;
 }
コード例 #3
0
 /**
  * @param \Box\TestScribe\MethodInfo\Method     $methodObj
  * @param array                                $arguments
  * @param \Box\TestScribe\Input\InputValue $value
  *
  * @return void
  */
 public function saveInvocationInformation(Method $methodObj, array $arguments, InputValue $value)
 {
     // Save the mocked object so that we can generate the mock statements for them.
     $this->mockedReturnValues = array_merge($this->mockedReturnValues, $value->getMocks());
     // To make the renderer simpler,
     // always save the MockClass instance in invocation record.
     $this->methodInvocations[] = [$methodObj, $arguments, $value];
 }