$builder->setParameter('class', 'BazClass'); $t->ok($builder->getService('foo2')->configured, '->createService() calls the configurator'); $builder->register('baz', 'BazClass'); $builder->register('foo3', 'FooClass')->setConfigurator(array(new sfServiceReference('baz'), 'configure')); $t->ok($builder->getService('foo3')->configured, '->createService() calls the configurator'); $builder->register('foo4', 'FooClass')->setConfigurator('foo'); try { $builder->getService('foo4'); $t->fail('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); } catch (InvalidArgumentException $e) { $t->pass('->createService() throws an InvalidArgumentException if the configure callable is not a valid callable'); } // ->resolveValue() $t->diag('->resolveValue()'); $builder = new sfServiceContainerBuilder(); $t->is($builder->resolveValue('foo'), 'foo', '->resolveValue() returns its argument unmodified if no placeholders are found'); $builder->setParameter('foo', 'bar'); $t->is($builder->resolveValue('I\'m a %foo%'), 'I\'m a bar', '->resolveValue() replaces placeholders by their values'); $builder->setParameter('foo', true); $t->ok($builder->resolveValue('%foo%') === true, '->resolveValue() replaces arguments that are just a placeholder by their value without casting them to strings'); $builder->setParameter('foo', 'bar'); $t->is($builder->resolveValue(array('%foo%' => '%foo%')), array('bar' => 'bar'), '->resolveValue() replaces placeholders in keys and values of arrays'); $t->is($builder->resolveValue(array('%foo%' => array('%foo%' => array('%foo%' => '%foo%')))), array('bar' => array('bar' => array('bar' => 'bar'))), '->resolveValue() replaces placeholders in nested arrays'); $t->is($builder->resolveValue('I\'m a %%foo%%'), 'I\'m a %foo%', '->resolveValue() supports % escaping by doubling it'); $t->is($builder->resolveValue('I\'m a %foo% %%foo %foo%'), 'I\'m a bar %foo bar', '->resolveValue() supports % escaping by doubling it'); try { $builder->resolveValue('%foobar%'); $t->fail('->resolveValue() throws a InvalidArgumentException if a placeholder references a non-existant parameter'); } catch (InvalidArgumentException $e) { $t->pass('->resolveValue() throws a InvalidArgumentException if a placeholder references a non-existant parameter'); }