BUGFIX: ModelAsController test failed for projects which do not support nested urls. This fix stores the original configuration and enables 'nested-urls' at the beginning of the tests and reset the state in tearDown.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103591 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Rainer Spittel 2010-04-27 20:19:14 +00:00 committed by Sam Minnee
parent 6a72c21f0e
commit 7f0677cb1d

View File

@ -7,6 +7,36 @@ class ModelAsControllerTest extends FunctionalTest {
protected $autoFollowRedirection = false;
protected $orig = array();
/**
* New tests require nested urls to be enabled, but the site might not
* support nested URLs.
* This setup will enable nested-urls for this test and resets the state
* after the tests have been performed.
*/
function setUp() {
parent::setUp();
$this->orig['nested_urls'] = SiteTree::nested_urls();
SiteTree::enable_nested_urls();
}
/**
* New tests require nested urls to be enabled, but the site might not
* support nested URLs.
* This setup will enable nested-urls for this test and resets the state
* after the tests have been performed.
*/
function tearDown() {
if (isset($this->orig['nested_urls']) && !$this->orig['nested_urls']) {
SiteTree::disable_nested_urls();
}
parent::tearDown();
}
protected function generateNestedPagesFixture() {
$level1 = new Page();
$level1->Title = 'First Level';
@ -45,6 +75,8 @@ class ModelAsControllerTest extends FunctionalTest {
* We're building up a page hierarchy ("nested URLs") and rename
* all the individual pages afterwards. The assumption is that
* all pages will be found by their old segments.
*
* NOTE: This test requires nested_urls
*
* Original: level1/level2/level3
* Republished as: newlevel1/newlevel2/newlevel3
@ -97,6 +129,11 @@ class ModelAsControllerTest extends FunctionalTest {
);
}
/**
*
* NOTE: This test requires nested_urls
*
*/
function testRedirectsNestedRenamedPagesWithGetParameters() {
$this->generateNestedPagesFixture();
@ -109,6 +146,11 @@ class ModelAsControllerTest extends FunctionalTest {
);
}
/**
*
* NOTE: This test requires nested_urls
*
*/
function testDoesntRedirectToNestedRenamedPageWhenNewExists() {
$this->generateNestedPagesFixture();
@ -133,6 +175,11 @@ class ModelAsControllerTest extends FunctionalTest {
);
}
/**
*
* NOTE: This test requires nested_urls
*
*/
function testFindOldPage(){
$page = new Page();
$page->Title = 'First Level';