Skip to content

Commit

Permalink
Merge pull request #25 from felixfbecker/default-value-resolver
Browse files Browse the repository at this point in the history
Default value resolver
  • Loading branch information
mnapoli authored Dec 17, 2016
2 parents 11868e9 + b99e355 commit 6b86749
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Interop\Container\ContainerInterface;
use Invoker\CallableResolver;
use Invoker\ParameterResolver\AssociativeArrayResolver;
use Invoker\ParameterResolver\DefaultValueResolver;
use Invoker\ParameterResolver\Container\TypeHintContainerResolver;
use Invoker\ParameterResolver\ResolverChain;

Expand Down Expand Up @@ -77,6 +78,7 @@ public function __construct(ContainerBuilder $containerBuilder = null, array $va
new ResolverChain([
new AssociativeArrayResolver,
new TypeHintContainerResolver($this->containerInteropProxy),
new DefaultValueResolver,
])
);
});
Expand Down
15 changes: 15 additions & 0 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ public function should_pass_request_object_by_parameter_name()
$this->assertEquals('Hello john', $response->getContent());
}

/**
* @test
*/
public function should_resolve_default_parameter()
{
$app = $this->createApplication();

$app->get('/', function ($optional = null) {
return 'Hello';
});

$response = $app->handle(Request::create('/?name=john'));
$this->assertEquals('Hello', $response->getContent());
}

/**
* @test
*/
Expand Down

0 comments on commit 6b86749

Please sign in to comment.