Permalink
Browse files

BUGFIX Enforcing creation of temp database in SapphireTest->setUp() t…

…o avoid writing to production databases. This check should only kick in for single test case runs, as the temp database connection should be set in a dev/tests/all run after the first db-related test anyway. (see #5034) (from r99342)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102462 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent a09263e commit 43ff00ebd60adde181ef70cbd8d1a218c9a53fd9 @chillu chillu committed Apr 12, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 dev/SapphireTest.php
@@ -111,7 +111,7 @@ function setUp() {
$fixtureFile = eval("return {$className}::\$fixture_file;");
// Set up fixture
- if($fixtureFile || $this->usesDatabase) {
+ if($fixtureFile || $this->usesDatabase || !self::using_temp_db()) {
if(substr(DB::getConn()->currentDatabase(),0,5) != 'tmpdb') {
//echo "Re-creating temp database... ";
self::create_temp_db();

3 comments on commit 43ff00e

@ntd
ntd commented on 43ff00e May 18, 2016 edited

The problem is when you have tests that do not use the database, then I suppose self::using_temp_db() will return false. In other words this commit makes usesDatabase effectively useless because the database is always created when you do not require it.

@dhensby
Member

I think this should be if(($fixtureFile || $this->usesDatabase) && !self::using_temp_db())

If there's a fixture file or you declare you need a database and there's no temp db active....

@dhensby
Member

Enforcing creation of temp database in SapphireTest->setUp() to avoid writing to production databases

uh oh, who's running test suites on production environments :/

Please sign in to comment.