21 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
45 protected function setUp()
48 $this->viewHelper = $this->getAccessibleMock(LinkViewHelper::class, [
'renderChildren']);
49 $this->injectDependenciesIntoViewHelper($this->viewHelper);
51 $this->uriBuilderMock = $this->getMockBuilder(UriBuilder::class)->getMock();
53 $this->tagBuilder = $this->getMockBuilder(TagBuilder::class)->setMethods([
60 $this->inject($this->viewHelper,
'tag', $this->tagBuilder);
68 $this->viewHelper->setArguments([
69 'route' =>
'theRouteArgument',
70 'parameters' => [
'parameter' =>
'to pass'],
71 'referenceType' =>
'theReferenceTypeArgument'
74 GeneralUtility::setSingletonInstance(UriBuilder::class, $this->uriBuilderMock);
76 $this->uriBuilderMock->expects($this->once())->method(
'buildUriFromRoute')
77 ->with(
'theRouteArgument', [
'parameter' =>
'to pass'],
'theReferenceTypeArgument')->willReturn(
'theUri');
79 $this->tagBuilder->expects($this->once())->method(
'addAttribute')->with(
'href',
'theUri');
80 $this->tagBuilder->expects($this->once())->method(
'setContent');
81 $this->tagBuilder->expects($this->once())->method(
'forceClosingTag')->with(
true);
82 $this->tagBuilder->expects($this->once())->method(
'render');
84 $this->viewHelper->render();
92 $this->setArgumentsUnderTest(
95 'route' =>
'theRouteArgument',
96 'referenceType' =>
'theReferenceTypeArgument'
99 GeneralUtility::setSingletonInstance(UriBuilder::class, $this->uriBuilderMock);
101 $this->uriBuilderMock->expects($this->once())->method(
'buildUriFromRoute')
102 ->with(
'theRouteArgument', [],
'theReferenceTypeArgument')->willReturn(
'theUri');
103 $this->viewHelper->render();