Autoloading sfDoctrin in Symfony Testing Framework
Well.. The unit testing part in symfony documentation is bit disappointing to me. I expected more unit test practice to come, but it spent most of time to explain functional testing. It is still vague how to write a unit test in symfony after reading the part. Actually I am still skeptical about browser functional testing. Maybe because I am not writing professional massive web site, though.
Anyway, like I said, I am interested in unit testing, particularly of a model. My model is based on the sfDoctrine plugin, and it was not easy to turn the autoloading on. So here is how I set the sfDoctrine into the autoloading list.
<?
include(dirname(__FILE__).'/../bootstrap/unit.php');
require_once($sf_symfony_lib_dir.'/util/sfCore.class.php');
sfCore::initSimpleAutoload(array(
SF_ROOT_DIR."/lib/model",
SF_ROOT_DIR."/plugins/sfDoctrinePlugin",
$sf_symfony_lib_dir,
));
define('SF_APP', 'yourapp');
#define('SF_ENVIRONMENT', 'test');
#define('SF_DEBUG', false);
require_once(SF_ROOT_DIR.'/apps/track/config/config.php');
$data = new sfDatabaseManager();
$data->initialize();
$model = new YourModel();
I’m using symfony 1.0.5 and sfDoctrine is checked out a couple of weeks ago.
July 30th, 2007 at 12:00 am
[…] After made autoloading sfDoctrine available last week, I was thinking accessing database or pretending it (for test purpose) is surely easy. However, it […]