Browse Source

use putenv to define defaults

if defined in the phpunit file, it's not possible to override them like
so:

	db_class=x; phpunit...

as phpunit will overwrite the existing environment variables with the
xml-defined settings
AD7six 12 years ago
parent
commit
7005190c16
1 changed files with 6 additions and 0 deletions
  1. 6 0
      tests/init.php

+ 6 - 0
tests/init.php

@@ -97,6 +97,12 @@ Cache::config([
 	]
 ]);
 
+// Ensure default test connection is defined
+if (!getenv('db_class')) {
+	putenv('db_class=Cake\Database\Driver\Sqlite');
+	putenv('db_dsn=sqlite::memory:');
+}
+
 ConnectionManager::config('test', [
 	'className' => 'Cake\Database\Connection',
 	'driver' => getenv('db_class'),