mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
712680a5e8
commit
2662896ed2
@ -9,6 +9,36 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
|
|
||||||
protected $autoFollowRedirection = false;
|
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() {
|
protected function generateNestedPagesFixture() {
|
||||||
$level1 = new Page();
|
$level1 = new Page();
|
||||||
$level1->Title = 'First Level';
|
$level1->Title = 'First Level';
|
||||||
@ -47,6 +77,8 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
* We're building up a page hierarchy ("nested URLs") and rename
|
* We're building up a page hierarchy ("nested URLs") and rename
|
||||||
* all the individual pages afterwards. The assumption is that
|
* all the individual pages afterwards. The assumption is that
|
||||||
* all pages will be found by their old segments.
|
* all pages will be found by their old segments.
|
||||||
|
*
|
||||||
|
* NOTE: This test requires nested_urls
|
||||||
*
|
*
|
||||||
* Original: level1/level2/level3
|
* Original: level1/level2/level3
|
||||||
* Republished as: newlevel1/newlevel2/newlevel3
|
* Republished as: newlevel1/newlevel2/newlevel3
|
||||||
@ -99,6 +131,11 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* NOTE: This test requires nested_urls
|
||||||
|
*
|
||||||
|
*/
|
||||||
function testRedirectsNestedRenamedPagesWithGetParameters() {
|
function testRedirectsNestedRenamedPagesWithGetParameters() {
|
||||||
$this->generateNestedPagesFixture();
|
$this->generateNestedPagesFixture();
|
||||||
|
|
||||||
@ -111,6 +148,11 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* NOTE: This test requires nested_urls
|
||||||
|
*
|
||||||
|
*/
|
||||||
function testDoesntRedirectToNestedRenamedPageWhenNewExists() {
|
function testDoesntRedirectToNestedRenamedPageWhenNewExists() {
|
||||||
$this->generateNestedPagesFixture();
|
$this->generateNestedPagesFixture();
|
||||||
|
|
||||||
@ -135,6 +177,11 @@ class ModelAsControllerTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* NOTE: This test requires nested_urls
|
||||||
|
*
|
||||||
|
*/
|
||||||
function testFindOldPage(){
|
function testFindOldPage(){
|
||||||
$page = new Page();
|
$page = new Page();
|
||||||
$page->Title = 'First Level';
|
$page->Title = 'First Level';
|
||||||
|
Loading…
Reference in New Issue
Block a user