Skip to content

Commit

Permalink
Add tests for container method binding
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Dec 14, 2016
1 parent 8b84d29 commit 45306f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Container/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,23 @@ public function testCallWithGlobalMethodName()
$this->assertEquals('taylor', $result[1]);
}

public function testCallWithBoundMethod()
{
$container = new Container;
$container->bindMethod('ContainerTestCallStub@unresolvable', function ($stub) {
return $stub->unresolvable('foo', 'bar');
});
$result = $container->call('ContainerTestCallStub@unresolvable');
$this->assertEquals(['foo', 'bar'], $result);

$container = new Container;
$container->bindMethod('ContainerTestCallStub@unresolvable', function ($stub) {
return $stub->unresolvable('foo', 'bar');
});
$result = $container->call([new ContainerTestCallStub, 'unresolvable']);
$this->assertEquals(['foo', 'bar'], $result);
}

public function testContainerCanInjectDifferentImplementationsDependingOnContext()
{
$container = new Container;
Expand Down Expand Up @@ -812,6 +829,11 @@ public function inject(ContainerConcreteStub $stub, $default = 'taylor')
{
return func_get_args();
}

public function unresolvable($foo, $bar)
{
return func_get_args();
}
}

class ContainerTestContextInjectOne
Expand Down

0 comments on commit 45306f6

Please sign in to comment.