/**
  * @return \Box\TestScribe\Execution\ExecutionResult
  *
  * @throws \Box\TestScribe\Exception\AbortException
  * @throws \Exception
  */
 public function runInstanceMethod()
 {
     // Even when the real constructor throws an exception,
     // the mocked object of the class under test is still needed
     // to generate the mock statements to cause the exception
     // to happen.
     $config = $this->globalComputedConfig;
     $className = $config->getFullClassName();
     $methodName = $config->getMethodName();
     $methodObj = $config->getInMethod();
     $mockClassUnderTest = $this->mockClassLoader->createAndLoadMockClass($className, $methodName);
     $mockCreationResult = $this->classUnderTestMockCreator->createMockObjectForTheClassUnderTest($mockClassUnderTest);
     $constructorArgs = $mockCreationResult->getConstructorArgs();
     $mockObj = $mockCreationResult->getMockObj();
     $exceptionFromExecution = $mockCreationResult->getException();
     if ($exceptionFromExecution === null) {
         $methodArgs = $this->argumentsCollector->collect($methodObj);
         $result = $this->expectedExceptionCatcher->execute([$this->reflectionUtil, 'invokeMethodRegardlessOfProtectionLevel'], [$mockObj, $methodObj, $methodArgs]);
         $exceptionFromExecution = $result->getException();
         $executionResult = $result->getResult();
     } else {
         $methodArgs = new Arguments([]);
         $executionResult = null;
     }
     $returnValue = new ExecutionResult($constructorArgs, $methodArgs, $mockClassUnderTest, $executionResult, $exceptionFromExecution);
     return $returnValue;
 }
 /**
  * @return \Box\TestScribe\Execution\ExecutionResult
  *
  * @throws \Box\TestScribe\Exception\AbortException
  * @throws \Exception
  */
 public function runStaticMethod()
 {
     $config = $this->globalComputedConfig;
     $methodObj = $config->getInMethod();
     $methodArgs = $this->argumentsCollector->collect($methodObj);
     $result = $this->expectedExceptionCatcher->execute([$this->reflectionUtil, 'invokeMethodRegardlessOfProtectionLevel'], [null, $methodObj, $methodArgs]);
     $exceptionFromExecution = $result->getException();
     $executionResult = $result->getResult();
     // No constructor arguments needed for static methods invocation.
     $constructorArgs = new Arguments([]);
     // Partial mocking of static methods is not supported.
     $mockClassUnderTest = null;
     $returnValue = new ExecutionResult($constructorArgs, $methodArgs, $mockClassUnderTest, $executionResult, $exceptionFromExecution);
     return $returnValue;
 }
 /**
  * @param \Box\TestScribe\Mock\MockClass $mockClassUnderTest
  *
  * @return \Box\TestScribe\Execution\ClassUnderTestMockCreationResultValue
  */
 public function createMockObjectForTheClassUnderTest(MockClass $mockClassUnderTest)
 {
     $constructorMethodObj = $mockClassUnderTest->getConstructorOfTheMockedClass();
     if ($constructorMethodObj) {
         $constructorArgs = $this->argumentsCollector->collect($constructorMethodObj);
         $constructorArgValues = $constructorArgs->getValues();
         $this->output->writeln("\nStart executing the constructor.\n");
     } else {
         // When the class under test doesn't have a constructor defined
         // don't display the constructor execution message.
         $constructorArgs = new Arguments([]);
         $constructorArgValues = [];
     }
     $result = $this->expectedExceptionCatcher->execute([$this->mockObjectFactory, 'createMockObjectFromMockClass'], [$mockClassUnderTest, $constructorArgValues]);
     $mockObj = $result->getResult();
     $exception = $result->getException();
     if ($constructorMethodObj) {
         $this->output->writeln("\nFinish executing the constructor.\n");
     }
     $result = new ClassUnderTestMockCreationResultValue($constructorArgs, $mockObj, $exception);
     return $result;
 }