2012-12-06 16:25:45 +01:00
|
|
|
<?php
|
2016-06-15 16:03:16 +12:00
|
|
|
|
2016-10-14 14:30:05 +13:00
|
|
|
namespace SilverStripe\ORM\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Control\Director;
|
2016-06-15 16:03:16 +12:00
|
|
|
use SilverStripe\ORM\DB;
|
2016-08-19 10:51:35 +12:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
|
2016-12-16 17:34:21 +13:00
|
|
|
class DBTest extends SapphireTest
|
|
|
|
{
|
2012-12-06 16:25:45 +01:00
|
|
|
|
2016-12-16 17:34:21 +13:00
|
|
|
public function testValidAlternativeDatabaseName()
|
|
|
|
{
|
2014-08-15 18:53:05 +12:00
|
|
|
|
2017-01-30 15:33:56 +00:00
|
|
|
$prefix = getenv('SS_DATABASE_PREFIX') ?: 'ss_';
|
2014-08-15 18:53:05 +12:00
|
|
|
|
2017-02-22 16:15:08 +13:00
|
|
|
Director::set_environment_type('dev');
|
2016-12-16 17:34:21 +13:00
|
|
|
$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(''));
|
2012-12-06 16:25:45 +01:00
|
|
|
|
2017-02-22 16:15:08 +13:00
|
|
|
Director::set_environment_type('live');
|
2016-12-16 17:34:21 +13:00
|
|
|
$this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
|
2012-12-06 16:25:45 +01:00
|
|
|
|
2017-02-22 16:15:08 +13:00
|
|
|
Director::set_environment_type('dev');
|
2016-12-16 17:34:21 +13:00
|
|
|
}
|
2014-08-15 18:53:05 +12:00
|
|
|
}
|