mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-25 03:55:50 +02:00
Session is not initialized by the time we need to use the setting in DB::connect(). Cookie values get initialized automatically for each request. Tightened name format validation to ensure it can only be used for temporary databases, rather than switching the browser session to a different production database. Encrypting token for secure cookie usage. Added dev/generatesecuretoken to generate this token. Not storing in YML config directly because of web access issues.
36 lines
1005 B
PHP
36 lines
1005 B
PHP
<?php
|
|
/**
|
|
* @package framework
|
|
* @subpackage tests
|
|
*/
|
|
class DBTest extends SapphireTest {
|
|
|
|
protected $origEnvType;
|
|
|
|
function setUp() {
|
|
$this->origEnvType = Director::get_environment_type();
|
|
Director::set_environment_type('dev');
|
|
|
|
parent::setUp();
|
|
}
|
|
|
|
function tearDown() {
|
|
Director::set_environment_type($this->origEnvType);
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
function testValidAlternativeDatabaseName() {
|
|
$this->assertTrue(DB::valid_alternative_database_name('ss_tmpdb1234567'));
|
|
$this->assertFalse(DB::valid_alternative_database_name('ss_tmpdb12345678'));
|
|
$this->assertFalse(DB::valid_alternative_database_name('tmpdb1234567'));
|
|
$this->assertFalse(DB::valid_alternative_database_name('random'));
|
|
$this->assertFalse(DB::valid_alternative_database_name(''));
|
|
|
|
$origEnvType = Director::get_environment_type();
|
|
Director::set_environment_type('live');
|
|
$this->assertFalse(DB::valid_alternative_database_name('ss_tmpdb1234567'));
|
|
Director::set_environment_type($origEnvType);
|
|
}
|
|
|
|
} |