/** * Render a link to a specific module * * @param string $path Target module path * @param string $action Target module action * @param array $arguments Arguments * @param string $section The anchor to be added to the URI * @param string $format The requested format, e.g. ".html" * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments) * @param boolean $addQueryString If set, the current query parameters will be kept in the URI * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE * @return string The rendered link * @throws \TYPO3\Fluid\Core\ViewHelper\Exception */ public function render($path, $action = null, $arguments = array(), $section = '', $format = '', array $additionalParams = array(), $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array()) { $this->uriModuleViewHelper->setRenderingContext($this->renderingContext); $uri = $this->uriModuleViewHelper->render($path, $action, $arguments, $section, $format, $additionalParams, $addQueryString, $argumentsToBeExcludedFromQueryString); if ($uri !== null) { $this->tag->addAttribute('href', $uri); } $this->tag->setContent($this->renderChildren()); $this->tag->forceClosingTag(true); return $this->tag->render(); }
/** * @test */ public function callingRenderAssignsVariablesCorrectlyToUriBuilder() { $this->uriBuilder->expects($this->once())->method('setSection')->with('section')->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setArguments')->with(array('additionalParams'))->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setArgumentsToBeExcludedFromQueryString')->with(array('argumentsToBeExcludedFromQueryString'))->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setFormat')->with('format')->will($this->returnSelf()); $expectedModifiedArguments = array('module' => 'the/path', 'moduleArguments' => array('arguments', '@action' => 'action')); $this->uriBuilder->expects($this->once())->method('uriFor')->with('index', $expectedModifiedArguments); // fallback for the method chaining of the URI builder $this->uriBuilder->expects($this->any())->method($this->anything())->will($this->returnValue($this->uriBuilder)); $this->viewHelper->render('the/path', 'action', array('arguments'), 'section', 'format', array('additionalParams'), true, array('argumentsToBeExcludedFromQueryString')); }
/** * @test */ public function callingRenderAddsUriViewHelpersReturnAsTagHrefAttributeIfItsNotEmpty() { $this->uriModuleViewHelper->expects($this->once())->method('render')->will($this->returnValue('SomethingNotNull')); $this->tagBuilder->expects($this->once())->method('addAttribute')->with('href', 'SomethingNotNull'); $this->viewHelper->render('path'); }