protected function setUp()
 {
     $this->object = new ApplicationStub_TestSuite('dev', true);
     $this->container = $this->object->getContainer();
     $this->container->define('event_emitter_service')->setClass('LazyEventEmitter');
     $this->container->define('sample_listener')->addNote('listener', array(array('sample.event', 'resolve')));
 }
 protected function setUp()
 {
     $this->container = new DependencyInjectionContainer();
     $this->container->define('WeakPunch');
     $this->container->define('StrongPunch');
     $this->manyMethods = array(array('fromNothing', array()), array('fromSomePunch', array(new ComponentArgument('WeakPunch'))), array('fromWeakPunch', array(new ComponentArgument('MediumPunch'))), array('fromPunches', array()));
     $this->noMethods = array();
     $this->against = new PunchReceiver();
     $this->adapter = $this->getMock('IComponentAdapter');
     $this->adapter->expects($this->any())->method('getInstance')->will($this->returnValue($this->against));
 }
 public function testLazyNotification()
 {
     // register main types as singletons
     $this->container->define('WeakPunch');
     $this->container->define('PunchListener');
     // create lazy callable
     $this->object->attach('event', array('lazy', 'PunchListener', 'handle'));
     // WeakPunch is singleton, requires instantiation through container,
     // which returns the same instance in LazyEventEmitter::getListeners('event')
     // as here:
     $punchable = $this->container->getInstanceOf('WeakPunch');
     $this->assertFalse($punchable->wasPunched);
     // let the wheel spinning
     $this->object->notify(new Event($this, 'event'));
     $this->assertTrue($punchable->wasPunched);
 }
 public function testMerge()
 {
     $this->object->define('MediumPunch');
     $punch = $this->object->getInstanceOf('MediumPunch');
     $this->assertThat($punch, $this->isInstanceOf('MediumPunch'));
     $container = new DependencyInjectionContainer();
     $container->define('MediumPunch')->setClass('StrongPunch');
     $punch = $container->getInstanceOf('MediumPunch');
     $this->assertThat($punch, $this->isInstanceOf('StrongPunch'));
     $this->object->merge($container);
     $punch = $this->object->getInstanceOf('MediumPunch');
     $this->assertThat($punch, $this->isInstanceOf('StrongPunch'));
 }
 protected function setUp()
 {
     $this->object = new WebApplicationStub_TestSuite('prod', false);
     $this->container = $this->object->getContainer();
     $this->container->define('event_emitter_service')->setClass('LazyEventEmitter');
     $this->container->define('sample_listener')->addNote('listener', array(array('sample.event', 'resolve')));
     $this->container->define('request_service')->setClass('Request');
     $this->container->define('controller_runner_service')->setClass('ControllerRunner');
     $this->container->define('router_service');
 }
 public function testCyclicInstantiation()
 {
     $this->setExpectedException('CyclicInstantiationException');
     $this->container->define('Cyclic');
     $instance = $this->container->getInstanceOf('Cyclic');
 }