public function testCanAddExtensionsToDefinition()
 {
     $service = Mockery::mock('foobar');
     $service->shouldReceive('someMethod')->once()->with('bar');
     $container = new Container();
     $container->addDefinitionProvider(new ArrayDefinitionProvider(['foobar' => new ParameterDefinition($service), 'foo' => 'bar', 'extenstion' => (new ExtendDefinition('foobar'))->addMethodCall('someMethod', new Reference('foo'))]));
     $container->get('foobar');
 }
Exemple #2
0
 /**
  * @param object|null $container
  */
 public function setContainer($container = null)
 {
     // Setup container
     $delegates = [$this->container, new ReflectionContainer()];
     $parentContainer = new Container();
     $parentContainer->share(ContainerInterface::class, $parentContainer);
     if ($container) {
         // Unify container to PSR11
         $acclimator = new ContainerAcclimator();
         $container = $acclimator->acclimate($container);
         array_unshift($delegates, $container);
     }
     // Bind delegates
     $delegates = array_filter($delegates);
     foreach ($delegates as $delegate) {
         $parentContainer->delegate($delegate);
     }
     $this->container = $parentContainer;
 }