示例#1
0
文件: WrapTest.php 项目: ranyuen/di
 public function testWrappedByAnnotation()
 {
     $c = new Container();
     $c['q'] = $c->protect(function ($invocation, $args) {
         return $invocation($args[0] * 7);
     });
     $wrapped = $c->newInstance('Fixture\\Wrapped');
     $this->assertEquals(42, $wrapped->qqq(6));
 }
示例#2
0
文件: BindTest.php 项目: ranyuen/di
 public function testProtect()
 {
     $c = new Container();
     $c['musasabi'] = function () {
         return 42;
     };
     $c['momonga'] = $c->protect(function () {
         return 42;
     });
     $this->assertEquals(42, $c['musasabi']);
     $this->assertEquals(42, $c['momonga']());
 }