Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 382b955

Browse files
committed
Merge branch 'hotfix/fragment-default' into develop
Forward port #33 Conflicts: CHANGELOG.md
2 parents 85d3add + 413dfc9 commit 382b955

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file, in reverse
2020

2121
- Nothing.
2222

23-
## 1.2.1 - TBD
23+
## 1.2.1 - 2017-01-12
2424

2525
### Added
2626

@@ -36,7 +36,10 @@ All notable changes to this project will be documented in this file, in reverse
3636

3737
### Fixed
3838

39-
- Nothing.
39+
- [#33](https://github.com/zendframework/zend-expressive-zendviewrenderer/pull/33)
40+
fixes the signature of the `UrlHelper` to make the default value of
41+
`$fragmentIdentifer` a `null` instead of `''`; this fixes an issue whereby
42+
missing fragments led to exceptions thrown by zend-expressive-helpers.
4043

4144
## 1.2.0 - 2017-01-11
4245

src/UrlHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function __construct(BaseHelper $helper)
2828
/**
2929
* Proxies to `Zend\Expressive\Helper\UrlHelper::generate()`
3030
*
31-
* @param string $routeName
31+
* @param null|string $routeName
3232
* @param array $routeParams
3333
* @param array $queryParams
34-
* @param string $fragmentIdentifier
34+
* @param null|string $fragmentIdentifier
3535
* @param array $options Can have the following keys:
3636
* - router (array): contains options to be passed to the router
3737
* - reuse_result_params (bool): indicates if the current RouteResult
@@ -42,7 +42,7 @@ public function __invoke(
4242
$routeName = null,
4343
array $routeParams = [],
4444
array $queryParams = [],
45-
$fragmentIdentifier = '',
45+
$fragmentIdentifier = null,
4646
array $options = []
4747
) {
4848
return $this->helper->generate($routeName, $routeParams, $queryParams, $fragmentIdentifier, $options);

test/UrlHelperTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function createHelper()
2525

2626
public function testInvocationProxiesToBaseHelper()
2727
{
28-
$this->baseHelper->generate('resource', ['id' => 'sha1'], [], '', [])->willReturn('/resource/sha1');
28+
$this->baseHelper->generate('resource', ['id' => 'sha1'], [], null, [])->willReturn('/resource/sha1');
2929
$helper = $this->createHelper();
3030
$this->assertEquals('/resource/sha1', $helper('resource', ['id' => 'sha1']));
3131
}
@@ -45,4 +45,23 @@ public function testUrlHelperAcceptsQueryParametersFragmentAndOptions()
4545
$helper('resource', ['id' => 'sha1'], ['foo' => 'bar'], 'fragment', ['reuse_result_params' => true])
4646
);
4747
}
48+
49+
/**
50+
* In particular, the fragment identifier needs to be null.
51+
*/
52+
public function testUrlHelperPassesExpectedDefaultsToBaseHelper()
53+
{
54+
$this->baseHelper->generate(
55+
null,
56+
[],
57+
[],
58+
null,
59+
[]
60+
)->willReturn('PATH');
61+
$helper = $this->createHelper();
62+
$this->assertEquals(
63+
'PATH',
64+
$helper()
65+
);
66+
}
4867
}

0 commit comments

Comments
 (0)