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. (from r103591)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112151 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-13 03:58:29 +00:00
parent 712680a5e8
commit 2662896ed2

View File

@ -9,6 +9,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';
@ -47,6 +77,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
@ -99,6 +131,11 @@ class ModelAsControllerTest extends FunctionalTest {
);
}
/**
*
* NOTE: This test requires nested_urls
*
*/
function testRedirectsNestedRenamedPagesWithGetParameters() {
$this->generateNestedPagesFixture();
@ -111,6 +148,11 @@ class ModelAsControllerTest extends FunctionalTest {
);
}
/**
*
* NOTE: This test requires nested_urls
*
*/
function testDoesntRedirectToNestedRenamedPageWhenNewExists() {
$this->generateNestedPagesFixture();
@ -135,6 +177,11 @@ class ModelAsControllerTest extends FunctionalTest {
);
}
/**
*
* NOTE: This test requires nested_urls
*
*/
function testFindOldPage(){
$page = new Page();
$page->Title = 'First Level';