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

Commit

Permalink
Merge branch 'hotfix/31'
Browse files Browse the repository at this point in the history
Close #31
  • Loading branch information
weierophinney committed Sep 6, 2016
2 parents 5debcc1 + d7bee91 commit f1ee9ae
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

## 3.0.2 - TBD
## 3.0.2 - 2016-09-06

### Added

Expand All @@ -25,6 +25,10 @@ All notable changes to this project will be documented in this file, in reverse
prevents false negative assertions from occuring.
- [#21](https://github.com/zendframework/zend-test/pull/21) updates the
`sebastian/version` dependency to also allow v2.0 releases.
- [#31](https://github.com/zendframework/zend-test/pull/31) fixes an issue with
the `AbstractControllerTestCase` when used to test a console request.
Previously, routes with multiple literal flags were never matched; they now
are.

## 3.0.1 - 2016-06-15

Expand Down
2 changes: 1 addition & 1 deletion src/PHPUnit/Controller/AbstractControllerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function url($url, $method = HttpRequest::METHOD_GET, $params = [])
{
$request = $this->getRequest();
if ($this->useConsoleRequest) {
preg_match_all('/(--\S+[= ]"[^\s"]*\s*[^\s"]*")|(--\S+=\S+|--\S+\s\S+|\S+)/', $url, $matches);
preg_match_all('/(--\S+[= ]"[^\s"]*\s*[^\s"]*")|(\S+)/', $url, $matches);
$params = str_replace([' "', '"'], ['=', ''], $matches[0]);
$request->params()->exchangeArray($params);

Expand Down
23 changes: 23 additions & 0 deletions test/PHPUnit/Controller/AbstractConsoleControllerTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,27 @@ public function testAssertMatchedArgumentsWithValueWithoutEqualsSign()
$this->assertEquals("10", $routeMatch->getParam('id'));
$this->assertEquals("custom text", $routeMatch->getParam('text'));
}

public function testAssertMatchedArgumentsWithLiteralFlags()
{
$this->dispatch('literal --foo --bar');
$routeMatch = $this->getApplication()->getMvcEvent()->getRouteMatch();
$this->assertInstanceOf(RouteMatch::class, $routeMatch, 'Did not receive a route match?');
$this->assertMatchedRouteName('arguments-literal');
$this->assertTrue($routeMatch->getParam('foo'));
$this->assertTrue($routeMatch->getParam('bar'));
$this->assertFalse($routeMatch->getParam('optional'));
$this->assertNull($routeMatch->getParam('doo'));

$this->reset();

$this->dispatch('literal --foo --bar --doo test');
$routeMatch = $this->getApplication()->getMvcEvent()->getRouteMatch();
$this->assertInstanceOf(RouteMatch::class, $routeMatch, 'Did not receive a route match?');
$this->assertMatchedRouteName('arguments-literal');
$this->assertTrue($routeMatch->getParam('foo'));
$this->assertTrue($routeMatch->getParam('bar'));
$this->assertFalse($routeMatch->getParam('optional'));
$this->assertSame('test', $routeMatch->getParam('doo'));
}
}
12 changes: 11 additions & 1 deletion test/_files/Baz/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@
'action' => 'console',
),
),
)
),
'arguments-literal' => array(
'type' => 'simple',
'options' => array(
'route' => 'literal --foo [--bar] [--doo=] [--optional]',
'defaults' => array(
'controller' => 'baz_index',
'action' => 'console',
),
),
),
),
),
),
Expand Down

0 comments on commit f1ee9ae

Please sign in to comment.