예제 #1
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]))
예제 #2
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]));
예제 #3
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));
예제 #4
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))
예제 #5
0
    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));
예제 #6
0
    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))
예제 #7
0
    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.'
        );
예제 #8
0
    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.')