A typical Developer Blog
by Gordon Franke
Icon

How can i check the count of database queries in my unit test?

1
2
3
$manager    = new sfDatabaseManager($configuration);
$connection = $manager->getDatabase('doctrine')->getDoctrineConnection();
$connection->count();

How can i unit test my own User class functions?

Use this in your testcode to create the user object

1
2
3
4
5
6
7
8
$_SERVER['session_id'] = 'test';
 
$dispatcher = new sfEventDispatcher();
$sessionPath = sfToolkit::getTmpDir().'/sessions_'.rand(11111, 99999);
$storage = new sfSessionTestStorage(array('session_path' => $sessionPath));
 
$myUser = new myUser($dispatcher, $storage);
$myUser->setAttribute('user_id', 1, 'sfGuardSecurityUser');