示例#1
0
 public function testBindsModuleSingletonProviderMethod()
 {
     $bindingMock = $this->getMockBuilder('Octahedron\\Pulp\\Binding\\Binding')->disableOriginalConstructor()->setMethods(['toProvider', 'in'])->getMock();
     $bindingMock->expects($this->once())->method('toProvider')->with($this->isInstanceOf('Octahedron\\Pulp\\Provider\\ProviderMethod'))->will($this->returnValue($bindingMock));
     $bindingMock->expects($this->once())->method('in')->with($this->identicalTo(Scopes::singleton()));
     $binderStub = $this->getMockBuilder('Octahedron\\Pulp\\Binding\\Binder')->setConstructorArgs([new AnnotationReader()])->setMethods(['bind'])->getMock();
     $binderStub->expects($this->once())->method('bind')->will($this->returnValue($bindingMock));
     $binderStub->install(new TestSingletonModule($binderStub));
 }
示例#2
0
 protected function getProviderMethods(Module $module)
 {
     $reflectedClass = new \ReflectionClass($module);
     foreach ($reflectedClass->getMethods() as $reflectedMethod) {
         $provides = $this->annotationReader->getMethodAnnotation($reflectedMethod, Provides::CLASS);
         if ($provides) {
             $binding = $this->bind($provides->value)->toProvider(new ProviderMethod($module, $reflectedMethod->getName()));
             if ($this->annotationReader->getMethodAnnotation($reflectedMethod, Singleton::CLASS)) {
                 $binding->in(Scopes::singleton());
             }
         }
     }
 }
示例#3
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Invalid scope specified
  */
 public function testInvalidScope()
 {
     Scopes::invalidScope();
 }
示例#4
0
 public function __construct($interface)
 {
     $this->interface = $interface;
     $this->scope = Scopes::instance();
 }