Maybe at this point you've already solved your problem, but I'll post
a solution anyway for future references, other people references.
You can create an instance of sfContext in your unit bootstraping
script, something like this:
$projectConfig = new sfProjectConfiguration($path);
$appConfig = $projectConfig->getApplicationConfiguration('frontend',
Where $path is the path to your test project's config dir. After this,
you can use the context anywhere.
I don't know if it's a good practice to make the model dependent of
the context, maybe somebody more mvc-experienced could give us a hand.
juro ha escrito:
> I have extended the save() method of a few of my models like this
> public function save(Doctrine_Connection $conn = null)
> $user = sfContext::getInstance()->getUser()->getGuardUser();
> $tag = $this->getTag();
> if ($this->getTimein() != '' && $this->getTimeout() == '')
> elseif ($this->getTimein() != '' && $this->getTimeout() != '')
> to store the user's id, when the object is saved.
> When I test this, I get an error that there is no sfContext - which I
> understand, as this is not run in the brower.
> How can I run unit tests on this anyway?
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to email@example.com
To unsubscribe from this group, send email to
For more options, visit this group at