mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
28 lines
901 B
PHP
28 lines
901 B
PHP
<?php
|
|
|
|
use SilverStripe\ORM\DB;
|
|
/**
|
|
* @package framework
|
|
* @subpackage tests
|
|
*/
|
|
class DBTest extends SapphireTest {
|
|
|
|
function testValidAlternativeDatabaseName() {
|
|
|
|
$prefix = defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : 'ss_';
|
|
|
|
Config::inst()->update('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('Director', 'environment_type', 'live');
|
|
$this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
|
|
|
|
Config::inst()->update('Director', 'environment_type', 'dev');
|
|
}
|
|
|
|
}
|