def testLoad(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.load """ loader = LoaderInterfaceMock1() resolver = LoaderResolver([loader]) loader = DelegatingLoader(resolver) loader.load('foo')
def testLoad(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.load """ loader = LoaderInterfaceMock1(); resolver = LoaderResolver([loader]); loader = DelegatingLoader(resolver); loader.load('foo');
def __init__(self, parser, resolver): """Constructor. @param: ControllerNameParser parser A ControllerNameParser instance @param: LoggerInterface logger A LoggerInterface instance @param: LoaderResolverInterface resolver A LoaderResolverInterface instance """ assert isinstance(resolver, LoaderResolverInterface) assert isinstance(parser, ControllerNameParser) self._parser = parser BaseDelegatingLoader.__init__(self, resolver)
def testSupports(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.supports """ loader1 = LoaderInterfaceMock1(); loader = DelegatingLoader(LoaderResolver([loader1])); self.assertTrue(loader.supports('foo.xml'), '->supports() returns True if the resource is loadable'); loader1 = LoaderInterfaceMock2(); loader = DelegatingLoader(LoaderResolver([loader1])); self.assertFalse(loader.supports('foo.foo'), '->supports() returns False if the resource is not loadable');
def testGetSetResolver(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.getResolver @covers Symfony\Component\Config\Loader\DelegatingLoader.setResolver """ resolver = LoaderResolver(); loader = DelegatingLoader(resolver); self.assertEqual(resolver, loader.getResolver(), '->getResolver() gets the resolver loader'); resolver = LoaderResolver(); loader.setResolver(resolver); self.assertEqual(resolver, loader.getResolver(), '->setResolver() sets the resolver loader');
def testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded(self): """@expectedException Symfony\Component\Config\Exception\FileLoaderLoadException """ try: loader = LoaderInterfaceMock2(); resolver = LoaderResolver([loader]); loader = DelegatingLoader(resolver); loader.load('foo'); self.fail() except Exception as e: self.assertTrue(isinstance(e, FileLoaderLoadException));
def testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded(self): """@expectedException Symfony\Component\Config\Exception\FileLoaderLoadException """ try: loader = LoaderInterfaceMock2() resolver = LoaderResolver([loader]) loader = DelegatingLoader(resolver) loader.load('foo') self.fail() except Exception as e: self.assertTrue(isinstance(e, FileLoaderLoadException))
def _getContainerLoader(self, container): assert isinstance(container, ContainerInterface) locator = FileLocator(self) resolver = LoaderResolver([ IniFileLoader(container, locator), JsonFileLoader(container, locator), YamlFileLoader(container, locator), ]) return DelegatingLoader(resolver)
def testConstructor(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.__construct """ resolver = LoaderResolver() loader = DelegatingLoader(resolver) self.assertTrue( True, '__init__() takes a loader resolver as its first argument')
def testGetSetResolver(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.getResolver @covers Symfony\Component\Config\Loader\DelegatingLoader.setResolver """ resolver = LoaderResolver() loader = DelegatingLoader(resolver) self.assertEqual(resolver, loader.getResolver(), '->getResolver() gets the resolver loader') resolver = LoaderResolver() loader.setResolver(resolver) self.assertEqual(resolver, loader.getResolver(), '->setResolver() sets the resolver loader')
def testSupports(self): """ @covers Symfony\Component\Config\Loader\DelegatingLoader.supports """ loader1 = LoaderInterfaceMock1() loader = DelegatingLoader(LoaderResolver([loader1])) self.assertTrue( loader.supports('foo.xml'), '->supports() returns True if the resource is loadable') loader1 = LoaderInterfaceMock2() loader = DelegatingLoader(LoaderResolver([loader1])) self.assertFalse( loader.supports('foo.foo'), '->supports() returns False if the resource is not loadable')
def load(self, resource, resourceType=None): """Loads a resource. @param: mixed resource A resource @param: string resourceType The resource type @return: RouteCollection A RouteCollection instance """ collection = BaseDelegatingLoader.load(self, resource, resourceType) for route in collection.all().values(): controller = route.getDefault('_controller') if (controller): try: controller = self._parser.parse(controller) except Exception: # unable to optimize unknown notation pass route.setDefault('_controller', controller) return collection