Skip to content

Commit

Permalink
BUGFIX: ModelAsController test failed for projects which do not suppo…
Browse files Browse the repository at this point in the history
…rt 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
  • Loading branch information
Rainer Spittel authored and Sam Minnee committed Feb 2, 2011
1 parent 6a72c21 commit 7f0677c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/control/ModelAsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -45,6 +75,8 @@ protected function generateNestedPagesFixture() {
* 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
Expand Down Expand Up @@ -97,6 +129,11 @@ function testDoesntRedirectToNestedChildrenOutsideOfOwnHierarchy() {
);
}

/**
*
* NOTE: This test requires nested_urls
*
*/
function testRedirectsNestedRenamedPagesWithGetParameters() {
$this->generateNestedPagesFixture();

Expand All @@ -109,6 +146,11 @@ function testRedirectsNestedRenamedPagesWithGetParameters() {
);
}

/**
*
* NOTE: This test requires nested_urls
*
*/
function testDoesntRedirectToNestedRenamedPageWhenNewExists() {
$this->generateNestedPagesFixture();

Expand All @@ -133,6 +175,11 @@ function testDoesntRedirectToNestedRenamedPageWhenNewExists() {
);
}

/**
*
* NOTE: This test requires nested_urls
*
*/
function testFindOldPage(){
$page = new Page();
$page->Title = 'First Level';
Expand Down

0 comments on commit 7f0677c

Please sign in to comment.