Skip to content

Commit

Permalink
Merge pull request #133 from neos/bugfix/formviewhelper-fragment
Browse files Browse the repository at this point in the history
BUGFIX: Set uri section in form viewhelper
  • Loading branch information
Sebobo authored Mar 15, 2021
2 parents 31ec0ba + fa6444d commit 25b2f05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/FormViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function getFormActionUri()
$actionRequest = $this->controllerContext->getRequest();
$uri = $actionRequest->getHttpRequest()->getUri();
if ($this->hasArgument('section') && $this->arguments['section'] !== '') {
$uri->withFragment($this->hasArgument('section'));
$uri = $uri->withFragment($this->arguments['section']);
}
return (string)$uri;
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/Unit/ViewHelpers/FormViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public function getFormActionUriTests($requestUri, $sectionArgument, $expectedRe
$mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($mockHttpRequest));

$mockUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock();
$mockUri->expects($this->any())->method('withFragment')->will($this->returnCallback(function ($fragment) use ($requestUri, $mockUri) {
$newUri = explode('#', $requestUri)[0] . '#' . $fragment;
$modifiedMockUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock();
$modifiedMockUri->expects($this->any())->method('__toString')->will($this->returnValue($newUri));
return $modifiedMockUri;
}));
$mockUri->expects($this->any())->method('__toString')->will($this->returnValue($requestUri));
$mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($mockUri));

Expand Down

0 comments on commit 25b2f05

Please sign in to comment.