Enhanced DBTest to respect SS_DATABASE_PREFIX if set

This commit is contained in:
Stephan Bauer 2014-04-24 23:32:23 +02:00
parent 1dcaf36c9b
commit 81210bb6fe

View File

@ -6,15 +6,18 @@
class DBTest extends SapphireTest { class DBTest extends SapphireTest {
function testValidAlternativeDatabaseName() { function testValidAlternativeDatabaseName() {
$prefix = defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : 'ss_';
Config::inst()->update('Director', 'environment_type', 'dev'); Config::inst()->update('Director', 'environment_type', 'dev');
$this->assertTrue(DB::valid_alternative_database_name('ss_tmpdb1234567')); $this->assertTrue(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
$this->assertFalse(DB::valid_alternative_database_name('ss_tmpdb12345678')); $this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb12345678'));
$this->assertFalse(DB::valid_alternative_database_name('tmpdb1234567')); $this->assertFalse(DB::valid_alternative_database_name('tmpdb1234567'));
$this->assertFalse(DB::valid_alternative_database_name('random')); $this->assertFalse(DB::valid_alternative_database_name('random'));
$this->assertFalse(DB::valid_alternative_database_name('')); $this->assertFalse(DB::valid_alternative_database_name(''));
Config::inst()->update('Director', 'environment_type', 'live'); Config::inst()->update('Director', 'environment_type', 'live');
$this->assertFalse(DB::valid_alternative_database_name('ss_tmpdb1234567')); $this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
Config::inst()->update('Director', 'environment_type', 'dev'); Config::inst()->update('Director', 'environment_type', 'dev');
} }