public function testInstantiateExplicitlyDisabledSingletonLeafes()
 {
     $config = array('YadifFoo' => array('class' => 'YadifFoo', 'scope' => Yadif_Container::SCOPE_SINGLETON, 'arguments' => array('YadifBaz', 'YadifBaz'), 'methods' => array()), 'YadifBaz' => array('class' => 'YadifBaz', 'scope' => Yadif_Container::SCOPE_PROTOTYPE, 'arguments' => array(), 'methods' => array()));
     $yadif = new Yadif_Container($config);
     $component = $yadif->getComponent("YadifFoo");
     $this->assertFalse($component->a === $component->b, 'Not Enforcing singleton of object did not work!');
 }
Exemple #2
0
 public function testBindMethodParamInConfigurationThroughParametersKey()
 {
     $config = array('YadifBaz' => array('class' => 'YadifBaz', 'methods' => array(array('method' => 'setA', 'arguments' => array(':foo'), 'params' => array(':foo' => 'bar')))));
     $yadif = new Yadif_Container($config);
     $component = $yadif->getComponent("YadifBaz");
     $this->assertEquals("bar", $component->a);
 }
 public function testRequireInformationFromConfigButGiveNonThrowsException()
 {
     $this->setExpectedException("Yadif_Exception");
     $components = array('YadifBaz' => array('class' => 'YadifBaz', 'methods' => array(array('method' => 'setA', 'arguments' => array('%foo.bar%')))));
     $yadif = new Yadif_Container($components);
     $baz = $yadif->getComponent('YadifBaz');
 }
 public function testDecorateInstance()
 {
     $config = array('YadifBaz' => array('class' => 'YadifBaz', 'decorateWith' => array('YadifBar', 'YadifFoo')), 'YadifBar' => array('arguments' => array('DecoratedInstance')), 'YadifFoo' => array('arguments' => array('DecoratedInstance')));
     $yadif = new Yadif_Container($config);
     $baz = $yadif->getComponent('YadifBaz');
     $this->assertType('YadifFoo', $baz);
     $this->assertType('YadifBar', $baz->a);
     $this->assertType('YadifBaz', $baz->a->a);
 }