Hi juro! 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', 'test', true); sfContext::createInstance($appConfig); 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. HTH. Greetings! juro ha escrito: > Hi, > 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(); > > if($this->isNew()) > { > $this->setCreatedBy($user); > } > $this->setUpdatedBy($user); > > $tag = $this->getTag(); > if ($this->getTimein() != '' && $this->getTimeout() == '') > { > $this->setActive(1); > $tag->setActive(1); > } > elseif ($this->getTimein() != '' && $this->getTimeout() != '') > { > $this->setActive(0); > $tag->setActive(0); > } > $tag->save(); > > parent::save(); > } > > 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? > > juro --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---