Hi,
On 03/04/2010 09:16 AM, Alexandru-Emil Lupu wrote:
> HI!
> Well is a Unit after all.

The reason I asked was because tasks like actions connect to a lot of
different symfony services (templating , the dispatcher , the mailer
etc). What I ended up doing was the following:

<?php

include(dirname(__FILE__).'/../../bootstrap/doctrine.php');
class ofSimpleLogger {
  public $msgs = array();
  public function log(sfEvent $event) {
    $params = $event->getParameters();
    $this->msgs[]= $params[0];
  }
}

$plan = 6;
$t = new lime_test($plan);


$formatter = new sfFormatter(80);
$dispatcher = new sfEventDispatcher;
$logger = new ofSimpleLogger;
$dispatcher->connect('command.log', array($logger, "log"));

$task = new events_runTask($dispatcher, $formatter);
$task->setConfiguration($configuration);

I also created a method doTestRun in my task that called execute() on
the Task, but you could also try doing this by calling
$task->run($arguments, $options);

Regards,
Tarjei

> Alecs
>
> On Thu, Mar 4, 2010 at 10:07 AM, Tarjei Huse <tar...@scanmine.com
> <mailto:tar...@scanmine.com>> wrote:
>
>     Hi,
>
>     I might have missed something, but does symfony have a way to write
>     tests for tasks?
>
>     I got a task I would like to have test coverage for and the best way
>     seems to be do some kind of functional testing on it.
>
>     Kind regards,
>     Tarjei
>
>     --
>     Regards / Med vennlig hilsen
>     Tarjei Huse
>     Mobil: 920 63 413
>
>     --
>     If you want to report a vulnerability issue on symfony, please
>     send it to security at symfony-project.com
>     <http://symfony-project.com>
>
>     You received this message because you are subscribed to the Google
>     Groups "symfony users" group.
>     To post to this group, send email to
>     symfony-users@googlegroups.com <mailto:symfony-users@googlegroups.com>
>     To unsubscribe from this group, send email to
>     symfony-users+unsubscr...@googlegroups.com
>     <mailto:symfony-users%2bunsubscr...@googlegroups.com>
>     For more options, visit this group at
>     http://groups.google.com/group/symfony-users?hl=en
>
>
>
>
> -- 
> Have a nice day!
>
> Alecs
> Certified ScrumMaster
>
> There are no cannibals alive! I have ate the last one yesterday ...  
> I am on web:  http://www.alecslupu.ro/
> I am on twitter: http://twitter.com/alecslupu
> I am on linkedIn: http://www.linkedin.com/in/alecslupu
> Tel: (+4)0722 621 280
>
> -- 
> If you want to report a vulnerability issue on symfony, please send it
> to security at symfony-project.com
>  
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en


-- 
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to