/**
  * Return statements for invoking the test and verifying the result.
  *
  * @param \Box\TestScribe\Execution\ExecutionResult $executionResult
  *
  * @param string                                    $targetObjectName
  *
  * @return string
  */
 public function genExecutionAndVerification(ExecutionResult $executionResult, $targetObjectName)
 {
     $exception = $executionResult->getException();
     $isReturnTypeVoid = $this->globalComputedConfig->isReturnTypeVoid();
     $shouldVerifyResult = $exception === null && !$isReturnTypeVoid;
     $methodArguments = $executionResult->getMethodArguments();
     $argumentsString = $this->argumentsRenderer->renderArgumentsAsStringInCode($methodArguments);
     $executionStatements = $this->executionRenderer->genExecutionStatements($shouldVerifyResult, $argumentsString, $targetObjectName);
     $resultValidationStatements = $this->resultValidationRenderer->genResultValidation($shouldVerifyResult, $executionResult);
     $result = ArrayUtil::joinNonEmptyStringsWithNewLine([$executionStatements, $resultValidationStatements], 2);
     return $result;
 }
 /**
  * Generate expected exception statement if an exception is thrown.
  * Otherwise return ''.
  *
  * @param \Box\TestScribe\Execution\ExecutionResult $executionResult
  *
  * @return string
  */
 public function genExceptionExpectation(ExecutionResult $executionResult)
 {
     $exception = $executionResult->getException();
     if ($exception !== null) {
         $exceptionType = get_class($exception);
         $exceptionTypeAsStringInCode = $this->varExporter->exportVariable($exceptionType);
         $exceptionMsg = $exception->getMessage();
         $exceptionMsgInCode = $this->varExporter->exportVariable($exceptionMsg);
         $exceptionStatement = "\$this->setExpectedException({$exceptionTypeAsStringInCode}, {$exceptionMsgInCode});";
     } else {
         $exceptionStatement = '';
     }
     return $exceptionStatement;
 }
 /**
  * @param \Box\TestScribe\Execution\ExecutionResult $result
  *
  * @return void
  */
 public function showExecutionResult(ExecutionResult $result)
 {
     $exception = $result->getException();
     if ($exception) {
         $exceptionType = get_class($exception);
         $exceptionMsg = $exception->getMessage();
         $resultMsg = "An exception ( {$exceptionType} ) is thrown.\n" . "Exception message ( {$exceptionMsg} ).";
     } else {
         $value = $result->getResultValue();
         // @TODO (ryang 6/4/15) : don't show the value if the return value of the method is void.
         $valueStr = $this->valueFormatter->getReadableFormat($value);
         $resultMsg = "Result from this method execution is :\n" . "{$valueStr}\n" . "End of the result.";
     }
     $msg = "{$resultMsg}\n\n" . "Please verify this result and the interactions with the mocks are what you expect.";
     $this->output->writeln($msg);
 }