I bumped into that same problem, and solved it somewhat differently.

Maybe nice to have as an alternative, although both methods are kind
of a hack.

[CODE]

class FakeUser
{
  public function hasCredential($credential)
  {
    return ($credential ==
sfGuardPermission::SOME_PERMISSION_CONSTANT);
  }

  public function setFlash()
  {
    throw Exception('model contains setFlash, this should moved to a
controller!!!');
  }

  public function shutdown()
  {
  }

}


$fakeUser = new FakeUser();
sfContext::getInstance()->set('user', $fakeUser);

[/CODE]



On 23 jan, 21:59, isleshocky77 <[email protected]> wrote:
> FIgured I would update this for anyone in the future trying to do this
> same thing.  I got this to work by adding this to the top of my unit
> test file.
>
> [CODE]
> $_SERVER['session_id'] = 'test';
>
> $dispatcher = new sfEventDispatcher();
> $sessionPath = sfToolkit::getTmpDir().'/sessions_'.rand(11111, 99999);
> $storage = new sfSessionTestStorage(array('session_path' =>
> $sessionPath));
>
> $user_1 = new sfUser($dispatcher, $storage);
> [/CODE]
>
> --
> Stephen Ostrow <[email protected]>
>
> On Jan 15, 6:50 pm, isleshocky77 <[email protected]> wrote:
>
> > One of my model methods takes an sfUser as a parameter so I need to
> > create and user an sfUser in my unit testing.  What is the best way of
> > doing this?  I've copied some of the code out of the symfony's unit
> > test for sfUser, but I can't get it to work properly. I get an error
> > saying
>
> > Fatal error: Uncaught exception 'sfException' with message 'Call to
> > undefined method sfUser::getTable.' in /srv/symfony/branches/1.2/lib/
> > user/sfUser.class.php:287
>
> > Any help would be appreciated.
>
> > -- Stephen Ostrow <[email protected]>

--~--~---------~--~----~------------~-------~--~----~
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