$t->diag('__construct()'); $pathPattern = $fixturesPath.'/templates/%name%.%renderer%'; $path = $fixturesPath.'/templates'; $loader = new ProjectTemplateLoader($pathPattern); $t->is($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes a path as its second argument'); $loader = new ProjectTemplateLoader(array($pathPattern)); $t->is($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes an array of paths as its second argument'); // ->load() $t->diag('->load()'); $loader = new ProjectTemplateLoader($pathPattern); $storage = $loader->load($path.'/foo.php'); $t->ok($storage instanceof FileStorage, '->load() returns a FileStorage if you pass an absolute path'); $t->is((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the passed absolute path'); $t->ok($loader->load('bar') === false, '->load() returns false if the template is not found'); $storage = $loader->load('foo'); $t->ok($storage instanceof FileStorage, '->load() returns a FileStorage if you pass a relative template that exists'); $t->is((string) $storage, $path.'/foo.php', '->load() returns a FileStorage pointing to the absolute path of the template'); $loader = new ProjectTemplateLoader($pathPattern); $loader->setDebugger($debugger = new ProjectTemplateDebugger()); $t->ok($loader->load('foo', array('renderer' => 'xml')) === false, '->load() returns false if the template does not exists for the given renderer'); $t->ok($debugger->hasMessage('Failed loading template'), '->load() logs a "Failed loading template" message if the template is not found'); $loader = new ProjectTemplateLoader(array($fixturesPath.'/null/%name%', $pathPattern)); $loader->setDebugger($debugger = new ProjectTemplateDebugger()); $loader->load('foo'); $t->ok($debugger->hasMessage('Loaded template file'), '->load() logs a "Loaded template file" message if the template is found');