public function testRemoveBindingKeepsStoredBindings()
 {
     $discovery = $this->createDiscovery();
     $discovery->addBindingType(new BindingType(Foo::clazz));
     $discovery->addBinding($binding1 = new ResourceBinding('/path1', Foo::clazz));
     $discovery->addBinding($binding2 = new ClassBinding(__CLASS__, Foo::clazz));
     $discovery = $this->loadDiscoveryFromStorage($discovery);
     $discovery->removeBinding($binding1->getUuid());
     $this->assertEquals(array($binding2), $discovery->getBindings());
     $this->assertFalse($discovery->hasBinding($binding1->getUuid()));
     $this->assertTrue($discovery->hasBinding($binding2->getUuid()));
 }
Beispiel #2
0
 /**
  * @param Args         $args
  * @param ClassBinding $bindingToUpdate
  *
  * @return ClassBinding
  */
 private function getUpdatedClassBinding(Args $args, ClassBinding $bindingToUpdate)
 {
     $className = $bindingToUpdate->getClassName();
     $typeName = $bindingToUpdate->getTypeName();
     $bindingParams = $bindingToUpdate->getParameterValues();
     if ($args->isOptionSet('class')) {
         $className = $args->getOption('class');
     }
     if ($args->isOptionSet('type')) {
         $typeName = $args->getOption('type');
     }
     $this->parseParams($args, $bindingParams);
     $this->unsetParams($args, $bindingParams);
     return new ClassBinding($className, $typeName, $bindingParams, $bindingToUpdate->getUuid());
 }
 public function testCreateWithClassName()
 {
     $binding = new ClassBinding(__CLASS__, Foo::clazz);
     $this->assertSame(__CLASS__, $binding->getClassName());
 }
 public function testRemoveBindingTypesRemovesBindings()
 {
     $discovery = $this->createDiscovery();
     $discovery->addBindingType(new BindingType(Foo::clazz));
     $discovery->addBindingType(new BindingType(Bar::clazz));
     $discovery->addBinding($binding1 = new ResourceBinding('/path1', Foo::clazz));
     $discovery->addBinding($binding2 = new ClassBinding(__CLASS__, Bar::clazz));
     $discovery->removeBindingTypes();
     $discovery = $this->loadDiscoveryFromStorage($discovery);
     $this->assertCount(0, $discovery->getBindings());
     $this->assertFalse($discovery->hasBinding($binding1->getUuid()));
     $this->assertFalse($discovery->hasBinding($binding2->getUuid()));
 }