public function testUseAlias()
 {
     $c = new ServiceContainer();
     $c->register('B', ['class' => 'Tlumx\\Test\\ServiceContainer\\B', 'args' => ['a' => ['ref' => 'A']]]);
     $c->register('A', ['class' => 'Tlumx\\Test\\ServiceContainer\\A', 'args' => ['some value'], 'calls' => ['setContainer' => [['ref' => 'this']]]]);
     $c->set('a', 'aaa');
     $c->setAlias('a-alias', 'a');
     $c->setAlias('B-alias', 'B');
     $this->assertEquals($c->get('a'), $c->get('a-alias'));
     $this->assertNotSame($c->get('A'), $c->get('B-alias'));
     $this->assertSame($c->get('B'), $c->get('B-alias'));
 }
Exemple #2
0
 /**
  * Constructor
  *
  * @param array $config
  */
 public function __construct(array $config = [])
 {
     parent::__construct([]);
     $this->setConfig($config);
 }