/** * Generate the test method as a string. * * @param \Box\TestScribe\Execution\ExecutionResult $executionResult * * @return string */ public function renderMethod(ExecutionResult $executionResult) { $config = $this->globalComputedConfig; $methodName = $config->getMethodName(); $fullyQualifiedClassName = $config->getFullClassName(); // @TODO (ryang 6/3/15) : move exception expectation statement after all the mocks statements. $methodBody = $this->methodBodyRenderer->renderMethodBody($executionResult); $indentationUtlObj = new IndentationUtil(); $shiftedMethodBody = $indentationUtlObj->indent(2, $methodBody); $testMethodName = $config->getTestMethodName(); $methodStatements = <<<TAG /** * @covers {$fullyQualifiedClassName}::{$methodName} * @covers {$fullyQualifiedClassName} */ public function {$testMethodName}() { {$shiftedMethodBody} } TAG; return $methodStatements; }
/** * Generate mock object expectations statements. * * @param \Box\TestScribe\Mock\MockClass $mock * * @return string */ private function renderMockObjectBody(MockClass $mock) { $mockReturnObjectStatements = $this->renderMockedReturnValue($mock); $methodExpectations = $this->mockAllMethodExpectationsRenderer->renderMethodExpectations($mock); $body = ArrayUtil::joinNonEmptyStringsWithNewLine([$mockReturnObjectStatements, $methodExpectations], 2); $indentUtilObj = new IndentationUtil(); $shiftedBody = $indentUtilObj->indent(2, $body); return $shiftedBody; }