mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fixed ORM tests
This commit is contained in:
parent
d75a8d1d93
commit
2a10c2397b
@ -70,7 +70,7 @@ class HTTP
|
|||||||
*/
|
*/
|
||||||
public static function absoluteURLs($html)
|
public static function absoluteURLs($html)
|
||||||
{
|
{
|
||||||
$html = str_replace('$CurrentPageURL', $_SERVER['REQUEST_URI'], $html);
|
$html = str_replace('$CurrentPageURL', Controller::curr()->getRequest()->getURL(), $html);
|
||||||
return HTTP::urlRewriter($html, function ($url) {
|
return HTTP::urlRewriter($html, function ($url) {
|
||||||
//no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":")
|
//no need to rewrite, if uri has a protocol (determined here by existence of reserved URI character ":")
|
||||||
if (preg_match('/^\w+:/', $url)) {
|
if (preg_match('/^\w+:/', $url)) {
|
||||||
@ -170,7 +170,8 @@ class HTTP
|
|||||||
*/
|
*/
|
||||||
public static function setGetVar($varname, $varvalue, $currentURL = null, $separator = '&')
|
public static function setGetVar($varname, $varvalue, $currentURL = null, $separator = '&')
|
||||||
{
|
{
|
||||||
$uri = $currentURL ? $currentURL : Director::makeRelative($_SERVER['REQUEST_URI']);
|
$request = Controller::curr()->getRequest();
|
||||||
|
$uri = $currentURL ?: $request->getURL();
|
||||||
|
|
||||||
$isRelative = false;
|
$isRelative = false;
|
||||||
// We need absolute URLs for parse_url()
|
// We need absolute URLs for parse_url()
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace SilverStripe\ORM\Tests;
|
namespace SilverStripe\ORM\Tests;
|
||||||
|
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
|
use SilverStripe\Core\Injector\Injector;
|
||||||
|
use SilverStripe\Core\Kernel;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
@ -11,19 +13,20 @@ class DBTest extends SapphireTest
|
|||||||
|
|
||||||
public function testValidAlternativeDatabaseName()
|
public function testValidAlternativeDatabaseName()
|
||||||
{
|
{
|
||||||
|
/** @var Kernel $kernel */
|
||||||
|
$kernel = Injector::inst()->get(Kernel::class);
|
||||||
$prefix = getenv('SS_DATABASE_PREFIX') ?: 'ss_';
|
$prefix = getenv('SS_DATABASE_PREFIX') ?: 'ss_';
|
||||||
|
|
||||||
Director::set_environment_type('dev');
|
$kernel->setEnvironment(Kernel::DEV);
|
||||||
$this->assertTrue(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
|
$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($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(''));
|
||||||
|
|
||||||
Director::set_environment_type('live');
|
$kernel->setEnvironment(Kernel::LIVE);
|
||||||
$this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
|
$this->assertFalse(DB::valid_alternative_database_name($prefix.'tmpdb1234567'));
|
||||||
|
|
||||||
Director::set_environment_type('dev');
|
$kernel->setEnvironment(Kernel::DEV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user