Permalink
Browse files

DSN-Support

  • Loading branch information...
1 parent c72acfe commit 12ffae850f41c517e481900c916ff60cc4b311e8 @robo47 robo47 committed Feb 3, 2012
Showing with 25 additions and 8 deletions.
  1. +25 −8 test/bootstrap/sfPluginTestBootstrap.class.php
@@ -150,18 +150,35 @@ public function bootstrap($app = 'frontend', $debug = true)
require_once dirname(__FILE__).'/../fixtures/project/config/ProjectConfiguration.class.php';
$dbms = 'sqlite';
- if (isset($_SERVER['DB'])) {
+ if (isset($_SERVER['DB']))
+ {
$dbms = strtolower($_SERVER['DB']);
}
+ if (!isset($_SERVER['DSN']))
+ {
+ // Check if configuration for dbms exists
+ if (!file_exists(dirname(__FILE__).'/../fixtures/project/config/database-' . $dbms . '.yml'))
+ {
+ throw new Exception('Didnt find database-'.$dbms. 'yml for DBMS: "' . $dbms . '"');
+ }
- // Check if configuration for dbms exists
- if (!file_exists(dirname(__FILE__).'/../fixtures/project/config/database-' . $dbms . '.yml')) {
- throw new Exception('Didnt find database-'.$dbms. 'yml for DBMS: "' . $dbms . '"');
+ copy(dirname(__FILE__).'/../fixtures/project/config/database-' . $dbms . '.yml',
+ dirname(__FILE__).'/../fixtures/project/config/databases.yml');
+ }
+ else
+ {
+ $databaseConfiguration = <<<EOT
+all:
+ doctrine:
+ class: sfDoctrineDatabase
+ param:
+ dsn: {$_SERVER['DSN']}
+EOT;
+ file_put_contents(
+ dirname(__FILE__).'/../fixtures/project/config/databases.yml',
+ $databaseConfiguration
+ );
}
-
- copy(dirname(__FILE__).'/../fixtures/project/config/database-' . $dbms . '.yml',
- dirname(__FILE__).'/../fixtures/project/config/databases.yml');
-
$this->configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', $debug);
require_once $this->configuration->getSymfonyLibDir().'/vendor/lime/lime.php';

0 comments on commit 12ffae8

Please sign in to comment.