/** * @test */ public function appendContentAppendsContentCorrectly() { $this->mockResponse->_set('content', 'foo'); $this->mockResponse->appendContent('bar'); $this->assertSame('foobar', $this->mockResponse->_get('content')); }
/** * Calls the specified action method and passes the arguments. * * If the action returns a string, it is appended to the content in the * response object. If the action doesn't return anything and a valid * view exists, the view is rendered automatically. * * @return void * @api */ protected function callActionMethod() { $preparedArguments = array(); /** @var \TYPO3\CMS\Extbase\Mvc\Controller\Argument $argument */ foreach ($this->arguments as $argument) { $preparedArguments[] = $argument->getValue(); } $validationResult = $this->arguments->getValidationResults(); if (!$validationResult->hasErrors()) { $this->emitBeforeCallActionMethodSignal($preparedArguments); $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments); } else { $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName); $ignoreValidationAnnotations = array(); if (isset($methodTagsValues['ignorevalidation'])) { $ignoreValidationAnnotations = $methodTagsValues['ignorevalidation']; } // if there exists more errors than in ignoreValidationAnnotations_=> call error method // else => call action method $shouldCallActionMethod = TRUE; foreach ($validationResult->getSubResults() as $argumentName => $subValidationResult) { if (!$subValidationResult->hasErrors()) { continue; } if (array_search('$' . $argumentName, $ignoreValidationAnnotations) !== FALSE) { continue; } $shouldCallActionMethod = FALSE; } if ($shouldCallActionMethod) { $this->emitBeforeCallActionMethodSignal($preparedArguments); $actionResult = call_user_func_array(array($this, $this->actionMethodName), $preparedArguments); } else { $actionResult = call_user_func(array($this, $this->errorMethodName)); } } if ($actionResult === NULL && $this->view instanceof ViewInterface) { $this->response->appendContent($this->view->render()); } elseif (is_string($actionResult) && strlen($actionResult) > 0) { $this->response->appendContent($actionResult); } elseif (is_object($actionResult) && method_exists($actionResult, '__toString')) { $this->response->appendContent((string) $actionResult); } }