There is some more initialization requirements for this to work. The simplest way I have found is to make it a "functional" test since we are relying on Propel functionality. You can still do lime unit tests. Here's one of my test files:
$app = 'admin';
include(dirname(__FILE__).'/../bootstrap/functional.php');
// to get configurations set up, even though we don't use the browser$b = new sfTestBrowser();
$b->initialize();
$t = $b->test();
$t->plan = 4;
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
try {$ra = RoomAssignmentPeer::getCurrentActiveFor(12345);
$t->fail('incomplete id, should throw exception');
} catch (rciException $ex){$t->pass('incomplete id');
}// ...// 3 more tests// ...
Add the lines from this snippet, and get the connection in the right way:
<pre class="php">
$con = $databaseManager->getDatabase('propel')->getConnection();
</pre>
You need to create an account or log in to post a comment or rate this snippet.
Comments on this snippet
There is some more initialization requirements for this to work. The simplest way I have found is to make it a "functional" test since we are relying on Propel functionality. You can still do lime unit tests. Here's one of my test files:
To get my batch file connected to the database using a raw SQL query, I had to just
generate the skeleton:
<pre> $ symfony batch default batchFileName frontend prod </pre>
Add the lines from this snippet, and get the connection in the right way: <pre class="php"> $con = $databaseManager->getDatabase('propel')->getConnection(); </pre>