mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merged from branches/2.3
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77454 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a7e93c3099
commit
7cb259f051
@ -696,6 +696,10 @@ class Director {
|
|||||||
*
|
*
|
||||||
* Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev
|
* Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev
|
||||||
* mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back.
|
* mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back.
|
||||||
|
*
|
||||||
|
* Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and then push the site into test
|
||||||
|
* mode for the remainder of the session. Putting ?isTest=0 onto the URL can turn it back.
|
||||||
|
*
|
||||||
* Generally speaking, these methods will be called from your _config.php file.
|
* Generally speaking, these methods will be called from your _config.php file.
|
||||||
*
|
*
|
||||||
* Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and
|
* Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and
|
||||||
@ -778,12 +782,6 @@ class Director {
|
|||||||
if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], Director::$dev_servers)) {
|
if(isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], Director::$dev_servers)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// Check if we are running on one of the test servers
|
|
||||||
if(in_array($_SERVER['HTTP_HOST'], Director::$test_servers)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -793,6 +791,15 @@ class Director {
|
|||||||
* For information about environment types, see {@link Director::set_environment_type()}.
|
* For information about environment types, see {@link Director::set_environment_type()}.
|
||||||
*/
|
*/
|
||||||
static function isTest() {
|
static function isTest() {
|
||||||
|
// Use ?isTest=1 to get test access on the live server, or explicitly set your environment
|
||||||
|
if(isset($_GET['isTest'])) {
|
||||||
|
if(Security::database_is_ready()) {
|
||||||
|
BasicAuth::requireLogin("SilverStripe developer access. Use your CMS login", "ADMIN");
|
||||||
|
$_SESSION['isTest'] = $_GET['isTest'];
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(self::isDev()) return false;
|
if(self::isDev()) return false;
|
||||||
|
|
||||||
if(self::$environment_type) {
|
if(self::$environment_type) {
|
||||||
|
@ -154,6 +154,21 @@ class DataObjectTest extends SapphireTest {
|
|||||||
$this->assertTrue($comment->ParentID == $page->ID);
|
$this->assertTrue($comment->ParentID == $page->ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testHasOneRelationship() {
|
||||||
|
$team1 = $this->fixture->objFromFixture('DataObjectTest_Team', 'team1');
|
||||||
|
$player1 = $this->fixture->objFromFixture('DataObjectTest_Player', 'player1');
|
||||||
|
|
||||||
|
// Add a captain to team 1
|
||||||
|
$team1->setField('CaptainID', $player1->ID);
|
||||||
|
$team1->write();
|
||||||
|
|
||||||
|
$this->assertEquals($player1->ID, $team1->Captain()->ID, 'The captain exists for team 1');
|
||||||
|
$this->assertEquals($player1->ID, $team1->getComponent('Captain')->ID, 'The captain exists through the component getter');
|
||||||
|
|
||||||
|
$this->assertEquals($team1->Captain()->FirstName, 'Player 1', 'Player 1 is the captain');
|
||||||
|
$this->assertEquals($team1->getComponent('Captain')->FirstName, 'Player 1', 'Player 1 is the captain');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Test removeMany() and addMany() on $many_many relationships
|
* @todo Test removeMany() and addMany() on $many_many relationships
|
||||||
@ -633,7 +648,7 @@ class DataObjectTest_Player extends Member implements TestOnly {
|
|||||||
static $has_one = array(
|
static $has_one = array(
|
||||||
'FavouriteTeam' => 'DataObjectTest_Team',
|
'FavouriteTeam' => 'DataObjectTest_Team',
|
||||||
);
|
);
|
||||||
|
|
||||||
static $belongs_many_many = array(
|
static $belongs_many_many = array(
|
||||||
'Teams' => 'DataObjectTest_Team'
|
'Teams' => 'DataObjectTest_Team'
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user