$t->is($loader->container, $container, '__construct() takes a container builder instance as its first argument'); // ->setServiceContainer() $t->diag('->setServiceContainer()'); $loader = new ProjectLoader(); $loader->setServiceContainer($container = new sfServiceContainerBuilder()); $t->is($loader->container, $container, '->setServiceContainer() sets the container builder attached to this loader'); // ->load() $t->diag('->load()'); $loader = new ProjectLoader(); try { $loader->load('foo'); $t->fail('->load() throws a LogicException if no container is attached to the loader'); } catch (LogicException $e) { $t->pass('->load() throws a LogicException if no container is attached to the loader'); } $loader->setServiceContainer($container = new sfServiceContainerBuilder(array('bar' => 'foo'))); $loader->load(array(array(), array('foo' => 'bar'))); $t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'bar'), '->load() merges current parameters with the loaded ones'); $loader->setServiceContainer($container = new sfServiceContainerBuilder(array('bar' => 'foo', 'foo' => 'baz'))); $loader->load(array(array(), array('foo' => 'bar'))); $t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'baz'), '->load() does not change the already defined parameters'); $loader->setServiceContainer($container = new sfServiceContainerBuilder(array('bar' => 'foo'))); $loader->load(array(array(), array('foo' => '%bar%'))); $t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo'), '->load() evaluates the values of the parameters towards already defined ones'); $loader->setServiceContainer($container = new sfServiceContainerBuilder(array('bar' => 'foo'))); $loader->load(array(array(), array('foo' => '%bar%', 'baz' => '%foo%'))); $t->is($container->getParameters(), array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), '->load() evaluates the values of the parameters towards already defined ones'); $loader->setServiceContainer($container = new sfServiceContainerBuilder()); $container->register('foo', 'FooClass'); $container->register('bar', 'BarClass'); $loader->load(array(array('baz' => new sfServiceDefinition('BazClass'), 'alias_for_foo' => 'foo'), array()));