True, I am testing the model Party, where I override the save() method
to insert the userid into created_by and updated_by like this:

public function save(Doctrine_Connection $conn = null)
  {
    $user = sfContext::getInstance()->getUser()->getGuardUser();

    if($this->isNew())
    {
     $this->setCreatedBy($user);
    }

    $this->setUpdatedBy($user);

    parent::save();
  }

With this in place, which works great by the way, how can I unit test
this class?

juro


On Feb 1, 2:04 pm, Thomas Rabaix <[email protected]> wrote:
> Hello,
>
> In one of your class you are doing a sfContext::getInstance(), which does
> not exist. To avoid this error can test if a context exists :
> sfContext::hasIntance().
>
>
>
> On Sun, Feb 1, 2009 at 10:57 AM, juro <[email protected]> wrote:
>
> > Hi,
> > my unit tests depend on a database connection, which I create using
>
> > include(dirname(__FILE__).'/unit.php');
> > $configuration = ProjectConfiguration::getApplicationConfiguration
> > ('reception', 'test', true);
> > new sfDatabaseManager($configuration);
> > Doctrine::loadData(sfConfig::get('sf_test_dir').'/fixtures');
>
> > When I run any test, I get the error message:
>
> > The "default" context does not exist
>
> > Does anyone know where this comes from?
>
> > juro
>
> --
> Thomas Rabaix
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to