public function testCircularDependencyWithReleaseOfLockBeansDefinedAsSsession()
 {
     $this->container = new XmlContainer(__DIR__ . self::CONFIG_FILE_NOT_INIT);
     $b = $this->container->getBean('bbbb');
     $a = $b->getA();
     $aa = $a->getB()->getA();
     $bb = $a->getB()->getA()->getB();
     $this->assertInstanceOf('Circular\\B', $b, 'Not valid instance');
     $this->assertInstanceOf('Circular\\A', $a, 'Not valid instance');
     $this->assertSame($b, $a->getB(), 'Not same instance');
     $this->assertSame($a, $aa, 'Not same instance');
     $this->assertSame($b, $bb, 'Not same instance');
 }
 public function testSimpleRandomWithWithDependencyOnIniValueIsNull()
 {
     $simpleRandom = $this->container->getBean('prototypeSimpleRandomIniValue');
     $this->assertInstanceOf('\\Annotation\\SimpleRandomIniValue', $simpleRandom);
     $this->assertEquals('', $simpleRandom->getRandomId(), 'Random id not NUll');
     $this->assertInstanceOf('\\Annotation\\Name', $simpleRandom->getName(), 'Not a Name instance');
 }
 public function testGetBeanOnSameObjectWithDifferentScopeOnRemove()
 {
     $a = $this->container->getBean('sessionMethod');
     $b = $this->container->getBean('singletonMethod');
     $this->assertEquals(1, $b->getId(), 'Init b value not 1');
     $this->assertEquals(1, $a->getId(), 'Init a value not 1');
     $this->container->destroyBean('singletonMethod');
     $this->container->destroyBean('sessionMethod');
     $this->assertEquals(0, $b->getId(), 'Destroy b value not 0');
     $this->assertEquals(0, $a->getId(), 'Destroy a value not 0');
 }
 public function testGetBeanWithArrayAsPropertyAndConstruct()
 {
     $bean = $this->container->getBean('listConstructProperty');
     $array = $bean->getList();
     $city = $bean->getCity();
     $this->assertInstanceOf('SimpleListConstruct', $bean, 'Not a SimpleList Instance');
     $this->assertTrue(is_array($array));
     $this->assertEquals('Maradona', $array[0], 'Maradona found');
     $this->assertEquals('Ronaldo', $array[1], 'Ronaldo found');
     $this->assertTrue(is_array($city));
     $this->assertEquals('New York', $city[0], 'New York found');
     $this->assertEquals('Maputo', $city[1], 'Maputo found');
 }
 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 testBeanRewriteTemplateBehavior()
 {
     $template = $this->container->getBean('template');
     $this->assertInstanceOf('Template', $template, 'template not instance of Template');
     $this->assertEquals('init', $template->getMethod(), 'Wrong init method ' . $template->getMethod());
 }
Example #8
0
 /**
  * Method to shutdown the container
  *
  * @return void
  */
 public function close()
 {
     PropertiesLoader::destroy();
     $this->ovoContainer->close();
 }