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

Commit eb67a42

Browse files
committed
Merge branch 'hotfix/fragment-default'
Close #33
2 parents 1e0ef9c + 413dfc9 commit eb67a42

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
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 1.2.1 - TBD
5+
## 1.2.1 - 2017-01-12
66

77
### Added
88

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

1919
### Fixed
2020

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

2326
## 1.2.0 - 2017-01-11
2427

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)