Skip to content
This repository was archived by the owner on May 1, 2019. It is now read-only.

Commit ad5283f

Browse files
committed
Merge pull request #466 from localheinz/fix/zf-module-list-route
Fix: Config key should be 'constraints' instead of 'constrains'
2 parents 4610f6b + 3e1ff17 commit ad5283f

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

module/ZfModule/config/module.config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
'type' => 'Segment',
5555
'options' => [
5656
'route' => '/list[/:owner]',
57-
'constrains' => [
57+
'constraints' => [
5858
'owner' => '[a-zA-Z][a-zA-Z0-9_-]*',
5959
],
6060
'defaults' => [

module/ZfModule/test/ZfModuleTest/Integration/Controller/IndexControllerTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,67 @@ public function testOrganizationActionFetches100MostRecentlyUpdatedRepositoriesW
228228
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
229229
}
230230

231+
/**
232+
* @dataProvider providerInvalidVendor
233+
* @param $vendor
234+
*/
235+
public function testOrganizationActionDoesNotMatchOnInvalidVendor($vendor)
236+
{
237+
$this->authenticatedAs(new User());
238+
239+
$repositoryCollection = $this->repositoryCollectionMock();
240+
241+
$repositoryRetriever = $this->getMockBuilder(RepositoryRetriever::class)
242+
->disableOriginalConstructor()
243+
->getMock()
244+
;
245+
246+
$repositoryRetriever
247+
->expects($this->any())
248+
->method('getUserRepositories')
249+
->with(
250+
$this->equalTo($vendor),
251+
$this->equalTo([
252+
'per_page' => 100,
253+
'sort' => 'updated',
254+
'direction' => 'desc',
255+
]
256+
))
257+
->willReturn($repositoryCollection)
258+
;
259+
260+
$this->getApplicationServiceLocator()
261+
->setAllowOverride(true)
262+
->setService(
263+
RepositoryRetriever::class,
264+
$repositoryRetriever
265+
)
266+
;
267+
268+
$url = sprintf(
269+
'/module/list/%s',
270+
$vendor
271+
);
272+
273+
$this->dispatch($url);
274+
275+
$event = $this->getApplication()->getMvcEvent();
276+
277+
$this->assertSame(Mvc\Application::ERROR_ROUTER_NO_MATCH, $event->getError());
278+
}
279+
280+
/**
281+
* @return array
282+
*/
283+
public function providerInvalidVendor()
284+
{
285+
return [
286+
[
287+
'9',
288+
],
289+
];
290+
}
291+
231292
public function testOrganizationActionFetches100MostRecentlyUpdatedRepositoriesWithOwnerSpecified()
232293
{
233294
$this->authenticatedAs(new User());

0 commit comments

Comments
 (0)