def testProcess(self): container = ContainerBuilder() container.setAlias('bar', 'foo') defi = container\ .register('moo')\ .setArguments([Reference('bar')])\ self._process(container) arguments = defi.getArguments() self.assertEqual('foo', str(arguments[0]))
def testProcess(self): container = ContainerBuilder(); container.setAlias('bar', 'foo'); defi = container\ .register('moo')\ .setArguments([Reference('bar')])\ ; self._process(container); arguments = defi.getArguments(); self.assertEqual('foo', str(arguments[0]));
def testProcessWithInvalidAlias(self): """@expectedException InvalidArgumentException """ try: container = ContainerBuilder(); container.setAlias('a_alias', 'a'); self._process(container); self.fail() except Exception as e: self.assertTrue(isinstance(e, InvalidArgumentException));
def testProcessWithInvalidAlias(self): """@expectedException InvalidArgumentException """ try: container = ContainerBuilder() container.setAlias('a_alias', 'a') self._process(container) self.fail() except Exception as e: self.assertTrue(isinstance(e, InvalidArgumentException))
def testProcessWithAliases(self): """@expectedException RuntimeException """ try: container = ContainerBuilder(); container.register('a').addArgument(Reference('b')); container.setAlias('b', 'c'); container.setAlias('c', 'a'); self._process(container); self.fail() except Exception as e: self.assertTrue(isinstance(e, RuntimeException));
def testProcessWithAliases(self): """@expectedException RuntimeException """ try: container = ContainerBuilder() container.register('a').addArgument(Reference('b')) container.setAlias('b', 'c') container.setAlias('c', 'a') self._process(container) self.fail() except Exception as e: self.assertTrue(isinstance(e, RuntimeException))
def testProcess(self): container = ContainerBuilder(); container.register('a', 'object'); bDefinition = Definition('object'); bDefinition.setPublic(False); container.setDefinition('b', bDefinition); container.setAlias('a_alias', 'a'); container.setAlias('b_alias', 'b'); self._process(container); self.assertTrue(container.has('a'), '->process() does nothing to public definitions.'); self.assertTrue(container.hasAlias('a_alias')); self.assertFalse(container.has('b'), '->process() removes non-public definitions.'); self.assertTrue( container.has('b_alias') and not container.hasAlias('b_alias'), '->process() replaces alias to actual.' );
def testProcess(self): container = ContainerBuilder() container.register('a', 'object') bDefinition = Definition('object') bDefinition.setPublic(False) container.setDefinition('b', bDefinition) container.setAlias('a_alias', 'a') container.setAlias('b_alias', 'b') self._process(container) self.assertTrue(container.has('a'), '->process() does nothing to public definitions.') self.assertTrue(container.hasAlias('a_alias')) self.assertFalse(container.has('b'), '->process() removes non-public definitions.') self.assertTrue( container.has('b_alias') and not container.hasAlias('b_alias'), '->process() replaces alias to actual.')