public function testSimpleRandomWithIniValue()
 {
     //TODO FIX -> add properties file, refresh container!
     $this->container->close();
     $container = new AnnotationContainer('test/src', __DIR__ . '/config/annotation.ini');
     $simpleRandom = $container->getBean('prototypeSimpleRandomIniValue');
     $this->assertInstanceOf('\\Annotation\\SimpleRandomIniValue', $simpleRandom);
     $this->assertEquals(99, $simpleRandom->getRandomId(), 'Random id not 99');
     $container->close();
     $this->assertNull($simpleRandom->getRandomId(), 'Random id not null');
     $this->container = null;
 }
 public function testGetBeanOnSameObjectWithDifferentScopeOnClose()
 {
     $a = $this->container->getBean('prototypeMethod');
     $b = $this->container->getBean('singletonMethod');
     $c = $this->container->getBean('sessionMethod');
     $this->assertEquals(1, $a->getId(), 'Init a value not 1');
     $this->assertEquals(1, $b->getId(), 'Init b value not 1');
     $this->assertEquals(1, $c->getId(), 'Init c value not 1');
     $this->container->close();
     $this->assertEquals(0, $a->getId(), 'Destroy a value not 0');
     $this->assertEquals(0, $b->getId(), 'Destroy b value not 0');
     $this->assertEquals(0, $c->getId(), 'Destroy c value not 0');
     $this->container = null;
 }
 public function testNewContainerWithSameContextClose()
 {
     $alternativeContainer = new XmlContainer(__DIR__ . self::A);
     $singletonB = $alternativeContainer->getBean('singletonRandom');
     $singletonA = $this->container->getBean('singletonRandom');
     $this->assertSame($singletonA, $singletonB, 'Different container, same instance');
     $this->assertEquals($singletonA->getRandomId(), $singletonB->getRandomId(), 'Id are equals!');
     $alternativeContainer->close();
     try {
         $this->container->close();
         $this->fail('Exception not throw');
     } catch (OvoContainerException $e) {
         $this->assertTrue(true);
         $this->container = null;
     }
 }
 public function testRewriteSystemPropertiesFromExternalIniFileCalledFromConstruct()
 {
     $this->container->close();
     $this->container = new XmlContainer(__DIR__ . self::CONFIG_FILE, __DIR__ . '/config/rewrite.ini');
     $this->assertEquals('false', PropertiesLoader::getProperty('ovo.bean.lazy.init'), 'init-on-boot is not false');
 }
 public function tearDown()
 {
     if (is_object($this->container)) {
         $this->container->close();
     }
 }
 public function tearDown()
 {
     if ($this->container instanceof OvoContainer) {
         $this->container->close();
     }
 }
Пример #7
0
 /**
  * Method to shutdown the container
  *
  * @return void
  */
 public function close()
 {
     PropertiesLoader::destroy();
     $this->ovoContainer->close();
 }