Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.3' into 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 15, 2016
2 parents 59a1ce2 + 2c969e8 commit 33edf4d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG-5.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
- Don't report exceptions inside queue worker signal handler ([#16738](https://github.com/laravel/framework/pull/16738))
- Kill timed out queue worker process ([#16746](https://github.com/laravel/framework/pull/16746))
- Removed unnecessary check in `ScheduleRunCommand::fire()` ([#16752](https://github.com/laravel/framework/pull/16752))
- Improved performance of `Str::startsWith()` ([#16761](https://github.com/laravel/framework/pull/16761))
- Improved handling of numeric values in `Str::startsWith()` ([#16770](https://github.com/laravel/framework/pull/16770))

### Fixed
- Added file existance check to `AppNameCommand::replaceIn()` to fix [#16575](https://github.com/laravel/framework/pull/16575) ([#16592](https://github.com/laravel/framework/pull/16592))
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ public function substituteImplicitBindings($route)
! $route->getParameter($parameter->name) instanceof Model) {
$method = $parameter->isDefaultValueAvailable() ? 'first' : 'firstOrFail';

$model = $class->newInstance();
$model = $this->container->make($class->name);

$route->setParameter(
$parameter->name, $model->where(
Expand Down
23 changes: 23 additions & 0 deletions tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,25 @@ public function testImplicitBindingsWithOptionalParameter()
$router->dispatch(Request::create('bar', 'GET'))->getContent();
}

public function testImplicitBindingThroughIOC()
{
$phpunit = $this;
$container = new Container;
$router = new Router(new Dispatcher, $container);
$container->singleton(Registrar::class, function () use ($router) {
return $router;
});

$container->bind('RoutingTestUserModel', 'RoutingTestExtendedUserModel');
$router->get('foo/{bar}', [
'middleware' => SubstituteBindings::class,
'uses' => function (RoutingTestUserModel $bar) use ($phpunit) {
$phpunit->assertInstanceOf(RoutingTestExtendedUserModel::class, $bar);
},
]);
$router->dispatch(Request::create('foo/baz', 'GET'))->getContent();
}

public function testDispatchingCallableActionClasses()
{
$router = $this->getRouter();
Expand Down Expand Up @@ -1390,6 +1409,10 @@ public function firstOrFail()
}
}

class RoutingTestExtendedUserModel extends RoutingTestUserModel
{
}

class ActionStub
{
public function __invoke()
Expand Down

0 comments on commit 33edf4d

Please sign in to comment.