PHPUnit does things with variables in the GLOBAL space. e.g. $db is there and has a PDO in it. If you don't need $db again after you've set it as the default for Zend_Db_Table then unset it and you'll be ok.
> Zend_Db_Table::setDefaultAdapter($db); > unset($db); > I think PHPUnit copies globals by serializing them, before each test care then restores it after. -- /James On Thu, Apr 24, 2008 at 10:09 PM, <[EMAIL PROTECTED]> wrote: > Hey guys, I'm trying to run some PHPUnit tests locally on my model > classes, against a local test database. I'm using the following simple > test-running script to set up the db connection and then run tests: > > > <?php > set_include_path( > realpath('../../../library') . PATH_SEPARATOR . > realpath('../') . PATH_SEPARATOR . > get_include_path()); > > require_once 'Zend/Db.php'; > require_once 'Zend/Db/Table.php'; > > $db = Zend_DB::factory('PDO_MYSQL', array( > 'host' => 'localhost', > 'username' => 'root', > 'password' => 'ingirum68', > 'dbname' => 'vzwprint')); > $db->query("SET NAMES 'utf8'"); > Zend_Db_Table::setDefaultAdapter($db); > > $tests = explode(',', $_GET['tests']); > foreach ($tests as $class) require_once "$class.php"; > > require_once 'PHPUnit/TextUI/TestRunner.php'; > $suite = new PHPUnit_Framework_TestSuite(); > foreach ($tests as $class) $suite->addTestSuite($class); > echo '<pre>'; > PHPUnit_TextUI_TestRunner::run($suite); > > > Pretty straightforward... right now I'm just pointing it at an empty > TestCase class just to see if the basic setup is working, and here's what > I'm getting for output: > > > PHPUnit 3.2.9 by Sebastian Bergmann. > > E > > Time: 0 seconds > > There was 1 error: > > 1) Warning(PHPUnit_Framework_Warning) > PDOException: You cannot serialize or unserialize PDO instances > C:\workspace\vzwprint\application\default\tests\run-tests.php:25 > > FAILURES! > Tests: 1, Errors: 1. > > > Yeah, so thanks PHPUnit and/or PDO and/or ZF, but I never /asked/ to > serialize any PDO instances, so if you would mind just not doing that, > that would be great. > > I'm not even loading up any of my own model code at this point. Anyone > got some idea what the hell is going on here? > >