If you are asking how to write a unit test for a task, than you need to initialize the configuration first:
$configuration = ProjectConfiguration::hasActive() ? ProjectConfiguration::getActive() : new ProjectConfiguration(realpath($_test_dir . '/..'));
Later, since tasks are just classes, you can easily initialize and test them:
$task = new myTask($configuration->getEventDispatcher(), new sfFormatter()); $task->run($argumentsArray, $optionsArray);
However, I believe that it is better to put the logic of the task in a separate class and use them in the execute () method of the task. It is even easier to verify this way.
Jakub zalas
source share