Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit af43c267c1e05aad626e0111978f017df63d4e79 2 parents c182b4f + eaba5ec
@trq trq authored
View
4 lib/Proem/Service/AssetManager.php
@@ -239,6 +239,10 @@ public function getDependencies($params)
} else {
$deps[] = $this->resolve($dependency->name);
}
+ } else {
+ if ($param->isDefaultValueAvailable()) {
+ $deps[] = $param->getDefaultValue();
+ }
}
}
return $deps;
View
9 lib/Proem/Service/Tests/AssetManagerFixtures/Foo.php
@@ -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;
+ }
}
View
10 lib/Proem/Service/Tests/AssetManagerTest.php
@@ -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';
Please sign in to comment.
Something went wrong with that request. Please try again.