public function doLoad($template, $renderer = 'php') { $this->loaded = true; if ('invalidBool' === $template) { return false; } elseif ('invalidInt' === $template) { return 0; } elseif ('invalidString' === $template) { return ''; } return 'valid'; } } } $context = createContext(); $view = new sfTemplatingComponentView($context, 'module', 'action', ''); $loader = new myLoader($view, $context, array('key' => 'value')); $t->diag('->configure()'); $t->is($loader->configured, true, '->configure() is executed in the constructor'); $t->diag('->getParameter()'); $t->is($loader->getParameter('key'), 'value', '->getParameter() returns the value of the specified parameter'); $t->is($loader->getParameter('unknown-key'), null, '->getParameter() returns null if the specified parameter does not exist'); $t->is($loader->getParameter('unknown-key', 'default'), 'default', '->getParameter() returns the specified default value'); $t->diag('->doLoad()'); $t->is($loader->loaded, false, '->doLoad() is not executed in the constructor'); $loader->load('test'); $t->is($loader->loaded, true, '->doLoad() is executed in the load() method'); $t->ok($loader->load('invalidBool') === false, '->laod() returns false if the doLoad() method returns false'); $t->ok($loader->load('invalidInt') === false, '->laod() returns false if the doLoad() method returns 0'); $t->ok($loader->load('invalidString') === false, '->laod() returns false if the doLoad() method returns empty string'); $t->ok($loader->load('valid') === 'valid', '->laod() returns true if the doLoad() method returns string');