silverstripe-framework/tests/model/DBTest.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

32 lines
1.0 KiB
PHP

<?php
use SilverStripe\ORM\DB;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\SapphireTest;
/**
* @package framework
* @subpackage tests
*/
class DBTest extends SapphireTest {
function testValidAlternativeDatabaseName() {
$prefix = defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : 'ss_';
Config::inst()->update('SilverStripe\\Control\\Director', 'environment_type', 'dev');
$this->assertTrue(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
$this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb12345678'));
$this->assertFalse(DB::valid_alternative_database_name('tmpdb1234567'));
$this->assertFalse(DB::valid_alternative_database_name('random'));
$this->assertFalse(DB::valid_alternative_database_name(''));
Config::inst()->update('SilverStripe\\Control\\Director', 'environment_type', 'live');
$this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
Config::inst()->update('SilverStripe\\Control\\Director', 'environment_type', 'dev');
}
}