Skip to content

Commit

Permalink
formatting and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 19, 2020
1 parent 6aa80e7 commit 44c2a8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Container/BoundMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected static function addDependencyForCallParameter($container, $parameter,
} elseif ($parameter->isDefaultValueAvailable()) {
$dependencies[] = $parameter->getDefaultValue();
} elseif (! $parameter->isOptional() && ! array_key_exists($parameter->name, $parameters)) {
$message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}";
$message = "Unable to resolve dependency [{$parameter}] in class {$parameter->getDeclaringClass()->getName()}";

throw new BindingResolutionException($message);
}
Expand Down
13 changes: 12 additions & 1 deletion tests/Container/ContainerCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,22 @@ public function testCallWithCallableObject()
public function testCallWithoutRequiredParamsThrowsException()
{
$this->expectException(BindingResolutionException::class);
$this->expectExceptionMessage('Unresolvable dependency resolving [Parameter #0 [ <required> $foo ]] in class Illuminate\Tests\Container\ContainerTestCallStub');
$this->expectExceptionMessage('Unable to resolve dependency [Parameter #0 [ <required> $foo ]] in class Illuminate\Tests\Container\ContainerTestCallStub');

$container = new Container;
$container->call(ContainerTestCallStub::class.'@unresolvable');
}

public function testCallWithoutRequiredParamsOnClosureThrowsException()
{
$this->expectException(BindingResolutionException::class);
$this->expectExceptionMessage('Unable to resolve dependency [Parameter #0 [ <required> $foo ]] in class Illuminate\Tests\Container\ContainerCallTest');

$container = new Container;
$foo = $container->call(function ($foo, $bar = 'default') {
return $foo;
});
}
}

class ContainerTestCallStub
Expand Down

0 comments on commit 44c2a8d

Please sign in to comment.