How i can write an unit test, for my Task (sfBaseTask) ?
+1
A:
If you're asking how to write a unit test for a task than firstly you need to initialize configuration:
$configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir . ‘/..’));
Later, as tasks are just classes, you can easily initialize them and test:
$task = new myTask($configuration->getEventDispatcher(), new sfFormatter());
$task->run($argumentsArray, $optionsArray));
However, I think it's better to put task logic into separate class(es) and use them in task's execute() method. It's even easier to test this way.
kuba
2010-07-24 15:22:40