Permalink
Browse files

Merge branch 'feature/auto-resolve-with-default-args' into develop

  • Loading branch information...
2 parents c182b4f + eaba5ec commit af43c267c1e05aad626e0111978f017df63d4e79 @trq trq committed Jan 28, 2013
@@ -239,6 +239,10 @@ public function getDependencies($params)
} else {
$deps[] = $this->resolve($dependency->name);
}
+ } else {
+ if ($param->isDefaultValueAvailable()) {
+ $deps[] = $param->getDefaultValue();
+ }
}
}
return $deps;
@@ -3,14 +3,21 @@
class Foo
{
protected $bar;
+ protected $what;
- public function __construct(Bar $bar)
+ public function __construct(Bar $bar, $what = 'thisiswhat')
{
$this->bar = $bar;
+ $this->what = $what;
}
public function getBar()
{
return $this->bar;
}
+
+ public function getWhat()
+ {
+ return $this->what;
+ }
}
@@ -321,6 +321,16 @@ public function testCanAutoResolveWithDeps()
$this->assertInstanceOf('Bar', $am->resolve('Foo')->getBar());
}
+ public function testCanAutoResolveDepsWithDefaultValues()
+ {
+ require_once __DIR__ . '/AssetManagerFixtures/Foo.php';
+ require_once __DIR__ . '/AssetManagerFixtures/Bar.php';
+ $am = new AssetManager;
+
+ $this->assertInstanceOf('Foo', $am->resolve('Foo'));
+ $this->assertEquals('thisiswhat', $am->resolve('Foo')->getWhat());
+ }
+
public function testCanAutoResolveAliased()
{
require_once __DIR__ . '/AssetManagerFixtures/Bar.php';

0 comments on commit af43c26

Please sign in to comment.